You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Adam Nichols (JIRA)" <ji...@apache.org> on 2010/04/23 01:40:52 UTC

[jira] Created: (PDFBOX-700) NullPointerException when trying to merge PDFs

NullPointerException when trying to merge PDFs
----------------------------------------------

                 Key: PDFBOX-700
                 URL: https://issues.apache.org/jira/browse/PDFBOX-700
             Project: PDFBox
          Issue Type: Bug
          Components: Utilities
    Affects Versions: 1.1.0
         Environment: Windows Vista 32-bit, Java 1.5.0_06, PDFBox HEAD tag (revision 937101)
            Reporter: Adam Nichols
             Fix For: 1.2.0
         Attachments: US_Constitutional_Ammendments.pdf, US_Constitutional_Ammendments_copy.pdf

I was trying to use the PDFMergerUtility class to merge some PDFs.  Using the unmodified PDFBox source, I get a NullPointerException when I call mergeDocuments().  I made two different copies of the same file to make sure it wasn't caused by something like file access.  The file opens fine with Adobe Acrobat, and PDFBox can load the document with no problem, so it doesn't seem to be a corrupt PDF in this case.  I'm not familiar with the PDOutlineNode class, so I'm not sure where to go from here.  I will attach the PDF I'm using to this bug report.  If there's anything else I can provide let me know.

Code:
public static void main(String[] args) {
        String inputFile0 = "C:\\US_Constitutional_Ammendments_copy.pdf";
        String inputFile1 = "C:\\US_Constitutional_Ammendments.pdf";
        String outputFile = "C:\\US_Constitutional_Ammendments_output.pdf";
        try {
            PDFMergerUtility pdfMergerUtil = new PDFMergerUtility();
            pdfMergerUtil.setDestinationFileName(outputFile);
            pdfMergerUtil.addSource(inputFile0);
            pdfMergerUtil.addSource(inputFile1);
            pdfMergerUtil.mergeDocuments();
            System.out.println("Yay, nothing went wrong.");
        } catch(Exception e) {
            System.out.println("Oh no, something went wrong!");
            e.printStackTrace();
        }
    }

java.lang.NullPointerException
        at org.apache.pdfbox.pdmodel.interactive.documentnavigation.outline.PDOutlineNode.setParent(PDOutlineNode.java:108)
        at org.apache.pdfbox.pdmodel.interactive.documentnavigation.outline.PDOutlineNode.appendChild(PDOutlineNode.java:118)
        at org.apache.pdfbox.util.PDFMergerUtility.appendDocument(PDFMergerUtility.java:303)
        at org.apache.pdfbox.util.PDFMergerUtility.mergeDocuments(PDFMergerUtility.java:193)
        at com.xldynamics.common.MergeTest.main(MergeTest.java:35)


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (PDFBOX-700) NullPointerException when trying to merge PDFs

Posted by "Adam Nichols (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/PDFBOX-700?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12860079#action_12860079 ] 

Adam Nichols commented on PDFBOX-700:
-------------------------------------

Sorry, two of the line numbers were off because I forgot to update my jar file after reverting my changes to PDFMergerUtility.  Same result, just different line numbers.

java.lang.NullPointerException
        at org.apache.pdfbox.pdmodel.interactive.documentnavigation.outline.PDOutlineNode.setParent(PDOutlineNode.java:108)
        at org.apache.pdfbox.pdmodel.interactive.documentnavigation.outline.PDOutlineNode.appendChild(PDOutlineNode.java:118)
        at org.apache.pdfbox.util.PDFMergerUtility.appendDocument(PDFMergerUtility.java:243)
        at org.apache.pdfbox.util.PDFMergerUtility.mergeDocuments(PDFMergerUtility.java:136)


> NullPointerException when trying to merge PDFs
> ----------------------------------------------
>
>                 Key: PDFBOX-700
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-700
>             Project: PDFBox
>          Issue Type: Bug
>          Components: Utilities
>    Affects Versions: 1.1.0
>         Environment: Windows Vista 32-bit, Java 1.5.0_06, PDFBox HEAD tag (revision 937101)
>            Reporter: Adam Nichols
>             Fix For: 1.2.0
>
>         Attachments: US_Constitutional_Ammendments.pdf, US_Constitutional_Ammendments_copy.pdf
>
>
> I was trying to use the PDFMergerUtility class to merge some PDFs.  Using the unmodified PDFBox source, I get a NullPointerException when I call mergeDocuments().  I made two different copies of the same file to make sure it wasn't caused by something like file access.  The file opens fine with Adobe Acrobat, and PDFBox can load the document with no problem, so it doesn't seem to be a corrupt PDF in this case.  I'm not familiar with the PDOutlineNode class, so I'm not sure where to go from here.  I will attach the PDF I'm using to this bug report.  If there's anything else I can provide let me know.
> Code:
> public static void main(String[] args) {
>         String inputFile0 = "C:\\US_Constitutional_Ammendments_copy.pdf";
>         String inputFile1 = "C:\\US_Constitutional_Ammendments.pdf";
>         String outputFile = "C:\\US_Constitutional_Ammendments_output.pdf";
>         try {
>             PDFMergerUtility pdfMergerUtil = new PDFMergerUtility();
>             pdfMergerUtil.setDestinationFileName(outputFile);
>             pdfMergerUtil.addSource(inputFile0);
>             pdfMergerUtil.addSource(inputFile1);
>             pdfMergerUtil.mergeDocuments();
>             System.out.println("Yay, nothing went wrong.");
>         } catch(Exception e) {
>             System.out.println("Oh no, something went wrong!");
>             e.printStackTrace();
>         }
>     }
> java.lang.NullPointerException
>         at org.apache.pdfbox.pdmodel.interactive.documentnavigation.outline.PDOutlineNode.setParent(PDOutlineNode.java:108)
>         at org.apache.pdfbox.pdmodel.interactive.documentnavigation.outline.PDOutlineNode.appendChild(PDOutlineNode.java:118)
>         at org.apache.pdfbox.util.PDFMergerUtility.appendDocument(PDFMergerUtility.java:303)
>         at org.apache.pdfbox.util.PDFMergerUtility.mergeDocuments(PDFMergerUtility.java:193)
>         at com.xldynamics.common.MergeTest.main(MergeTest.java:35)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (PDFBOX-700) NullPointerException when trying to merge PDFs

Posted by "Andreas Lehmkühler (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/PDFBOX-700?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Andreas Lehmkühler resolved PDFBOX-700.
---------------------------------------

    Resolution: Fixed

I've applied the patch with version 940369.

Thanks to Alan for the contribution.

> NullPointerException when trying to merge PDFs
> ----------------------------------------------
>
>                 Key: PDFBOX-700
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-700
>             Project: PDFBox
>          Issue Type: Bug
>          Components: Utilities
>    Affects Versions: 1.1.0
>         Environment: Windows Vista 32-bit, Java 1.5.0_06, PDFBox HEAD tag (revision 937101)
>            Reporter: Adam Nichols
>             Fix For: 1.2.0
>
>         Attachments: PDFBOX-700.patch, US_Constitutional_Ammendments.pdf, US_Constitutional_Ammendments_copy.pdf
>
>
> I was trying to use the PDFMergerUtility class to merge some PDFs.  Using the unmodified PDFBox source, I get a NullPointerException when I call mergeDocuments().  I made two different copies of the same file to make sure it wasn't caused by something like file access.  The file opens fine with Adobe Acrobat, and PDFBox can load the document with no problem, so it doesn't seem to be a corrupt PDF in this case.  I'm not familiar with the PDOutlineNode class, so I'm not sure where to go from here.  I will attach the PDF I'm using to this bug report.  If there's anything else I can provide let me know.
> Code:
> public static void main(String[] args) {
>         String inputFile0 = "C:\\US_Constitutional_Ammendments_copy.pdf";
>         String inputFile1 = "C:\\US_Constitutional_Ammendments.pdf";
>         String outputFile = "C:\\US_Constitutional_Ammendments_output.pdf";
>         try {
>             PDFMergerUtility pdfMergerUtil = new PDFMergerUtility();
>             pdfMergerUtil.setDestinationFileName(outputFile);
>             pdfMergerUtil.addSource(inputFile0);
>             pdfMergerUtil.addSource(inputFile1);
>             pdfMergerUtil.mergeDocuments();
>             System.out.println("Yay, nothing went wrong.");
>         } catch(Exception e) {
>             System.out.println("Oh no, something went wrong!");
>             e.printStackTrace();
>         }
>     }
> java.lang.NullPointerException
>         at org.apache.pdfbox.pdmodel.interactive.documentnavigation.outline.PDOutlineNode.setParent(PDOutlineNode.java:108)
>         at org.apache.pdfbox.pdmodel.interactive.documentnavigation.outline.PDOutlineNode.appendChild(PDOutlineNode.java:118)
>         at org.apache.pdfbox.util.PDFMergerUtility.appendDocument(PDFMergerUtility.java:303)
>         at org.apache.pdfbox.util.PDFMergerUtility.mergeDocuments(PDFMergerUtility.java:193)
>         at com.xldynamics.common.MergeTest.main(MergeTest.java:35)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (PDFBOX-700) NullPointerException when trying to merge PDFs

Posted by "Adam Nichols (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/PDFBOX-700?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Adam Nichols updated PDFBOX-700:
--------------------------------

    Attachment: PDFBOX-700.patch

Patch which is so simple I'm embarrassed to have asked for help.  Resolves the issue.

> NullPointerException when trying to merge PDFs
> ----------------------------------------------
>
>                 Key: PDFBOX-700
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-700
>             Project: PDFBox
>          Issue Type: Bug
>          Components: Utilities
>    Affects Versions: 1.1.0
>         Environment: Windows Vista 32-bit, Java 1.5.0_06, PDFBox HEAD tag (revision 937101)
>            Reporter: Adam Nichols
>             Fix For: 1.2.0
>
>         Attachments: PDFBOX-700.patch, US_Constitutional_Ammendments.pdf, US_Constitutional_Ammendments_copy.pdf
>
>
> I was trying to use the PDFMergerUtility class to merge some PDFs.  Using the unmodified PDFBox source, I get a NullPointerException when I call mergeDocuments().  I made two different copies of the same file to make sure it wasn't caused by something like file access.  The file opens fine with Adobe Acrobat, and PDFBox can load the document with no problem, so it doesn't seem to be a corrupt PDF in this case.  I'm not familiar with the PDOutlineNode class, so I'm not sure where to go from here.  I will attach the PDF I'm using to this bug report.  If there's anything else I can provide let me know.
> Code:
> public static void main(String[] args) {
>         String inputFile0 = "C:\\US_Constitutional_Ammendments_copy.pdf";
>         String inputFile1 = "C:\\US_Constitutional_Ammendments.pdf";
>         String outputFile = "C:\\US_Constitutional_Ammendments_output.pdf";
>         try {
>             PDFMergerUtility pdfMergerUtil = new PDFMergerUtility();
>             pdfMergerUtil.setDestinationFileName(outputFile);
>             pdfMergerUtil.addSource(inputFile0);
>             pdfMergerUtil.addSource(inputFile1);
>             pdfMergerUtil.mergeDocuments();
>             System.out.println("Yay, nothing went wrong.");
>         } catch(Exception e) {
>             System.out.println("Oh no, something went wrong!");
>             e.printStackTrace();
>         }
>     }
> java.lang.NullPointerException
>         at org.apache.pdfbox.pdmodel.interactive.documentnavigation.outline.PDOutlineNode.setParent(PDOutlineNode.java:108)
>         at org.apache.pdfbox.pdmodel.interactive.documentnavigation.outline.PDOutlineNode.appendChild(PDOutlineNode.java:118)
>         at org.apache.pdfbox.util.PDFMergerUtility.appendDocument(PDFMergerUtility.java:303)
>         at org.apache.pdfbox.util.PDFMergerUtility.mergeDocuments(PDFMergerUtility.java:193)
>         at com.xldynamics.common.MergeTest.main(MergeTest.java:35)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (PDFBOX-700) NullPointerException when trying to merge PDFs

Posted by "Adam Nichols (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/PDFBOX-700?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Adam Nichols updated PDFBOX-700:
--------------------------------

    Attachment: US_Constitutional_Ammendments.pdf
                US_Constitutional_Ammendments_copy.pdf

The input files

> NullPointerException when trying to merge PDFs
> ----------------------------------------------
>
>                 Key: PDFBOX-700
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-700
>             Project: PDFBox
>          Issue Type: Bug
>          Components: Utilities
>    Affects Versions: 1.1.0
>         Environment: Windows Vista 32-bit, Java 1.5.0_06, PDFBox HEAD tag (revision 937101)
>            Reporter: Adam Nichols
>             Fix For: 1.2.0
>
>         Attachments: US_Constitutional_Ammendments.pdf, US_Constitutional_Ammendments_copy.pdf
>
>
> I was trying to use the PDFMergerUtility class to merge some PDFs.  Using the unmodified PDFBox source, I get a NullPointerException when I call mergeDocuments().  I made two different copies of the same file to make sure it wasn't caused by something like file access.  The file opens fine with Adobe Acrobat, and PDFBox can load the document with no problem, so it doesn't seem to be a corrupt PDF in this case.  I'm not familiar with the PDOutlineNode class, so I'm not sure where to go from here.  I will attach the PDF I'm using to this bug report.  If there's anything else I can provide let me know.
> Code:
> public static void main(String[] args) {
>         String inputFile0 = "C:\\US_Constitutional_Ammendments_copy.pdf";
>         String inputFile1 = "C:\\US_Constitutional_Ammendments.pdf";
>         String outputFile = "C:\\US_Constitutional_Ammendments_output.pdf";
>         try {
>             PDFMergerUtility pdfMergerUtil = new PDFMergerUtility();
>             pdfMergerUtil.setDestinationFileName(outputFile);
>             pdfMergerUtil.addSource(inputFile0);
>             pdfMergerUtil.addSource(inputFile1);
>             pdfMergerUtil.mergeDocuments();
>             System.out.println("Yay, nothing went wrong.");
>         } catch(Exception e) {
>             System.out.println("Oh no, something went wrong!");
>             e.printStackTrace();
>         }
>     }
> java.lang.NullPointerException
>         at org.apache.pdfbox.pdmodel.interactive.documentnavigation.outline.PDOutlineNode.setParent(PDOutlineNode.java:108)
>         at org.apache.pdfbox.pdmodel.interactive.documentnavigation.outline.PDOutlineNode.appendChild(PDOutlineNode.java:118)
>         at org.apache.pdfbox.util.PDFMergerUtility.appendDocument(PDFMergerUtility.java:303)
>         at org.apache.pdfbox.util.PDFMergerUtility.mergeDocuments(PDFMergerUtility.java:193)
>         at com.xldynamics.common.MergeTest.main(MergeTest.java:35)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.