[英]Using JEuclid to generate formula in PDF(XSL-FO)
我正在嘗試將xml轉換為包含公式的pdf。 我已經添加了果醬罐來處理配方奶。 除公式外,整個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();
}
}
}
編輯:根據要求添加控制台日志
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。 (沒有可用的上下文信息)2019年3月18日12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent SEVERE:找不到圖像。 URI:../ Logo / Separator.jpg。 (沒有可用的上下文信息)2019年3月18日12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent SEVERE:找不到圖像。 URI:../ IPTC-19048-MS_fig_01.tif。 (沒有可用的上下文信息)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。 (沒有可用的上下文信息)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。 (沒有可用的上下文信息)2019年3月18日12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent SEVERE:找不到圖像。 URI:../ IPTC-19048-MS_fig_04.tif。 (沒有可用的上下文信息)2019年3月18日12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent SEVERE:找不到圖像。 URI:../ IPTC-19048-MS_fig_05.tif。 (沒有可用的上下文信息)2019年3月18日12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent SEVERE:找不到圖像。 URI:../ IPTC-19048-MS_fig_06.tif。 (沒有可用的上下文信息)2019年3月18日12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent SEVERE:找不到圖像。 URI:../ IPTC-19048-MS_fig_07.tif。 (沒有可用的上下文信息)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。 (沒有可用的上下文信息)2019年3月18日12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent SEVERE:找不到圖像。 URI:../ IPTC-19048-MS_fig_09.tif。 (沒有可用的上下文信息)2019年3月18日12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent SEVERE:找不到圖像。 URI:../ IPTC-19048-MS_fig_10.tif。 (沒有可用的上下文信息)2019年3月18日12:58:52 org.apache.fop.events.LoggingEventListener processEvent警告:找不到字體“ Arial,normal,700”。 替換為“ any,normal,700”。 Mar 18,2019 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent警告:找不到字體“ Symbol,normal,700”。 替換為“ Symbol,normal,400”。 Mar 18,2019 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent INFO:一個fo:block(沒有可用的上下文信息)的寬度大於inline-progression-dimension中的可用空間。 根據過度約束的幾何規則調整最終縮進(XSL 1.1,ch.5.3.4)Mar 18,2019 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent警告:fo:block第1行的內容已超出沿行進方向的可用區域減少了5880毫點。 (無可用的上下文信息)2019年3月18日12:58:52 org.apache.fop.events.LoggingEventListener processEvent INFO:一個fo:block(無可用的上下文信息)的寬度大於inline-progression-dimension中的可用空間。 根據過度約束的幾何規則調整最終縮進(XSL 1.1,ch.5.3.4)Mar 18,2019 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent警告:fo:block第1行的內容已超出沿行進方向的可用區域減少了5880毫點。 (無可用的上下文信息)2019年3月18日12:58:52 org.apache.fop.events.LoggingEventListener processEvent INFO:一個fo:block(無可用的上下文信息)的寬度大於inline-progression-dimension中的可用空間。 根據過度約束的幾何規則調整最終縮進(XSL 1.1,ch.5.3.4)Mar 18,2019 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent警告:fo:block第1行的內容已超出沿行進方向的可用區域減少了5880毫點。 (無可用的上下文信息)2019年3月18日12:58:52 org.apache.fop.events.LoggingEventListener processEvent INFO:一個fo:block(無可用的上下文信息)的寬度大於inline-progression-dimension中的可用空間。 根據過度約束的幾何規則調整最終縮進(XSL 1.1,ch.5.3.4)Mar 18,2019 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent警告:fo:block第1行的內容已超出沿行進方向的可用區域減少了5880毫點。 (無可用的上下文信息)2019年3月18日12:58:52 org.apache.fop.events.LoggingEventListener processEvent INFO:一個fo:block(無可用的上下文信息)的寬度大於inline-progression-dimension中的可用空間。 根據過度約束的幾何規則調整最終縮進(XSL 1.1,ch.5.3.4)Mar 18,2019 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent警告:fo:block第1行的內容已超出沿行進方向的可用區域減少了5880毫點。 (無可用的上下文信息)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:呈現的頁面#2。 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:呈現的頁面#4。 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:呈現的頁面#6。 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:呈現的頁面#8。 Mar 18,2019 12:58:53 PM 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">
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.