Author: ssteiner Date: Wed May 9 15:04:25 2018 New Revision: 1831255 URL: http://svn.apache.org/viewvc?rev=1831255&view=rev Log: FOP-2772: NPE where pdf used as background image
Modified: xmlgraphics/fop-pdf-images/trunk/src/java/org/apache/fop/render/pdf/pdfbox/AbstractPDFBoxHandler.java xmlgraphics/fop-pdf-images/trunk/test/java/org/apache/fop/render/pdf/PDFBoxAdapterTestCase.java Modified: xmlgraphics/fop-pdf-images/trunk/src/java/org/apache/fop/render/pdf/pdfbox/AbstractPDFBoxHandler.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop-pdf-images/trunk/src/java/org/apache/fop/render/pdf/pdfbox/AbstractPDFBoxHandler.java?rev=1831255&r1=1831254&r2=1831255&view=diff ============================================================================== --- xmlgraphics/fop-pdf-images/trunk/src/java/org/apache/fop/render/pdf/pdfbox/AbstractPDFBoxHandler.java (original) +++ xmlgraphics/fop-pdf-images/trunk/src/java/org/apache/fop/render/pdf/pdfbox/AbstractPDFBoxHandler.java Wed May 9 15:04:25 2018 @@ -110,7 +110,7 @@ public abstract class AbstractPDFBoxHand } String stream = adapter.createStreamFromPDFBoxPage(pddoc, page, originalImageUri, at, fontinfo, pos); - if (userAgent.isAccessibilityEnabled()) { + if (userAgent.isAccessibilityEnabled() && curentSessionElem != null) { TaggedPDFConductor conductor = new TaggedPDFConductor(curentSessionElem, handler, page, adapter); conductor.handleLogicalStructure(pddoc); } Modified: xmlgraphics/fop-pdf-images/trunk/test/java/org/apache/fop/render/pdf/PDFBoxAdapterTestCase.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop-pdf-images/trunk/test/java/org/apache/fop/render/pdf/PDFBoxAdapterTestCase.java?rev=1831255&r1=1831254&r2=1831255&view=diff ============================================================================== --- xmlgraphics/fop-pdf-images/trunk/test/java/org/apache/fop/render/pdf/PDFBoxAdapterTestCase.java (original) +++ xmlgraphics/fop-pdf-images/trunk/test/java/org/apache/fop/render/pdf/PDFBoxAdapterTestCase.java Wed May 9 15:04:25 2018 @@ -543,4 +543,21 @@ public class PDFBoxAdapterTestCase { getPDFBoxAdapter(false).createStreamFromPDFBoxPage(doc, page, CFF1, at, new FontInfo(), new Rectangle()); doc.close(); } + + @Test + public void testPDFBoxImageHandlerAccessibilityEnabled() throws Exception { + ImageInfo imgi = new ImageInfo("a", "b"); + PDDocument doc = PDDocument.load(new File(SHADING)); + ImagePDF img = new ImagePDF(imgi, doc); + PDFDocument pdfdoc = new PDFDocument(""); + PDFPage pdfpage = getPDFPage(pdfdoc); + pdfpage.setDocument(pdfdoc); + PDFContentGenerator con = new PDFContentGenerator(pdfdoc, null, null); + FOUserAgent mockedAgent = mock(FOUserAgent.class); + when(mockedAgent.isAccessibilityEnabled()).thenReturn(true); + when(mockedAgent.getPDFObjectCache()).thenReturn(new SoftMapCache(true)); + PDFRenderingContext c = new PDFRenderingContext(mockedAgent, con, pdfpage, null); + c.setPageNumbers(new HashMap<Integer, PDFArray>()); + new PDFBoxImageHandler().handleImage(c, img, new Rectangle()); + } } --------------------------------------------------------------------- To unsubscribe, e-mail: fop-commits-unsubscr...@xmlgraphics.apache.org For additional commands, e-mail: fop-commits-h...@xmlgraphics.apache.org