[
https://issues.apache.org/jira/browse/PDFBOX-743?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12876237#action_12876237
]
Philipp Koch commented on PDFBOX-743:
-------------------------------------
i changes the lines in question and ran my test. it still worked.
my changes:
--- pdfbox/src/main/java/org/apache/pdfbox/pdfviewer/PageDrawer.java
(revision 952200)
+++ pdfbox/src/main/java/org/apache/pdfbox/pdfviewer/PageDrawer.java
(working copy)
@@ -124,13 +124,15 @@
appearanceName = "default";
}
Map appearanceMap = appearDictionary.getNormalAppearance();
- PDAppearanceStream appearance =
- (PDAppearanceStream)appearanceMap.get( appearanceName );
- if( appearance != null )
- {
- g.translate( (int)rect.getLowerLeftX(),
(int)-rect.getLowerLeftY() );
- processSubStream( page, appearance.getResources(),
appearance.getStream() );
- g.translate( (int)-rect.getLowerLeftX(),
(int)+rect.getLowerLeftY() );
+ if (appearanceMap != null){
+ PDAppearanceStream appearance =
+ (PDAppearanceStream)appearanceMap.get( appearanceName
);
+ if( appearance != null )
+ {
+ g.translate( (int)rect.getLowerLeftX(),
(int)-rect.getLowerLeftY() );
+ processSubStream( page, appearance.getResources(),
appearance.getStream() );
+ g.translate( (int)-rect.getLowerLeftX(),
(int)+rect.getLowerLeftY() );
+ }
}
}
}
Index:
pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/PDAppearanceDictionary.java
===================================================================
---
pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/PDAppearanceDictionary.java
(revision 952200)
+++
pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/PDAppearanceDictionary.java
(working copy)
@@ -85,7 +85,10 @@
public Map getNormalAppearance()
{
COSBase ap = dictionary.getDictionaryObject( COSName.getPDFName( "N" )
);
- if( ap instanceof COSStream )
+ if (ap == null) {
+ return null;
+ }
+ if( ap instanceof COSStream)
{
COSStream aux = (COSStream) ap;
ap = new COSDictionary();
> PDAppereanceDictionary#getNormalAppearance might throw NPE
> ----------------------------------------------------------
>
> Key: PDFBOX-743
> URL: https://issues.apache.org/jira/browse/PDFBOX-743
> Project: PDFBox
> Issue Type: Bug
> Components: PDModel
> Affects Versions: 1.1.0
> Reporter: Philipp Koch
> Fix For: 1.2.0
>
>
> following code patch will ensure that no NPE is thrown. the question is if
> the check for NULL is done at the correct place (functionally yes)
> respectively is it correct to apply the default configuration setting for
> that case?
> @@ -85,7 +85,7 @@
> public Map getNormalAppearance()
> {
> COSBase ap = dictionary.getDictionaryObject( COSName.getPDFName( "N"
> ) );
> - if( ap instanceof COSStream )
> + if( ap instanceof COSStream || ap == null)
> {
> COSStream aux = (COSStream) ap;
> ap = new COSDictionary();
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.