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

Slow performance when printing PDF (fix provided)

    Details

    • Flags:
      Patch, Important

      Description

      When printing a PDF document (4 pages, 177KB, link below) using command

      java -jar pdfbox-app-2.0.0-RC1.jar PrintPDF test.pdf
      

      processing of the document before print takes about 15 seconds on system with Core i5-4670 processor.

      Most of the time is wasted on reading font files from system. The reason is that the font is read byte by byte in an unbuffered manner. The defective code is located in class org.apache.fontbox.ttf.RAFDataStream, where new instance of RandomAccessFile is created without buffering.

      I prepared a buffer wrapper over RandomAccessFile that adds buffering to RandomAccessFile. Use of the buffer in RAFDataStream shortens printing time 5 times, i.e., printing takes 3 seconds instead of 15s.

      The wrapper class is augmented version of a class released at https://code.google.com/p/jmzreader/wiki/BufferedRandomAccessFile (Apache License 2.0).

      Please integrate provided fix with original source of FontBox.

      PDF document and fix are available at http://1drv.ms/1NsKPFc

        Attachments

        1. test.pdf
          177 kB
          Tomasz Pawlak
        2. RAFDataStream.java
          11 kB
          Tomasz Pawlak
        3. RAFDataStream.java.patch
          6 kB
          Tomasz Pawlak

          Activity

            People

            • Assignee:
              tilman Tilman Hausherr
              Reporter:
              tomash Tomasz Pawlak
            • Votes:
              2 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 1h
                1h
                Remaining:
                Remaining Estimate - 1h
                1h
                Logged:
                Time Spent - Not Specified
                Not Specified