Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » iText »

Re: [iText-questions] Re : Re : Re : Re : direct-mail and
manipulation of pdf

Bruno

2007-08-21

Replies:

chtiteuf@(protected):
> I don't find how to proceed to fill n times 1 form

You're getting on my nerves.
What is there about the example I referred to earlier that
you don't understand?
http://itext.ugent.be/articles/eid-pdf/index.php#template

PdfReader reader;
ByteArrayOutputStream baos;
PdfStamper stamper;
AcroFields form;
Document document = new Document();
try {
 PdfSmartCopy copy = new PdfSmartCopy(document, new
FileOutputStream("EIDForms.pdf"));
 document.open();
 for (int i = 0; i < values.length; i++) {
  // set fields
  reader = new PdfReader("EIDFormTemplate.pdf");
  baos = new ByteArrayOutputStream();
  stamper = new PdfStamper(reader, baos);
  form = stamper.getAcroFields();
  form.setExtraMargin(0, 1);
  for (int j = 0; j < keys.length; j++) {
    form.setField(keys[j], values[i][j]);
  }
  stamper.setFormFlattening(true);
  stamper.close();
  // add page
  reader = new PdfReader(baos.toByteArray());
  copy.addPage(copy.getImportedPage(reader, 1));
 }
} catch (DocumentException de) {
 System.err.println(de.getMessage());
} catch (IOException ioe) {
 System.err.println(ioe.getMessage());
}
document.close();

What more can I say? You just don't want to listen...
Bruno

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
iText-questions mailing list
iText-questions@(protected)
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/
©2008 junlu.com - Jax Systems, LLC, U.S.A.