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

.getNumberofPages() returns incorrect value

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Trivial
    • Resolution: Fixed
    • 2.0.14
    • 2.0.15, 3.0.0 PDFBox
    • Parsing
    • None
    • Operating System: Ubuntu 18.04
      Framework: Grails 2.5.6

    Description

      Uses the following method to return total page numbers:

      static int pageCount(byte[] document) { withDocument(document) { PDDocument pdf -> pdf.getNumberOfPages() } }
      
      
      static Object withDocument(byte[] document, Closure clos) {
          PDDocument doc
      
          try {
              // Read the PDF file via PdfBox
              ByteArrayInputStream bais = new ByteArrayInputStream(document)
              doc = PDDocument.load(bais, MemoryUsageSetting.setupTempFileOnly())
      
              // Clone the Closure as a security measureee
              Closure clone = clos.clone()
      
              // Execute the custom processing on the PDDocument
              clone(doc)
          } finally {
              doc?.close()
          }
      }
      

      When using the attached PDF, it returns a total of two pages.

      Attachments

        1. NeS1078.pdf
          277 kB
          Spencer

        Issue Links

          Activity

            People

              lehmi Andreas Lehmkühler
              spencer.gowin Spencer
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: