You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Tilman Hausherr (JIRA)" <ji...@apache.org> on 2019/03/19 20:18:00 UTC
[jira] [Updated] (PDFBOX-4490) .getNumberofPages() returns
incorrect value
[ https://issues.apache.org/jira/browse/PDFBOX-4490?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Tilman Hausherr updated PDFBOX-4490:
------------------------------------
Component/s: (was: Utilities)
Parsing
> .getNumberofPages() returns incorrect value
> -------------------------------------------
>
> Key: PDFBOX-4490
> URL: https://issues.apache.org/jira/browse/PDFBOX-4490
> Project: PDFBox
> Issue Type: Bug
> Components: Parsing
> Affects Versions: 2.0.14
> Environment: Operating System: Ubuntu 18.04
> Framework: Grails 2.5.6
> Reporter: Spencer
> Priority: Trivial
> 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