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());
}
}
```
[ Full content available at: https://github.com/apache/cxf/pull/436 ]
This message was relayed via gitbox.apache.org for [email protected]