You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Andreas Lehmkühler (JIRA)" <ji...@apache.org> on 2019/03/24 11:08:00 UTC
[jira] [Comment Edited] (PDFBOX-4490) .getNumberofPages() returns
incorrect value
[ https://issues.apache.org/jira/browse/PDFBOX-4490?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16799988#comment-16799988 ]
Andreas Lehmkühler edited comment on PDFBOX-4490 at 3/24/19 11:07 AM:
----------------------------------------------------------------------
It seems to be a runtime issue. It works for Oracle JDK 1.7.0_75 and fails for OpenJDK 1.8.0_201 at least on fedora.
Update: it fails as well for Oracle 1.8.0_73
was (Author: lehmi):
It seems to be a runtime issue. It works for Oracle JDK 1.7.0_75 and fails for OpenJDK 1.8.0_201 at least on fedora.
> .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