slavb18 commented on issue #436: introduce getStreamResult URL: https://github.com/apache/cxf/pull/436#issuecomment-414925153 example pdf provider based on XSLTJaxbProvider ```java @Produces({"application/xml", "application/*+xml", "text/xml", "text/html","application/pdf" }) @Consumes({"application/xml", "application/*+xml", "text/xml", "text/html" }) @Provider public class XSLTJaxbPDFProvider<T> extends XSLTJaxbProvider<T> { protected FopFactory fopFactory = null; MediaType pdfMediaType = MediaType.valueOf("application/pdf"); @Override protected Templates createTemplates(URL urlStream) { Templates templates = super.createTemplates(urlStream); if (fopFactory==null) { try { fopFactory = FopFactory.newInstance(getClass().getResource("/fop").toURI(),getClass().getResourceAsStream("/fop/fopconf.xml")); } catch (IOException | URISyntaxException | SAXException ex) { throw new RuntimeException(ex); } } return templates; } @Override protected Result getStreamResult(OutputStream os, Annotation[] anns, MediaType mt) throws Exception { return mt.isCompatible(pdfMediaType) ? getStreamResultPdf(os, anns, mt) : super.getStreamResult(os, anns, mt); } protected Result getStreamResultPdf(OutputStream os, Annotation[] anns, MediaType mt) throws FOPException { FOUserAgent userAgent = fopFactory.newFOUserAgent(); Fop fop = fopFactory.newFop("application/pdf", userAgent, os); return new SAXResult(fop.getDefaultHandler()); } } ```
---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
