[英]Can I add time stamp to pdf using Apache fop XSL-FO
有沒有辦法使用apache fop為pdf添加時間戳。
我正在生成這樣的pdf:
final File xsltFile = new File("D:\\test.xsl");
final StreamSource xmlSource = new StreamSource(new File("D:\\test.xml"));
final FopFactory fopFactory = FopFactory.newInstance(new File(".").toURI());
final FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
final OutputStream out = new java.io.FileOutputStream("D:\\test.pdf");
try {
final Fop fop = fopFactory.newFop(org.apache.xmlgraphics.util.MimeConstants.MIME_PDF, foUserAgent, out);
final TransformerFactory factory = TransformerFactory.newInstance();
final Transformer transformer = factory.newTransformer(new StreamSource(xsltFile));
final Result res = new SAXResult(fop.getDefaultHandler());
transformer.transform(xmlSource, res);
} finally {
out.close();
}
這有幫助嗎?
final FOUserAgent foUserAgent = FOP_FACTORY.newFOUserAgent();
/**/ foUserAgent.setProducer ("Pro Ducer");
/**/ foUserAgent.setCreationDate (new Date());
/**/ foUserAgent.setTargetResolution(300 /* dpi */);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.