prevent NPE in new inline image processing code copied from PDFBox
@@ -33,6 +33,7 @@ import org.apache.pdfbox.pdmodel.graphics.image.PDImage;
import org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject;
import org.apache.pdfbox.pdmodel.graphics.pattern.PDAbstractPattern;
import org.apache.pdfbox.pdmodel.graphics.pattern.PDTilingPattern;
+import org.apache.pdfbox.pdmodel.graphics.state.PDExtendedGraphicsState;
import org.apache.pdfbox.pdmodel.graphics.state.PDSoftMask;
import org.apache.pdfbox.pdmodel.graphics.state.RenderingMode;
import org.apache.pdfbox.tools.imageio.ImageIOUtil;
@@ -118,7 +119,9 @@ class ImageGraphicsEngine extends PDFGraphicsStreamEngine {
}
for (COSName name : res.getExtGStateNames()) {
- PDSoftMask softMask = res.getExtGState(name).getSoftMask();
+ PDExtendedGraphicsState extendedGraphicsState = res.getExtGState(name);
+ if (extendedGraphicsState != null) {
+ PDSoftMask softMask = extendedGraphicsState.getSoftMask();
if (softMask != null) {
try {
@@ -136,6 +139,7 @@ class ImageGraphicsEngine extends PDFGraphicsStreamEngine {
}
}
}
+ }
@Override
public void drawImage(PDImage pdImage) throws IOException {
