[ 
https://issues.apache.org/jira/browse/PDFBOX-6187?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Joseph Jezerinac updated PDFBOX-6187:
-------------------------------------
    Attachment:     (was: FailingDocument-sample.pdf)

>  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
>    Affects Versions: 3.0.6 PDFBox
>         Environment: Java 17 (OpenJDK)  
>            Reporter: Joseph Jezerinac
>            Priority: Major
>
> 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-sample.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]

Reply via email to