Uploaded image for project: 'PDFBox'
  1. PDFBox
  2. PDFBOX-5051

Slow rendering for specific PDF file

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0.21
    • 2.0.24, 3.0.0 PDFBox
    • Rendering
    • None
    • Amazon Coretto jdk11.0.3_7, OpenJDK 15

    Description

      Doing PDF rendering upon the document being attached is rather slow.

      It takes 18 seconds on a Core i7 machine with 32 GB of RAM and no maximum being imposed upon the JVM.

       System.setProperty("sun.java2d.cmm", "sun.java2d.cmm.kcms.KcmsServiceProvider");
       long ms = System.currentTimeMillis();        
       try (final PDDocument document = PDDocument.load(new File("C:\\temp\\slowpdfbox.pdf")))
      {         
      ms = System.currentTimeMillis() -ms;         
      System.out.println("Took " + ms + " milliseconds for loading");                     
      PDFRenderer pdfRenderer = new PDFRenderer(document);            
      pdfRenderer.setSubsamplingAllowed(true);            
      
      for (int page = 0; page < 1; ++page)            
      {             
      ms = System.currentTimeMillis();                             
      BufferedImage bim = pdfRenderer.renderImageWithDPI(page, 300, ImageType.RGB);                                
      ms = System.currentTimeMillis() -ms;                
      System.out.println("Took " + ms + " milliseconds for rendering");                   
                      
      String fileName = "c:\\temp\\test.jpg";                
      ImageIOUtil.writeImage(bim, fileName, 300); //<---this number            
      }           
       document.close();        
      } 
      catch (IOException e){           
       System.err.println("Exception while reading pdf document - " + e);        
      }
      
      
      

      Console Output:

      Took 262 milliseconds for loading
      Dez. 18, 2020 6:25:15 VORM. org.apache.pdfbox.pdmodel.graphics.color.PDICCBased ensureDisplayProfile
      WARNUNG: ICC profile is Perceptual, ignoring, treating as Display class
      Took 17914 milliseconds for rendering

       

       

      Attachments

        1. slowpdfbox.pdf
          37 kB
          Stefan Mueller

        Issue Links

          Activity

            People

              tilman Tilman Hausherr
              steve4j Stefan Mueller
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: