Details
-
Bug
-
Status: Closed
-
Trivial
-
Resolution: Fixed
-
2.0.14
-
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
Attachments
Issue Links
- is related to
-
PDFBOX-4759 Add tests for PDFBOX-4153 and PDFBOX-4490
- Closed