我正在尝试使用fo:external-graphic-tag将照片添加到我的pdf文件中:
<fo:external-graphic src="url(resources\common\img\Logo_tiny.png)" />
在我的本地系统上,每个工作都很好,但是当我想在服务器系统上运行时,它会说
Image not found. URI: resources\common\img\Logo_tiny.png. (No context info available)
我的Fop-Factory-Setup看起来像这样:
fopFactory.setUserConfig(config);
fopFactory.getFontManager().setFontBaseURL(servletContext.getRealPath("/WEB-INF/config/"));
Fop fop = fopFactory.newFop(org.apache.xmlgraphics.util.MimeConstants.MIME_PDF, userAgent, outStream);
Transformer transformer = TransformerFactory.newInstance().newTransformer(transformSource);
Result res = new SAXResult(fop.getDefaultHandler());
transformer.transform(source, res);
// get the pdf:
response.setContentType("application/pdf");
response.setHeader("Content-Disposition", "attachment; filename=\"Output.pdf\"");
response.setContentLength(outStream.size());
OutputStream responseOutputStream = response.getOutputStream();
outStream.writeTo(responseOutputStream);
responseOutputStream.flush();
responseOutputStream.close();
context.responseComplete();
我检查了几次:图像在jar文件中可用,它可以在ear-file中找到。该图片也用于不同的上下文中,并显示出来。
是否有人对此问题有提示或解决方案? 非常感谢!!