[
https://issues.apache.org/jira/browse/PDFBOX-6187?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18071139#comment-18071139
]
ASF subversion and git services commented on PDFBOX-6187:
---------------------------------------------------------
Commit 1932851 from Tilman Hausherr in branch 'pdfbox/branches/3.0'
[ https://svn.apache.org/r1932851 ]
PDFBOX-6187: avoid NPE
> NullPointerException in AppearanceGeneratorHelper when PDFont.getName()
> returns null
> ---------------------------------------------------------------------------------------
>
> Key: PDFBOX-6187
> URL: https://issues.apache.org/jira/browse/PDFBOX-6187
> Project: PDFBox
> Issue Type: Bug
> Components: AcroForm
> Affects Versions: 3.0.6 PDFBox
> Environment: Java 17 (OpenJDK)
> Reporter: Joseph Jezerinac
> Priority: Major
> Attachments: failingdocument.pdf, screenshot-1.png
>
>
> When opening a PDF that contains an AcroForm text field whose font resource
> has no /BaseFont entry, PDFont.getName() returns null. The default AcroForm
> fixup triggered by getAcroForm() calls refreshAppearances(), which leads to a
> NullPointerException in
> AppearanceGeneratorHelper.insertGeneratedAppearance() at line 516, where
> String.contains() is called on the null return value without a null check.
> Steps to reproduce:
> {code:java}
>
>
>
> import org.apache.pdfbox.Loader;
>
>
>
> import org.apache.pdfbox.pdmodel.PDDocument;
>
>
>
> import org.apache.pdfbox.pdmodel.interactive.form.PDAcroForm;
>
>
>
> import java.io.File;
>
>
>
>
> public class PdfBoxNullFontNameTest {
>
>
>
>
> private static final String PDF_PATH = "/path/to/failingdocument.pdf";
>
>
>
>
> public static void main(String[] args) throws Exception {
> File pdf = new File(PDF_PATH);
>
>
>
> PDDocument doc = Loader.loadPDF(pdf);
> PDAcroForm form = doc.getDocumentCatalog().getAcroForm();
>
>
>
> }
> }
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]