简体   繁体   English

使用JEuclid在PDF(XSL-FO)中生成公式

[英]Using JEuclid to generate formula in PDF(XSL-FO)

I am trying to transform an xml to pdf which contains formulas. 我正在尝试将xml转换为包含公式的pdf。 I have added jeuclid jars to handle formula. 我已经添加了果酱罐来处理配方奶。 Whole xml is transformed properly except the formulas. 除公式外,整个xml均已正确转换。 I am getting blank where there are formulas. 有公式的地方我变得空白。

public class PDFCreation {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        PDFCreation pdfCreation = new PDFCreation();
        try {
            pdfCreation.convertToPDF("SPE.xsl", "IPTC-19048-MS.xml", "IPTC-19048-MS.pdf");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void convertToPDF(String xsl, String xml, String pdf) throws IOException, FOPException, TransformerException {
        File xsltFile = new File(xsl);
        StreamSource xmlSource = new StreamSource(new File(xml));
        FopFactory fopFactory = FopFactory.newInstance(new File(".").toURI());
        FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
        OutputStream out;
        out = new java.io.FileOutputStream(pdf);
        try {
            Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, foUserAgent, out);
            TransformerFactory factory = TransformerFactory.newInstance();
            Transformer transformer = factory.newTransformer(new StreamSource(xsltFile));
            Result res = new SAXResult(fop.getDefaultHandler());
            transformer.transform(xmlSource, res);
        } finally {
            out.close();
        }
    }
}

EDIT: As requested adding console log 编辑:根据要求添加控制台日志

Mar 18, 2019 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent WARNING: The following feature isn't implemented by Apache FOP, yet: table-layout="auto" (on fo:table) (No context info available) Mar 18, 2019 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent WARNING: The following feature isn't implemented by Apache FOP, yet: table-layout="auto" (on fo:table) (No context info available) Mar 18, 2019 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent SEVERE: Image not found. Mar 18,2019 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent警告:Apache FOP尚未实现以下功能:table-layout =“ auto”(在fo:table上)(否上下文信息可用)Mar 18,2019 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent警告:Apache FOP尚未实现以下功能:table-layout =“ auto”(在fo上:表)(无可用的上下文信息)2019年3月18日12:58:52 org.apache.fop.events.LoggingEventListener processEvent SEVERE:找不到图像。 URI: ../Logo/IPTC_Logo.tif. URI:../ Logo / IPTC_Logo.tif。 (No context info available) Mar 18, 2019 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent SEVERE: Image not found. (没有可用的上下文信息)2019年3月18日12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent SEVERE:找不到图像。 URI: ../Logo/Separator.jpg. URI:../ Logo / Separator.jpg。 (No context info available) Mar 18, 2019 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent SEVERE: Image not found. (没有可用的上下文信息)2019年3月18日12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent SEVERE:找不到图像。 URI: ../IPTC-19048-MS_fig_01.tif. URI:../ IPTC-19048-MS_fig_01.tif。 (No context info available) Mar 18, 2019 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent WARNING: The following feature isn't implemented by Apache FOP, yet: table-layout="auto" (on fo:table) (No context info available) Mar 18, 2019 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent WARNING: The following feature isn't implemented by Apache FOP, yet: table-layout="auto" (on fo:table) (No context info available) Mar 18, 2019 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent SEVERE: Image not found. (没有可用的上下文信息)2019年3月18日12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent警告:Apache FOP尚未实现以下功能:table-layout =“ auto”(on fo:table)(无上下文信息可用)Mar 18,2019 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent警告:Apache FOP尚未实现以下功能:table-layout =“ auto”(在fo:table上)(无上下文信息可用)Mar 18,2019 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent SEVERE:找不到图像。 URI: ../IPTC-19048-MS_fig_02.tif. URI:../ IPTC-19048-MS_fig_02.tif。 (No context info available) Mar 18, 2019 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent WARNING: The following feature isn't implemented by Apache FOP, yet: table-layout="auto" (on fo:table) (No context info available) Mar 18, 2019 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent SEVERE: Image not found. (没有可用的上下文信息)2019年3月18日12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent警告:Apache FOP尚未实现以下功能:table-layout =“ auto”(on fo:table)(无上下文信息可用)Mar 18,2019 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent SEVERE:找不到图像。 URI: ../IPTC-19048-MS_fig_03.tif. URI:../ IPTC-19048-MS_fig_03.tif。 (No context info available) Mar 18, 2019 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent SEVERE: Image not found. (没有可用的上下文信息)2019年3月18日12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent SEVERE:找不到图像。 URI: ../IPTC-19048-MS_fig_04.tif. URI:../ IPTC-19048-MS_fig_04.tif。 (No context info available) Mar 18, 2019 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent SEVERE: Image not found. (没有可用的上下文信息)2019年3月18日12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent SEVERE:找不到图像。 URI: ../IPTC-19048-MS_fig_05.tif. URI:../ IPTC-19048-MS_fig_05.tif。 (No context info available) Mar 18, 2019 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent SEVERE: Image not found. (没有可用的上下文信息)2019年3月18日12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent SEVERE:找不到图像。 URI: ../IPTC-19048-MS_fig_06.tif. URI:../ IPTC-19048-MS_fig_06.tif。 (No context info available) Mar 18, 2019 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent SEVERE: Image not found. (没有可用的上下文信息)2019年3月18日12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent SEVERE:找不到图像。 URI: ../IPTC-19048-MS_fig_07.tif. URI:../ IPTC-19048-MS_fig_07.tif。 (No context info available) Mar 18, 2019 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent WARNING: The following feature isn't implemented by Apache FOP, yet: table-layout="auto" (on fo:table) (No context info available) Mar 18, 2019 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent WARNING: The following feature isn't implemented by Apache FOP, yet: table-layout="auto" (on fo:table) (No context info available) Mar 18, 2019 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent SEVERE: Image not found. (没有可用的上下文信息)2019年3月18日12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent警告:Apache FOP尚未实现以下功能:table-layout =“ auto”(on fo:table)(无上下文信息可用)Mar 18,2019 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent警告:Apache FOP尚未实现以下功能:table-layout =“ auto”(在fo:table上)(无上下文信息可用)Mar 18,2019 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent SEVERE:找不到图像。 URI: ../IPTC-19048-MS_fig_08.tif. URI:../ IPTC-19048-MS_fig_08.tif。 (No context info available) Mar 18, 2019 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent SEVERE: Image not found. (没有可用的上下文信息)2019年3月18日12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent SEVERE:找不到图像。 URI: ../IPTC-19048-MS_fig_09.tif. URI:../ IPTC-19048-MS_fig_09.tif。 (No context info available) Mar 18, 2019 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent SEVERE: Image not found. (没有可用的上下文信息)2019年3月18日12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent SEVERE:找不到图像。 URI: ../IPTC-19048-MS_fig_10.tif. URI:../ IPTC-19048-MS_fig_10.tif。 (No context info available) Mar 18, 2019 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent WARNING: Font "Arial,normal,700" not found. (没有可用的上下文信息)2019年3月18日12:58:52 org.apache.fop.events.LoggingEventListener processEvent警告:找不到字体“ Arial,normal,700”。 Substituting with "any,normal,700". 替换为“ any,normal,700”。 Mar 18, 2019 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent WARNING: Font "Symbol,normal,700" not found. Mar 18,2019 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent警告:找不到字体“ Symbol,normal,700”。 Substituting with "Symbol,normal,400". 替换为“ Symbol,normal,400”。 Mar 18, 2019 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent INFO: An fo:block (No context info available) is wider than the available room in inline-progression-dimension. Mar 18,2019 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent INFO:一个fo:block(没有可用的上下文信息)的宽度大于inline-progression-dimension中的可用空间。 Adjusting end-indent based on overconstrained geometry rules (XSL 1.1, ch. 5.3.4) Mar 18, 2019 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent WARNING: The contents of fo:block line 1 exceed the available area in the inline-progression direction by 5880 millipoints. 根据过度约束的几何规则调整最终缩进(XSL 1.1,ch.5.3.4)Mar 18,2019 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent警告:fo:block第1行的内容已超出沿行进方向的可用区域减少了5880毫点。 (No context info available) Mar 18, 2019 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent INFO: An fo:block (No context info available) is wider than the available room in inline-progression-dimension. (无可用的上下文信息)2019年3月18日12:58:52 org.apache.fop.events.LoggingEventListener processEvent INFO:一个fo:block(无可用的上下文信息)的宽度大于inline-progression-dimension中的可用空间。 Adjusting end-indent based on overconstrained geometry rules (XSL 1.1, ch. 5.3.4) Mar 18, 2019 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent WARNING: The contents of fo:block line 1 exceed the available area in the inline-progression direction by 5880 millipoints. 根据过度约束的几何规则调整最终缩进(XSL 1.1,ch.5.3.4)Mar 18,2019 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent警告:fo:block第1行的内容已超出沿行进方向的可用区域减少了5880毫点。 (No context info available) Mar 18, 2019 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent INFO: An fo:block (No context info available) is wider than the available room in inline-progression-dimension. (无可用的上下文信息)2019年3月18日12:58:52 org.apache.fop.events.LoggingEventListener processEvent INFO:一个fo:block(无可用的上下文信息)的宽度大于inline-progression-dimension中的可用空间。 Adjusting end-indent based on overconstrained geometry rules (XSL 1.1, ch. 5.3.4) Mar 18, 2019 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent WARNING: The contents of fo:block line 1 exceed the available area in the inline-progression direction by 5880 millipoints. 根据过度约束的几何规则调整最终缩进(XSL 1.1,ch.5.3.4)Mar 18,2019 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent警告:fo:block第1行的内容已超出沿行进方向的可用区域减少了5880毫点。 (No context info available) Mar 18, 2019 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent INFO: An fo:block (No context info available) is wider than the available room in inline-progression-dimension. (无可用的上下文信息)2019年3月18日12:58:52 org.apache.fop.events.LoggingEventListener processEvent INFO:一个fo:block(无可用的上下文信息)的宽度大于inline-progression-dimension中的可用空间。 Adjusting end-indent based on overconstrained geometry rules (XSL 1.1, ch. 5.3.4) Mar 18, 2019 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent WARNING: The contents of fo:block line 1 exceed the available area in the inline-progression direction by 5880 millipoints. 根据过度约束的几何规则调整最终缩进(XSL 1.1,ch.5.3.4)Mar 18,2019 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent警告:fo:block第1行的内容已超出沿行进方向的可用区域减少了5880毫点。 (No context info available) Mar 18, 2019 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent INFO: An fo:block (No context info available) is wider than the available room in inline-progression-dimension. (无可用的上下文信息)2019年3月18日12:58:52 org.apache.fop.events.LoggingEventListener processEvent INFO:一个fo:block(无可用的上下文信息)的宽度大于inline-progression-dimension中的可用空间。 Adjusting end-indent based on overconstrained geometry rules (XSL 1.1, ch. 5.3.4) Mar 18, 2019 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent WARNING: The contents of fo:block line 1 exceed the available area in the inline-progression direction by 5880 millipoints. 根据过度约束的几何规则调整最终缩进(XSL 1.1,ch.5.3.4)Mar 18,2019 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent警告:fo:block第1行的内容已超出沿行进方向的可用区域减少了5880毫点。 (No context info available) Mar 18, 2019 12:58:53 PM org.apache.fop.events.LoggingEventListener processEvent INFO: Rendered page #1. (无可用的上下文信息)2019年3月18日12:58:53 PM org.apache.fop.events.LoggingEventListener processEvent INFO:呈现的页面#1。 Mar 18, 2019 12:58:53 PM org.apache.fop.events.LoggingEventListener processEvent INFO: Rendered page #2. Mar 18,2019 12:58:53 PM org.apache.fop.events.LoggingEventListener processEvent INFO:呈现的页面#2。 Mar 18, 2019 12:58:53 PM org.apache.fop.events.LoggingEventListener processEvent INFO: Rendered page #3. Mar 18,2019 12:58:53 PM org.apache.fop.events.LoggingEventListener processEvent INFO:呈现的页面#3。 Mar 18, 2019 12:58:53 PM org.apache.fop.events.LoggingEventListener processEvent INFO: Rendered page #4. Mar 18,2019 12:58:53 PM org.apache.fop.events.LoggingEventListener processEvent INFO:呈现的页面#4。 Mar 18, 2019 12:58:53 PM org.apache.fop.events.LoggingEventListener processEvent INFO: Rendered page #5. Mar 18,2019 12:58:53 PM org.apache.fop.events.LoggingEventListener processEvent INFO:呈现的页面#5。 Mar 18, 2019 12:58:53 PM org.apache.fop.events.LoggingEventListener processEvent INFO: Rendered page #6. Mar 18,2019 12:58:53 PM org.apache.fop.events.LoggingEventListener processEvent INFO:呈现的页面#6。 Mar 18, 2019 12:58:53 PM org.apache.fop.events.LoggingEventListener processEvent INFO: Rendered page #7. Mar 18,2019 12:58:53 PM org.apache.fop.events.LoggingEventListener processEvent INFO:呈现的页面#7。 Mar 18, 2019 12:58:53 PM org.apache.fop.events.LoggingEventListener processEvent INFO: Rendered page #8. Mar 18,2019 12:58:53 PM org.apache.fop.events.LoggingEventListener processEvent INFO:呈现的页面#8。 Mar 18, 2019 12:58:53 PM org.apache.fop.events.LoggingEventListener processEvent INFO: Rendered page #9. Mar 18,2019 12:58:53 PM org.apache.fop.events.LoggingEventListener processEvent INFO:呈现的页面#9。

I have not written anything for formula in my xsl as I read JEuclid handles it. 当我阅读JEuclid处理它时,我还没有在xsl中为公式编写任何内容。

Do you have the mathml namespace on your fo:root tag? fo:root标记上是否有mathml名称空间? Like so: 像这样:

<fo:root xmlns: fo="http://www.w3.org/1999/XSL/Format" xmlns:mathml="http://www.w3.org/1998/Math/MathML">

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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