Hi,

Below is a bug I discovered in pdfbox (2.0.27, Windows, JRE 1.8.0_361).  I 
traced it through the code and saw there is in fact a way that a (probably 
malformed) form could generate the NPE.  I wish I could share the pdf document 
to reproduce, but I cannot.  Perhaps looking at the where a null could come 
from in acroFormLegacyMode will clarify the situation.  It's pretty clear when 
you look at the relevant code.

I think there should be a null check, and then skip the problematic field if 
you find one... or at least emit a more helpful message.

Thanks,

Chris

> java -jar pdfbox-app-2.0.27.jar PDFMerger mydoc.pdf mydoc.pdf merged.pdf
Exception in thread "main" java.lang.NullPointerException
        at 
org.apache.pdfbox.multipdf.PDFMergerUtility.acroFormLegacyMode(PDFMergerUtility.java:1451)
        at 
org.apache.pdfbox.multipdf.PDFMergerUtility.mergeAcroForm(PDFMergerUtility.java:1262)
        at 
org.apache.pdfbox.multipdf.PDFMergerUtility.appendDocument(PDFMergerUtility.java:576)
        at 
org.apache.pdfbox.multipdf.PDFMergerUtility.legacyMergeDocuments(PDFMergerUtility.java:461)
        at 
org.apache.pdfbox.multipdf.PDFMergerUtility.mergeDocuments(PDFMergerUtility.java:347)
        at org.apache.pdfbox.tools.PDFMerger.merge(PDFMerger.java:70)
        at org.apache.pdfbox.tools.PDFMerger.main(PDFMerger.java:49)
        at org.apache.pdfbox.tools.PDFBox.main(PDFBox.java:81)



________________________________

NOTICE - This communication may contain confidential and privileged information 
that is for the sole use of the intended recipient. Any viewing, copying or 
distribution of, or reliance on this message by unintended recipients is 
strictly prohibited. If you have received this message in error, please notify 
us immediately by replying to the message and deleting it from your computer.

Reply via email to