You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "John Hewson (JIRA)" <ji...@apache.org> on 2015/12/11 19:31:11 UTC
[jira] [Comment Edited] (PDFBOX-3154)
PDDocumentCatalog.getDocumentCatalog().getPages().getCount() returns 0 -
first page is -1
[ https://issues.apache.org/jira/browse/PDFBOX-3154?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15053154#comment-15053154 ]
John Hewson edited comment on PDFBOX-3154 at 12/11/15 6:30 PM:
---------------------------------------------------------------
It doesn't make any difference, but just so that you know, your sample code:
{code}
PDDocument pdDocument = PDDocument.load(inputStream);
int pages = pdDocument.getDocumentCatalog().getPages().getCount();
PDPage page = pdDocument.getDocumentCatalog().getPages().get(-1);
{code}
Can be simplified to:
{code}
PDDocument pdDocument = PDDocument.load(inputStream);
int pages = pdDocument.getNumberOfPages();
PDPage page = pdDocument.getPage(-1);
{code}
was (Author: jahewson):
It doesn't make any difference, but just so that you know, your sample code:
{code}
PDDocument pdDocument = PDDocument.load(inputStream);
int pages = pdDocument.getDocumentCatalog().getPages().getCount();
PDPage page = pdDocument.getDocumentCatalog().getPages().get(-1);
{code}
Can be simplified to:
{code}
PDDocument pdDocument = PDDocument.load(inputStream);
int pages = pdDocument.getNumberOfPages()
PDPage page = pdDocument.getPages().get(-1)
{code}
> PDDocumentCatalog.getDocumentCatalog().getPages().getCount() returns 0 - first page is -1
> -----------------------------------------------------------------------------------------
>
> Key: PDFBOX-3154
> URL: https://issues.apache.org/jira/browse/PDFBOX-3154
> Project: PDFBox
> Issue Type: Bug
> Affects Versions: 2.0.0
> Reporter: Aleksander Blomskøld
> Attachments: siba.pdf
>
>
> The attached PDF opens fine in the readers I have checked, but PDFBox has some issues with it. It apparently has 0 pages, but it is possible to get the first page by asking for page number -1.
> Code:
> PDDocument pdDocument = PDDocument.load(inputStream);
> int pages = pdDocument.getDocumentCatalog().getPages().getCount();
> //pages == 0
> PDPage page = pdDocument.getDocumentCatalog().getPages().get(-1);
> //page != null
> This behaviour exists on version 2.0.0.rc2 and on trunk.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: dev-help@pdfbox.apache.org