Leonard Rosenthol <leonardr <at> pdfsages.com> writes:
> Coordinates are PAGE RELATIVE - so adding the size of a page will
> simply put the field off the page, NOT onto a second (or subsequent) page.
>
> Leonard
Thank you for the speedy reply. However, the problem (for me, at least) is that
addMap() method only provides for the coordinate parameters, without regard to
the page number. So, how would I distinguish between the field at location
y=100 on page 1, and the field with y=100 on page 2?
Perhaps, I should show how the pages are formatted in our app.
1. A Document object is created, and PdfAcroForm object is grabbed from it:
Document document = new Document(new com.lowagie.text.Rectangle(612, 792));
ByteArrayOutputStream os = new ByteArrayOutputStream();
PdfWriter writer = PdfWriter.getInstance(document, os);
PdfAcroForm acroForm = writer.getAcroForm();
document.open();
PdfContentByte cb = writer.getDirectContent();
2. Pages are drawn in a loop: 0 < page < nPages
if (page > 0)
{
try { document.newPage(); }
catch(DocumentException de) { System.err.println(de.getMessage()); }
}
imageProvider.setRenedringPage(page); // JComponent that draws pages
PdfTemplate tp = cb.createTemplate(width, height);
Graphics2D g2 = tp.createGraphics(width, height, mapper);
g2.translate(0, -height * page);
imageProvider.paintContents(g2);
g2.dispose();
cb.addTemplate(tp, 0, 0);
3. After all pages have been drawn, the fields are sensitized in a loop:
java.awt.Rectangle cursorFrame = field.getCursorFrame(); // field frame, coord
origin is at the report bottom
int xOrigin = field.getDisplayFrameXOrigin();
int yOrigin = reportHeight - cursorFrame.y;
int width = cursorFrame.width;
int height = field.getDisplayFrameHeight();
acroForm.addMap(fieldID, null, url, cb, xOrigin, yOrigin - height, xOrigin +
width, yOrigin);
4. The Document is closed:
document.close();
Should I perhaps do addMap() in the loop that creates pages, and sensitize the
page fields before the next page is created?
Alex.
-------------------------------------------------------
This SF.net email is sponsored by: The Robotic Monkeys at ThinkGeek
For a limited time only, get FREE Ground shipping on all orders of $35
or more. Hurry up and shop folks, this offer expires April 30th!
http://www.thinkgeek.com/freeshipping/?cpg=12297
_______________________________________________
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions