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

ASF subversion and git services commented on PDFBOX-2803:
---------------------------------------------------------

Commit 1679889 from [~jahewson] in branch 'pdfbox/trunk'
[ https://svn.apache.org/r1679889 ]

PDFBOX-2803: Avoid NPE in willBeSubset()

> NullPointerException into class PDType0Font
> -------------------------------------------
>
>                 Key: PDFBOX-2803
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-2803
>             Project: PDFBox
>          Issue Type: Bug
>    Affects Versions: 2.0.0
>            Reporter: Konstantin Kakunin
>            Assignee: John Hewson
>             Fix For: 2.0.0
>
>         Attachments: help-email.zip
>
>
> I find error on trunk (from 12 May 2015 )
> {code}
> Exception in thread "main" java.lang.NullPointerException
>     at 
> org.apache.pdfbox.pdmodel.font.PDType0Font.willBeSubset(PDType0Font.java:150)
>     at 
> org.apache.pdfbox.pdmodel.PDPageContentStream.setFont(PDPageContentStream.java:304)
>     at 
> org.apache.pdfbox.pdmodel.interactive.form.AppearanceGeneratorHelper.insertGeneratedAppearance(AppearanceGeneratorHelper.java:295)
>     at 
> org.apache.pdfbox.pdmodel.interactive.form.AppearanceGeneratorHelper.createAppearanceContent(AppearanceGeneratorHelper.java:227)
>     at 
> org.apache.pdfbox.pdmodel.interactive.form.AppearanceGeneratorHelper.setAppearanceValue(AppearanceGeneratorHelper.java:202)
>     at 
> org.apache.pdfbox.pdmodel.interactive.form.AppearanceGenerator.generateFieldAppearances(AppearanceGenerator.java:61)
>     at 
> org.apache.pdfbox.pdmodel.interactive.form.PDField.updateFieldAppearances(PDField.java:110)
>     at 
> org.apache.pdfbox.pdmodel.interactive.form.PDTextField.setValue(PDTextField.java:286)
>     at pdftext.my_main.main(my_main.java:74)
> {code} 
> For me, I fixed error as:
> {code}
>    /**
>     * Constructor for reading a Type0 font from a PDF file.
>     * 
>     * @param fontDictionary The font dictionary according to the PDF 
> specification.
>     */
>     public PDType0Font(COSDictionary fontDictionary) throws IOException
>     {
>         super(fontDictionary);
>         COSArray descendantFonts = 
> (COSArray)dict.getDictionaryObject(COSName.DESCENDANT_FONTS);
>         COSDictionary descendantFontDictionary = (COSDictionary) 
> descendantFonts.getObject(0);
>         if (descendantFontDictionary == null)
>         {
>             throw new IOException("Missing descendant font dictionary");
>         }
>         descendantFont = 
> PDFontFactory.createDescendantFont(descendantFontDictionary, this);
>         readEncoding();
>         fetchCMapUCS2();
>         
> //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
>         PDType0Font parentFont = PDType0Font.load(new PDDocument(), new 
> File("c:\\Windows\\Fonts\\arial.ttf")); //kostya!!!!
>         embedder = parentFont.embedder; //kostya!!!!
>     }
> {code}
> embedder has not been initialized in 
> {code}
> public PDType0Font(COSDictionary fontDictionary) throws IOException
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to