Hi, 
Is there a way to add form fields to a pdf using PdfStamper?  The only thing I
have found is that I can set fields if the field exists in the PdfReader.  I
want to add fields though like I can do using PdfWriter.  I have tried two
methods to read in a page from a pdf file that has a graphic I made using
Acrobat's pencil tool and add form fields.  In the first one below, it doesn't
seem as though I can add them.  In the second one, I can add them, but I don't
get the graphic I made using the pencil tool on the template.  Any suggestions?

Example 1
PdfReader reader = new PdfReader("C:\\approvalSheetTemplate.pdf");
FileOutputStream outFile = new FileOutputStream("C:\\approvalSheet.pdf");
PdfStamper outStamper = new PdfStamper(reader, outFile);
outStamper.close();

Example 2
PdfReader reader = new
PdfReader("/com/test/ed/mls/inboard/approvalSheetTemplate.pdf");
int numberOfPages = reader.getNumberOfPages();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Document document = new Document(reader.getPageSize(1));
PdfWriter writer = PdfWriter.getInstance(document, baos);
document.open();
PdfContentByte cb = writer.getDirectContent();
cb.addTemplate(writer.getImportedPage(reader, 1), 0, 0);
fieldName = "test";
rectangle = new Rectangle(1, 750, 26, 765);
TextField testTextField = new TextField(writer, rectangle, fieldName);
testTextField.setText("testText");
writer.addAnnotation(testTextField.getTextField());

Thanks,
Ed



-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_id=5047&alloc_id=10808&op=click
_______________________________________________
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to