我已经将FOP版本从fop 1.1升级到了fop 2.3版本
org.apache.fop.events.LoggingEventListener processEvent图像未找到。
下面是为升级而修改的代码段。 使用FOP 2.3的Master View代码
代码:
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer();
FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
//foUserAgent.setURIResolver( this.getURIResolver() );
transformer.setURIResolver(this.getURIResolver());
Fop fop = null;
Source src = new StreamSource(new ByteArrayInputStream(foDoc));
if (this.getContentType().equals("application/pdf"))
{
fop = fopFactory.newFop(MimeConstants.MIME_PDF, foUserAgent, os);
}
else if (this.getContentType().equals("application/postscript"))
{
fop = fopFactory.newFop(MimeConstants.MIME_POSTSCRIPT, foUserAgent, os);
}
查看fop 2.3的代码
protected static final FopFactory fopFactory = FopFactory.newInstance(new File(".").toURI(), resolver);
XSLT代码
<fo:external-graphic src = "stylesheets/Anthem_Join_In.bmp"/>
答案 0 :(得分:1)
Resolver的API已更改,并且记录不充分。此代码在JSF webApp中对我有效(fop 2.3)。
files:
"/etc/nginx/conf.d/proxy.conf" :
mode: "000644"
owner: root
group: root
content: |
server{
if ($http_x_forwarded_proto = "http") {
return 301 https://$host$request_uri;
}
}
项目中的其余先前代码保持不变。我没有使用Transformer.setURIResolver(...)
xml fop代码如下:
final ServletContext sc = (ServletContext) FacesContext.getCurrentInstance().getExternalContext().getContext();
// Create ServletContext resource Resolver
ResourceResolver resolver = new ResourceResolver() {
@Override
public Resource getResource(URI uri) throws IOException {
return new Resource(sc.getResourceAsStream(uri.toASCIIString()));
}
@Override
public OutputStream getOutputStream(URI uri) throws IOException {
URL url = sc.getResource(uri.toASCIIString());
return url.openConnection().getOutputStream();
}
};
// Buid the factory
FopFactoryBuilder builder = new FopFactoryBuilder(new URI(sc.getContextPath()), resolver);
FopFactory FOP_FACTORY = builder.build();