You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "ASF subversion and git services (JIRA)" <ji...@apache.org> on 2015/04/23 20:14:39 UTC
[jira] [Commented] (PDFBOX-2704) PDPageTree.indexOf doesn't find
page numbers
[ https://issues.apache.org/jira/browse/PDFBOX-2704?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14509505#comment-14509505 ]
ASF subversion and git services commented on PDFBOX-2704:
---------------------------------------------------------
Commit 1675695 from [~tilman] in branch 'pdfbox/trunk'
[ https://svn.apache.org/r1675695 ]
PDFBOX-2704: fix bug in PDPageTree.indexOf and add test, by Andrea Vacondio
> PDPageTree.indexOf doesn't find page numbers
> --------------------------------------------
>
> Key: PDFBOX-2704
> URL: https://issues.apache.org/jira/browse/PDFBOX-2704
> Project: PDFBox
> Issue Type: Bug
> Components: PDModel
> Affects Versions: 2.0.0
> Environment: 2.0.0-SNAPSHOT r1665633
> Reporter: Andrea Vacondio
> Assignee: Tilman Hausherr
> Labels: PDPageTree
> Fix For: 2.0.0
>
> Attachments: bigger_outline_test.pdf, page_tree_index_of.diff, page_tree_multiple_levels.pdf, with_outline.pdf
>
>
> I know https://issues.apache.org/jira/browse/PDFBOX-2423 is not closed yet so I'm not sure if the issues I'm having are a cause of that.
> I'm using the latest trunk and I have issues with the PDPageTree.indexOf method. The javadoc reads ??Returns the index of the given page, or -1 if it does not exist.?? which I understand it means in returns -1 if the given page is not found in the page tree correct? If so, the following unit test fails:
> {code}
> @Test
> public void indexOfNotFoundPage() throws IOException {
> PDDocument doc1 = PDDocument.load(getClass().getClassLoader()
> .getResourceAsStream("pdf/bigger_outline_test.pdf"));
> assertEquals(-1, doc1.getPages().indexOf(new PDPage()));
> }
> {code}
> Another similar issue I have is that PDPageTree.indexOf doesn't find the correct index for a PDPage returned by the PDOutlineItem.findDestinationPage:
> {code}
> @Test
> public void indexOfPageFromOutlineDestination() throws IOException {
> PDDocument doc = PDDocument
> .load(getClass().getClassLoader().getResourceAsStream("pdf/bigger_outline_test.pdf"));
> PDDocumentOutline outline = doc.getDocumentCatalog().getDocumentOutline();
> for (PDOutlineItem current : outline.children()) {
> if (current.getTitle().contains("Second")) {
> assertEquals(3, doc.getPages().indexOf(current.findDestinationPage(doc)));
> }
> }
> }
> {code}
> Also note that indexOf is used by PDPageDestination.findPageNumber which also returns a wrong result.
--
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