You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Spencer Gowin (JIRA)" <ji...@apache.org> on 2019/03/19 14:40:00 UTC
[jira] [Created] (PDFBOX-4490) .getNumberofPages() returns
incorrect value
Spencer Gowin created PDFBOX-4490:
-------------------------------------
Summary: .getNumberofPages() returns incorrect value
Key: PDFBOX-4490
URL: https://issues.apache.org/jira/browse/PDFBOX-4490
Project: PDFBox
Issue Type: Bug
Components: Utilities
Affects Versions: 2.0.14
Environment: Operating System: Ubuntu 18.04
Framework: Grails 2.5.6
Reporter: Spencer Gowin
Attachments: NeS1078.pdf
Uses the following method to return total page numbers:
{code:java}
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()
}
}
{code}
When using the attached PDF, it returns a total of two pages.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: dev-help@pdfbox.apache.org