Hi Paulo,
I have a fixed size PDF form and I use PDFStamper to populate the fields. The document has 15 pages. There are couple of fields which span multiple pages. In the PDF I have named the fields as name.1, name.2, name.3 etc. If the contents should continue from name.1 to name.2 and name.3. I have the following code:
public void checkMultiplePageSpan(AcroFields form, String name, String value, PdfStamper stamper) throws DocumentException, IOException
{
int i = 1;
String field = name + "." + i;
// Point it to page 1
PdfContentByte cb = stamper.getOverContent(1);
ColumnText text = new ColumnText(cb);
text.addText(new Phrase(value, FontFactory.getFont(FontFactory.COURIER, 12, Font.NORMAL)));
do
{
AcroFields.Item item = form.getFieldItem(field);
if (item != null)
{
int pageN = ((Integer)item.page.get(0)).intValue();
float[] position = form.getFieldPositions(field);
{
int i = 1;
String field = name + "." + i;
// Point it to page 1
PdfContentByte cb = stamper.getOverContent(1);
ColumnText text = new ColumnText(cb);
text.addText(new Phrase(value, FontFactory.getFont(FontFactory.COURIER, 12, Font.NORMAL)));
do
{
AcroFields.Item item = form.getFieldItem(field);
if (item != null)
{
int pageN = ((Integer)item.page.get(0)).intValue();
float[] position = form.getFieldPositions(field);
// Here I need to specify which page the contents should be written
text.setSimpleColumn(position[1], position[2], position[3], position[4]);
field = name + "." + (++i);
}
else
{
break;
}
}
while ((text.go() & ColumnText.NO_MORE_TEXT) == 0);
}
field = name + "." + (++i);
}
else
{
break;
}
}
while ((text.go() & ColumnText.NO_MORE_TEXT) == 0);
}
Now the question is, how do I move to the specific page every time, using the same columntext.?
If this is not possible, is there any other way I can achieve this?
Thank you very much.
Merlyn.
Do you Yahoo!?
Take Yahoo! Mail with you! Get it on your mobile phone.