When setting accessibility with : A. userAgent.setAccessibility(true) and then generating PDF, an exception occurs : ----- ERROR org.apache.fop.area.AreaTreeModel - Error while rendering page 1 java.lang.NullPointerException at org.apache.fop.render.pdf.PDFPainter.prepareImageMCID(PDFPainter.java:152) ----- It seems that logicalStructureHandler of PDFPainter is null. The cause is that the logicalStructureHandler is set when calling : B. FopFactory.newFop(String outputFormat, FOUserAgent userAgent, OutputStream stream) which calls : PDFDocumentHandler.startDocument() where it tests accessibility of the attached FOUserAgent. Issue is due to the fact that at the moment calling "B", we couldn't have correctly set "A" so, the logicalStructureHandler of PDFPainter remains null. A solution is to change method FopFactory.setAccessibility() to public, so that we can set accessibility before calling "B".
My mistake, this has already been managed : FOUserAgent fopUserAgent = FopFactory.newFOUserAgent(); fopUserAgent.setAccessbility(true); Fop fop = FopFactory.newFop(String outputFormat, fopUserAgent, OutputStream stream)