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();
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).
resetting P2 open bugs to P3 pending further review