All,
I was hoping for a quick sanity check here. I've got my code working, but I
want to make sure I haven't missed an optimizations.


Quick Description:

I have an existing PDF form with named fields. The form does have a
watermark that I added, but the rest of it was created in Acrobat. (i think)
The users of my app select one to N number of items.
For each item selected, a form is filled out and merged with the other to
result in an N length pdf.


Concerns:
I've got this working but the file seems a little large ~5 megs for 50
items. It makes me think that somehow I should be able to have a single
"form", and each page would just exist as a collection of form values. Not
being a PDF expert though, my expectations might be too high.

That being said, is there any way I could improve the final size of this
file? Speed up the process? Make it more efficient? (Part the test has been
removed, assume everything needed is there. I was throwing Exception just to
get this code tested, the production version should be more appropriately
laid out.)


   @Test
  public void createPdfs() throws Exception {

       InputStream is = new FileInputStream(FILE_PATH);
       PdfReader original = new PdfReader(is);

       PdfCopyFields allDocs = new PdfCopyFields(new
FileOutputStream("C:\\pdftest\\testCONCAT.pdf"));
       ByteArrayOutputStream baos = new ByteArrayOutputStream();
       for (Items dd : list) {
           // do the following for each target
           PdfReader readerCopy = new PdfReader(original);
           readerCopy.removeUsageRights();
           baos.reset();
           PdfStamper stamper = new PdfStamper(readerCopy, baos);
           AcroFields form = stamper.getAcroFields();
           form.setField("docNumberAndSuffix", dd.getMessage());
           stamper.setFormFlattening(true);
           stamper.close();
           allDocs.addDocument(new PdfReader(baos.toByteArray()));

       }
       allDocs.setFullCompression();
       allDocs.close();
   }



Thanks in advance all.
--james
------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.itextpdf.com/book/
Check the site with examples before you ask questions: 
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/

Reply via email to