You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Eric Leleu (JIRA)" <ji...@apache.org> on 2013/04/14 19:24:15 UTC

[jira] [Commented] (PDFBOX-1546) The document's page tree contains an invalid node

    [ https://issues.apache.org/jira/browse/PDFBOX-1546?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13631356#comment-13631356 ] 

Eric Leleu commented on PDFBOX-1546:
------------------------------------

Hi,


The error comes from the OpenAction declared in your PDF.
This action contains the reference to the first page of the original PDF that has just been removed.

You have to update this value before the save method call:

            PDPageXYZDestination xyzDest = new PDPageXYZDestination();
            // WHen the PDF is open, go to the first page
            xyzDest.setPage((PDPage)pdfDoc.getDocumentCatalog().getAllPages().get(0));
            pdfDoc.getDocumentCatalog().setOpenAction(xyzDest);

Here is the full example : 

        PDDocument pdfDoc = PDDocument.load("JIRA-1546-test.pdf");
        if (pdfDoc != null) {
            pdfDoc.removePage(0);
            
            PDPageXYZDestination xyzDest = new PDPageXYZDestination();
            // WHen the PDF is open, go to the first page
            xyzDest.setPage((PDPage)pdfDoc.getDocumentCatalog().getAllPages().get(4));
            pdfDoc.getDocumentCatalog().setOpenAction(xyzDest);

            // Update the pdfDoc in the file system
            pdfDoc.save("test_ele.pdf");

        }


BR,
Eric
                
> The document's page tree contains an invalid node
> -------------------------------------------------
>
>                 Key: PDFBOX-1546
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-1546
>             Project: PDFBox
>          Issue Type: Bug
>          Components: PDModel
>    Affects Versions: 1.7.1
>         Environment: Windows 7 adobe reader 10.1.0
>            Reporter: Ken White
>              Labels: newbie
>         Attachments: test.modified_by_pdfbox.pdf, test.pdf
>
>
> After removing some pages and saving the PDDocument opening the document with adobe reader gives the following error.
> The document's page tree contains an invalid node
> The original document does not.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira