Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Cannot Reproduce
    • 2.0.5
    • None
    • Rendering

    Description

      I have a PDF with 2 images in it on 2 separate pages. Each page also has some text. When I try to print the PDF, the first page renders fine, but nothing renders for the second page and I get a blank page printed.

          String sourcePDF = "C:\\temp\\CPTest\\MyTest.pdf";
          PrinterJob job = PrinterJob.getPrinterJob();
          try (PDDocument document = PDDocument.load(new File(sourcePDF))) {
            job.setPageable(new PDFPageable(document);
            PrintService service = getPrintService("Adobe PDF");
            job.setPrintService(service);
            job.print();
          } catch (IOException | PrinterException e) {
            throw new RuntimeException("Unable to print file " + sourcePDF + ".", e);
          }
      

      I have also tried printing to a physical printer with the same results. Saves me paper by just using the Adobe PDF printer.

      Attachments

        1. PDFBOX-3776-reduced.pdf
          153 kB
          Tilman Hausherr
        2. Java Printing Test.pdf
          378 kB
          Jon Ominsky
        3. Mytest.pdf
          1.92 MB
          Jon Ominsky

        Issue Links

        Activity

          jominsky Jon Ominsky created issue -
          jominsky Jon Ominsky made changes -
          Field Original Value New Value
          Attachment Mytest.pdf [ 12866218 ]
          jominsky Jon Ominsky added a comment -

          The Java Printing Test.pdf is the result of printing.

          jominsky Jon Ominsky added a comment - The Java Printing Test.pdf is the result of printing.
          jominsky Jon Ominsky made changes -
          Attachment Java Printing Test.pdf [ 12866219 ]
          jominsky Jon Ominsky made changes -
          Description I have a PDF with 2 images in it on 2 separate pages. Each page also has some text. When I try to print the PDF, the first page renders fine, but nothing renders for the second page and I get a blank page printed. I have a PDF with 2 images in it on 2 separate pages. Each page also has some text. When I try to print the PDF, the first page renders fine, but nothing renders for the second page and I get a blank page printed.

          {code}
              String sourcePDF = "C:\\temp\\CPTest\\MyTest.pdf";
              PrinterJob job = PrinterJob.getPrinterJob();
              try (PDDocument document = PDDocument.load(new File(sourcePDF))) {
                job.setPageable(new PDFPageable(document);
                PrintService service = getPrintService("Adobe PDF");
                job.setPrintService(service);
                job.print();
              } catch (IOException | PrinterException e) {
                throw new RuntimeException("Unable to print file " + sourcePDF + ".", e);
              }
          {code}
          jominsky Jon Ominsky made changes -
          Description I have a PDF with 2 images in it on 2 separate pages. Each page also has some text. When I try to print the PDF, the first page renders fine, but nothing renders for the second page and I get a blank page printed.

          {code}
              String sourcePDF = "C:\\temp\\CPTest\\MyTest.pdf";
              PrinterJob job = PrinterJob.getPrinterJob();
              try (PDDocument document = PDDocument.load(new File(sourcePDF))) {
                job.setPageable(new PDFPageable(document);
                PrintService service = getPrintService("Adobe PDF");
                job.setPrintService(service);
                job.print();
              } catch (IOException | PrinterException e) {
                throw new RuntimeException("Unable to print file " + sourcePDF + ".", e);
              }
          {code}
          I have a PDF with 2 images in it on 2 separate pages. Each page also has some text. When I try to print the PDF, the first page renders fine, but nothing renders for the second page and I get a blank page printed.

          {code}
              String sourcePDF = "C:\\temp\\CPTest\\MyTest.pdf";
              PrinterJob job = PrinterJob.getPrinterJob();
              try (PDDocument document = PDDocument.load(new File(sourcePDF))) {
                job.setPageable(new PDFPageable(document);
                PrintService service = getPrintService("Adobe PDF");
                job.setPrintService(service);
                job.print();
              } catch (IOException | PrinterException e) {
                throw new RuntimeException("Unable to print file " + sourcePDF + ".", e);
              }
          {code}

          I have also tried printing to a physical printer with the same results. Saves me paper by just using the Adobe PDF printer.
          tilman Tilman Hausherr made changes -
          Affects Version/s 2.0.5 [ 12338759 ]
          tilman Tilman Hausherr added a comment - - edited

          All versions from 2.0.0 upwards can render the second page, but none can print it, if the first page is printed. As a workaround, use the PDFPageable constructor that has a dpi parameter. Use 300 or 600 or whatever you like best for dpi.

          Please delete your SO question, I doubt there will be any answers, as this is a bug in PDFBox or in java.

          tilman Tilman Hausherr added a comment - - edited All versions from 2.0.0 upwards can render the second page, but none can print it, if the first page is printed. As a workaround, use the PDFPageable constructor that has a dpi parameter. Use 300 or 600 or whatever you like best for dpi. Please delete your SO question, I doubt there will be any answers, as this is a bug in PDFBox or in java.
          tilman Tilman Hausherr made changes -
          Component/s Rendering [ 12322302 ]
          tilman Tilman Hausherr made changes -
          Labels printing

          Reduced version of your file.

          tilman Tilman Hausherr added a comment - Reduced version of your file.
          tilman Tilman Hausherr made changes -
          Attachment PDFBOX-3776-reduced.pdf [ 12866243 ]
          tilman Tilman Hausherr made changes -
          Link This issue relates to PDFBOX-3729 [ PDFBOX-3729 ]

          Somewhat similar to PDFBOX-3729, although that one needs an unusual modification of the spooler settings, and this one doesn't.

          tilman Tilman Hausherr added a comment - Somewhat similar to PDFBOX-3729 , although that one needs an unusual modification of the spooler settings, and this one doesn't.
          jominsky Jon Ominsky made changes -
          Attachment CMC-MBOM-001_PATTARO Roberto.pdf [ 12866413 ]
          jominsky Jon Ominsky made changes -
          Attachment CMC-MBOM-001_PATTARO Roberto.pdf [ 12866413 ]
          jominsky Jon Ominsky made changes -
          Comment [ So...that resolved the issue. However, I was using this PDF as something to reproduce the real issue I have with a document from a client that I'm not sure I can share. I will ask the client if I can share a single page of that document that illustrates the issue and will attach it. ]
          jominsky Jon Ominsky made changes -
          Comment [ Attaching the PDF file that I cannot get printed from the client. The first two pages print, but the rest only have the footer / header and not the image. ]
          jominsky Jon Ominsky made changes -
          Comment [ It was not. I installed it and was able to print correctly. Thank you for the quick responses and guidance. ]
          jominsky Jon Ominsky made changes -
          Comment [ I spoke too soon. This resolved the issue with the images, but when I print to a printer, the A4 pages are not shrinking. I did create a class that essentially is PDFPageable but takes a scaling property (shrink to fit) when creating the PDFPrinter object. However, the A4 pages still print on the Letter size paper. Any suggestions? Should I instead post this on SO? ]
          tilman Tilman Hausherr made changes -
          Comment [ Yes, there or on the mailing list, but improve your description, i.e. does your printer only have letter? Include as much as possible of your code. To clean up this issue, please remove the latest file and all comments (i.e. all of today, and the "So...that resolved the issue" (it doesn't,, it's just a workaround)) related to the jbig2 issue, I'll delete mine too including this one. This is just to focus on the original problem. ]
          tilman Tilman Hausherr made changes -
          Comment [ That one I can print. Is the levigo jbig2 decoder plugin installed? ]
          tilman Tilman Hausherr made changes -
          Labels printing print printing
          tilman Tilman Hausherr made changes -
          Link This issue relates to PDFBOX-4010 [ PDFBOX-4010 ]
          tilman Tilman Hausherr added a comment - TODO for me: try to reproduce https://stackoverflow.com/questions/17814657/blank-page-when-printing-bufferedimage-in-java

          I am unable to reproduce the SO issue, and now I am unable to reproduce THIS issue. Even when using 2.0.5. Thus I suspect that the bug is fixed in current java versions. I am using jdk8 151.

          tilman Tilman Hausherr added a comment - I am unable to reproduce the SO issue, and now I am unable to reproduce THIS issue. Even when using 2.0.5. Thus I suspect that the bug is fixed in current java versions. I am using jdk8 151.
          tilman Tilman Hausherr added a comment - - edited

          Jon Ominsky can please you retest? If it still happens, please tell more about your system (os and jdk).

          tilman Tilman Hausherr added a comment - - edited Jon Ominsky can please you retest? If it still happens, please tell more about your system (os and jdk).

          Closing because I can't reproduce it anymore and there hasn't been further feedback.

          tilman Tilman Hausherr added a comment - Closing because I can't reproduce it anymore and there hasn't been further feedback.
          tilman Tilman Hausherr made changes -
          Resolution Cannot Reproduce [ 5 ]
          Status Open [ 1 ] Closed [ 6 ]

          People

            Unassigned Unassigned
            jominsky Jon Ominsky
            Votes:
            1 Vote for this issue
            Watchers:
            Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack