When i print a specific document with 2 pages with AWT Renderer, the second page is printed first, and then the first page. Even if i select a PDF pseudo printer driver (WIN2PDF), the generated PDF contains first the second page, then the first page (see attached PDF). Printing code: Pageable p = getFop93Pageable(fopString); printJavaxDefault(p,DocFlavor.SERVICE_FORMATTED.PAGEABLE); Utility method code for generating Pageable: public static Pageable getFop93Pageable(String fopString){ StringReader reader = new StringReader(fopString); if(fopFactory == null){ fopFactory = FopFactory.newInstance(); } try { AWTRenderer renderer = new AWTRenderer(); FOUserAgent agent = fopFactory.newFOUserAgent(); agent.setRendererOverride(renderer); renderer.setPreviewDialogDisplayed(false); renderer.setUserAgent(agent); Fop fop = fopFactory.newFop(AWTRenderer.MIME_TYPE, agent); TransformerFactory factory = TransformerFactory.newInstance(); Transformer transformer = factory.newTransformer(); Source src = new StreamSource(reader); Result res = new SAXResult(fop.getDefaultHandler()); transformer.transform(src, res); return renderer; } catch (Exception e) { e.printStackTrace(); throw new RuntimeException(e); } finally{ if(reader != null) reader.close(); } } Utility method code for printing pageable: public static void printJavaxDefault(Object input, DocFlavor flavor){ PrintService pservice = PrintServiceLookup.lookupDefaultPrintService(); if(pservice==null) { throw new RuntimeException("No print service available"); } DocPrintJob pj = pservice.createPrintJob(); Doc doc = new SimpleDoc(input, flavor, null); PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet(); aset.add(MediaSizeName.ISO_A4); try { pj.print(doc, aset); } catch (PrintException e) { throw new RuntimeException(e); } } The used FOP XML document (fopString) is attached to this bug report.
Created attachment 20815 [details] Printed Document on PDF pseudo printer Document printed to the WIN2PDF pseudo printer
Created attachment 20816 [details] Used FOP XML document for printing
We experimented a little bit with the document and could confirm that this bug is related with the usage of the total numer of pages in the document footer. <fo:block text-align="end"> Seite <fo:page-number /> von <fo:page-number-citation ref-id="LASTBLOCK1" /> </fo:block> If we don't generate the total numer of pages in the footer, the pages are printed in the correct order!
As a short-term work-around, can you please modify AWTRenderer.supportsOutOfOrder() and make sure it returns "false"? I'm pretty sure that's the problem. Of course, you'll need the sources for that and you have to rebuild FOP yourself. HTH
Thanks for the hint, but we removed the total number of pages from the footer as a workaround, until the bug is fixed.
Had the same problem generating total numer of pages and applied the patch mentioned above. AWTRenderer.java: /** @see org.apache.fop.render.Renderer */ public boolean supportsOutOfOrder() { return false; // TODO true? } It works fine!
Set out-of-order support to false to make sure this cannot happen anymore: http://svn.apache.org/viewvc?rev=649149&view=rev
batch transition pre-FOP1.0 resolved+fixed bugs to closed+fixed