我试图将xml转换为包含公式的pdf。我添加了jeuclid罐子来处理配方奶粉。除公式外,整个xml被正确转换。在有公式的地方,我变得空白。
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();
}
}
}
编辑:根据要求添加控制台日志
org.apache.fop.events.LoggingEventListener processEvent警告:Apache FOP尚未实现以下功能:table-layout =“auto”(在fo:table上)(否) org.apache.fop.events.LoggingEventListener processEvent警告:Apache FOP没有实现以下功能:table-layout =“auto”(在fo:表)(没有上下文信息)2010年3月18日12:58:52 org.apache.fop.events.LoggingEventListener processEvent SEVERE:找不到图像。 URI:../ LOGo / IPTC_Logo.tif。 (没有上下文信息)2019年3月18日下午12:58:52 org.apache.fop.events.LoggingEventListener processEvent SEVERE:找不到图像。 URI:../ Logo / Separator.jpg。 (没有上下文信息)2019年3月18日下午12:58:52 org.apache.fop.events.LoggingEventListener processEvent SEVERE:找不到图像。 URI:../ IPTC-19048-MS_fig_01.tif。 (没有上下文信息)2010年3月18日12:58:52 org.apache.fop.events.LoggingEventListener processEvent警告:Apache FOP尚未实现以下功能:table-layout =“auto”(on fo:table)(无上下文信息)2010年3月18日12:58:52 org.apache.fop.events.LoggingEventListener processEvent警告:Apache FOP尚未实现以下功能:table-layout =“ auto“(在fo:table上)(没有上下文信息)Mar 18,20199 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent SEVERE:找不到图像。 URI:../ IPTC-19048-MS_fig_02.tif。 (没有上下文信息)2010年3月18日12:58:52 org.apache.fop.events.LoggingEventListener processEvent警告:Apache FOP尚未实现以下功能:table-layout =“auto”(on fo:table)(无上下文信息)Mar 18,20199 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent SEVERE:找不到图像。 URI:../ IPTC-19048-MS_fig_03.tif。 (没有上下文信息)2019年3月18日下午12:58:52 org.apache.fop.events.LoggingEventListener processEvent SEVERE:找不到图像。 URI:../ IPTC-19048-MS_fig_04.tif。 (没有上下文信息)2019年3月18日下午12:58:52 org.apache.fop.events.LoggingEventListener processEvent SEVERE:找不到图像。 URI:../ IPTC-19048-MS_fig_05.tif。 (没有上下文信息)2019年3月18日下午12:58:52 org.apache.fop.events.LoggingEventListener processEvent SEVERE:找不到图像。 URI:../ IPTC-19048-MS_fig_06.tif。 (没有上下文信息)2019年3月18日下午12:58:52 org.apache.fop.events.LoggingEventListener processEvent SEVERE:找不到图像。 URI:../ IPTC-19048-MS_fig_07.tif。 (没有上下文信息)2010年3月18日12:58:52 org.apache.fop.events.LoggingEventListener processEvent警告:Apache FOP尚未实现以下功能:table-layout =“auto”(on fo:table)(无上下文信息)2010年3月18日12:58:52 org.apache.fop.events.LoggingEventListener processEvent警告:Apache FOP尚未实现以下功能:table-layout =“ auto“(在fo:table上)(没有上下文信息)Mar 18,20199 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent SEVERE:找不到图像。 URI:../ IPTC-19048-MS_fig_08.tif。 (没有上下文信息)2019年3月18日下午12:58:52 org.apache.fop.events.LoggingEventListener processEvent SEVERE:找不到图像。 URI:../ IPTC-19048-MS_fig_09.tif。 (没有上下文信息)2019年3月18日下午12:58:52 org.apache.fop.events.LoggingEventListener processEvent SEVERE:找不到图像。 URI:../ IPTC-19048-MS_fig_10.tif。 (没有上下文信息)2010年3月18日12:58:52 org.apache.fop.events.LoggingEventListener processEvent警告:找不到字体“Arial,normal,700”。用“any,normal,700”代替。 2019年3月18日下午12:58:52 org.apache.fop.events.LoggingEventListener processEvent警告:未找到字体“Symbol,normal,700”。用“符号,正常,400”代替。 org.apache.fop.events.LoggingEventListener processEvent INFO:fo:block(没有可用的上下文信息)比inline-progression-dimension中的可用空间宽。根据过度约束的几何规则调整end-indent(XSL 1.1,ch.5.3.4)org.apache.fop.events.LoggingEventListener processEvent警告:fo:block line 1的内容超出直线前进方向的可用面积为5880毫升。 (没有上下文信息)2010年3月18日12:58:52 org.apache.fop.events.LoggingEventListener processEvent INFO:fo:block(没有可用的上下文信息)比inline-progression-dimension中的可用空间宽。根据过度约束的几何规则调整end-indent(XSL 1.1,ch.5.3.4)org.apache.fop.events.LoggingEventListener processEvent警告:fo:block line 1的内容超出直线前进方向的可用面积为5880毫升。 (没有上下文信息)2010年3月18日12:58:52 org.apache.fop.events.LoggingEventListener processEvent INFO:fo:block(没有可用的上下文信息)比inline-progression-dimension中的可用空间宽。根据过度约束的几何规则调整end-indent(XSL 1.1,ch.5.3.4)org.apache.fop.events.LoggingEventListener processEvent警告:fo:block line 1的内容超出直线前进方向的可用面积为5880毫升。 (没有上下文信息)2010年3月18日12:58:52 org.apache.fop.events.LoggingEventListener processEvent INFO:fo:block(没有可用的上下文信息)比inline-progression-dimension中的可用空间宽。根据过度约束的几何规则调整end-indent(XSL 1.1,ch.5.3.4)org.apache.fop.events.LoggingEventListener processEvent警告:fo:block line 1的内容超出直线前进方向的可用面积为5880毫升。 (没有上下文信息)2010年3月18日12:58:52 org.apache.fop.events.LoggingEventListener processEvent INFO:fo:block(没有可用的上下文信息)比inline-progression-dimension中的可用空间宽。根据过度约束的几何规则调整end-indent(XSL 1.1,ch.5.3.4)org.apache.fop.events.LoggingEventListener processEvent警告:fo:block line 1的内容超出直线前进方向的可用面积为5880毫升。 (没有上下文信息)2019年3月18日下午12:58:53 org.apache.fop.events.LoggingEventListener processEvent INFO:呈现页面#1。 2019年3月18日下午12:58:53 org.apache.fop.events.LoggingEventListener processEvent INFO:呈现的页面#2。 2019年3月18日下午12:58:53 org.apache.fop.events.LoggingEventListener processEvent INFO:呈现页面#3。 2019年3月18日下午12:58:53 org.apache.fop.events.LoggingEventListener processEvent INFO:渲染页面#4。 2019年3月18日下午12:58:53 org.apache.fop.events.LoggingEventListener processEvent INFO:呈现的页面#5。 2019年3月18日下午12:58:53 org.apache.fop.events.LoggingEventListener processEvent INFO:渲染页面#6。 2019年3月18日下午12:58:53 org.apache.fop.events.LoggingEventListener processEvent INFO:呈现的页面#7。 2019年3月18日下午12:58:53 org.apache.fop.events.LoggingEventListener processEvent INFO:呈现的页面#8。 2019年3月18日下午12:58:53 org.apache.fop.events.LoggingEventListener processEvent INFO:渲染页面#9。
当我读到JEuclid处理它时,我没有在我的xsl中为公式编写任何内容。
你的fo:root标签上有mathml命名空间吗?像这样:
<fo:root xmlns: fo="http://www.w3.org/1999/XSL/Format" xmlns:mathml="http://www.w3.org/1998/Math/MathML">