Bug 42136 - PDFDocumentGraphics2D.translate() does not work correctly with multiple pages
Summary: PDFDocumentGraphics2D.translate() does not work correctly with multiple pages
Status: NEW
Alias: None
Product: Fop - Now in Jira
Classification: Unclassified
Component: pdf (show other bugs)
Version: 0.95
Hardware: PC Linux
: P3 normal
Target Milestone: ---
Assignee: fop-dev
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-04-16 14:34 UTC by Ricardo Andere de Mello
Modified: 2012-04-07 01:52 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ricardo Andere de Mello 2007-04-16 14:34:06 UTC
I used the translate() method to move some custom graphics at the beginning of
every PDF page, using PDFDocumentGraphics2D, but if the FIRST call in the page
(after the nextpage()) is the translate(), the next translate() methods at other
pages dont work. 
To make it work correctly I had to place a dummy call after the nextpage(),
"drawline(0,0,0,0);", and then call the translate() method.

example:

THIS DOES NOT WORK:
g2d.translate(0,0);
g2d.drawLine(0,0,100,100)
g2d.nextPage();
g2d.translate(20,20);
g2d.drawLine(0,0,100,100)
g2d.nextPage();

THIS WORKS:
g2d.drawLine(0,0,0,0); //dummy
g2d.translate(0,0);
g2d.drawLine(0,0,100,100)
g2d.nextPage();
g2d.drawLine(0,0,0,0); //dummy
g2d.translate(20,20);
g2d.drawLine(0,0,100,100)
g2d.nextPage();
Comment 1 Julien Aymé 2010-05-07 03:31:55 UTC
Hi,
This bug main cause is that the page is not initialized until a draw method is called.

One solution could be to explicitly allow to call preparePainting() or startPage() (make the method public with a special warning on the javadoc: you have to know what you're doing).

Another solution would be to add a paragraph in the PDFDocumentGraphics2D javadoc that a dummy call to any draw method is required to initialize the current page and to allow subsequent transformation (any AffineTransform).
Comment 2 Glenn Adams 2012-04-07 01:45:11 UTC
resetting P2 open bugs to P3 pending further review