繁体   English   中英

我可以使用 Apache fop XSL-FO 向 pdf 添加时间戳吗

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM