Bug 43383 - AWT Renderer prints pages in the wrong order
Summary: AWT Renderer prints pages in the wrong order
Status: CLOSED FIXED
Alias: None
Product: Fop - Now in Jira
Classification: Unclassified
Component: awt renderer (show other bugs)
Version: 0.93
Hardware: PC Windows XP
: P2 normal
Target Milestone: ---
Assignee: fop-dev
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-09-13 05:45 UTC by Christian Wolf
Modified: 2012-04-01 06:34 UTC (History)
1 user (show)



Attachments
Printed Document on PDF pseudo printer (518.51 KB, application/octet-stream)
2007-09-13 05:47 UTC, Christian Wolf
Details
Used FOP XML document for printing (36.23 KB, text/plain)
2007-09-13 05:48 UTC, Christian Wolf
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Christian Wolf 2007-09-13 05:45:49 UTC
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.
Comment 1 Christian Wolf 2007-09-13 05:47:27 UTC
Created attachment 20815 [details]
Printed Document on PDF pseudo printer

Document printed to the WIN2PDF pseudo printer
Comment 2 Christian Wolf 2007-09-13 05:48:06 UTC
Created attachment 20816 [details]
Used FOP XML document for printing
Comment 3 Christian Wolf 2007-10-10 08:22:10 UTC
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!
Comment 4 Jeremias Maerki 2007-10-10 08:52:03 UTC
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
Comment 5 Christian Wolf 2007-10-11 03:46:09 UTC
Thanks for the hint, but we removed the total number of pages from the footer 
as a workaround, until the bug is fixed.
Comment 6 surf.incognito 2007-10-23 05:11:29 UTC
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!
Comment 7 Jeremias Maerki 2008-04-17 08:14:03 UTC
Set out-of-order support to false to make sure this cannot happen anymore:
http://svn.apache.org/viewvc?rev=649149&view=rev
Comment 8 Glenn Adams 2012-04-01 06:34:53 UTC
batch transition pre-FOP1.0 resolved+fixed bugs to closed+fixed