Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » iText »

AW: [iText-questions] How to insert pdf form fields in different
 pages??

"Sölter, Peter"

2005-06-01


Hi Anitha,
you'll have to process one page after the other and do the
formfield.setPage()
on every page the PdfWriter is actually at.

In your code the PDfWriter is already on the last page.
Therefore all fields appear on this page.

Maybe you could write your own XML-parsing code and iterate through the
pages.

Greetings,
Peter

-----Ursprüngliche Nachricht-----
Von: itext-questions-admin@(protected)
[mailto:itext-questions-admin@(protected)
Soares
Gesendet: Dienstag, 31. Mai 2005 18:02
An: anitha.d.chandran@(protected);
itext-questions-admin@(protected)
Betreff: RE: [iText-questions] How to insert pdf form fields in different
pages??


That won't work with XML.

> -----Original Message-----
> From: itext-questions-admin@(protected)
> [mailto:itext-questions-admin@(protected)
> Behalf Of anitha.d.chandran@(protected)
> Sent: Tuesday, May 31, 2005 12:32 PM
> To: itext-questions@(protected);
> itext-questions-admin@(protected)
> Subject: [iText-questions] How to insert pdf form fields in
> different pages??
>
>
>
>
>
> Hi,
> I am trying ton insert pdfForm fields in a 5 page Document. One
> field, I need to isert in the 4th page and the rest in page5.
>
> This is the code snippet, I use for the same..
> But, even if I specify the page Number as 4 and 5, all the
> form fields,
> comes in the last(5th) page only.
> Could you please help.?
>
>
> --------------------------------------------------------------
> --------------------------------------------------------------
> ------------------
>
> document = new Document();
> baos = new ByteArrayOutputStream();
> writer = PdfWriter.getInstance(document, baos);
> writer.getPageNumber();
>
> SAXiTextHandler saxItextHandler = new SAXiTextHandler(document);
> saxItextHandler.setControlOpenClose(false);
> saxItextHandler.startDocument();
> document.open();
>
> SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
> parser.parse(new ByteArrayInputStream(pdfContents.getBytes()),
> saxItextHandler);
>
> Rectangle rect = null;
> Color color = new Color(0,0,120);
> BaseFont bf =
> FontFactory.getFont(FontFactory.HELVETICA_OBLIQUE).getBaseFont();
> //.getCalculatedBaseFont(false);
>
>
> //First Form Field
>
> rect = new Rectangle(10, 10, 10, 10);
> TextField tf = new TextField(writer,rect, "fmField1");
> tf.setTextColor(color);
> tf.setFont(bf);
> PdfFormField formField2 = tf.getTextField();
> formField2.setWidget(rect, PdfAnnotation.HIGHLIGHT_NONE);
> formField2.setFlags(PdfAnnotation.FLAGS_PRINT);
> formField2.setFieldName("fmField1");
> formField2.setPage(4);
> writer.addAnnotation(formField2);
>
> //second form field.
> rect = new Rectangle(10, 10, 10, 10);
> tf = new TextField(writer,rect, "fmField2");
> tf.setTextColor(color);
> tf.setFont(bf);
> PdfFormField formField3 = tf.getTextField();
> formField3.setWidget(rect, PdfAnnotation.HIGHLIGHT_NONE);
> formField3.setFlags(PdfAnnotation.FLAGS_PRINT);
> formField3.setFieldName("fmField2");
> formField3.setPage(5);
> writer.addAnnotation(formField3);
>
>
> --------------------------------------------------------------
> --------------------------------------------------------------
> --------------------
>
> Thanks,
> Anitha
>
>
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by Yahoo.
> Introducing Yahoo! Search Developer Network - Create apps using Yahoo!
> Search APIs Find out how you can build Yahoo! directly into your own
> Applications - visit
> http://developer.yahoo.net/?fr=offad-ysdn-ostg-q22005
> _______________________________________________
> iText-questions mailing list iText-questions@(protected)
> https://lists.sourceforge.net/lists/listinfo/itext-questions
>


-------------------------------------------------------
This SF.Net email is sponsored by Yahoo.
Introducing Yahoo! Search Developer Network - Create apps using Yahoo!
Search APIs Find out how you can build Yahoo! directly into your own
Applications - visit http://developer.yahoo.net/?fr=offad-ysdn-ostg-q22005
_______________________________________________
iText-questions mailing list iText-questions@(protected)
https://lists.sourceforge.net/lists/listinfo/itext-questions


-------------------------------------------------------
This SF.Net email is sponsored by Yahoo.
Introducing Yahoo! Search Developer Network - Create apps using Yahoo!
Search APIs Find out how you can build Yahoo! directly into your own
Applications - visit http://developer.yahoo.net/?fr=offad-ysdn-ostg-q22005
_______________________________________________
iText-questions mailing list
iText-questions@(protected)
https://lists.sourceforge.net/lists/listinfo/itext-questions
©2008 junlu.com - Jax Systems, LLC, U.S.A.