Uploaded image for project: 'FOP'
  1. FOP
  2. FOP-1415

AWT Renderer prints pages in the wrong order

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Resolution: Fixed
    • 0.93
    • None
    • renderer/awt
    • None
    • Operating System: Windows XP
      Platform: PC
    • 43383

    Description

      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.

      Attachments

        1. fop.txt
          36 kB
          Christian Wolf
        2. Java Printing.pdf
          519 kB
          Christian Wolf

        Activity

          People

            fop-dev@xmlgraphics.apache.org fop-dev
            wolfc@spardat.at Christian Wolf
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: