【发布时间】:2017-05-29 12:26:13
【问题描述】:
我正在尝试使用 ItextRenderer 将我的 xhtml 代码转换为 pdf,但问题是数学方程式没有很好地转换。我正在使用 mathjax 在所有浏览器中查看方程式:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><script type="text/javascript"src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=MML_HTMLorMML"/>
这是我的html代码:
<math xmlns:xlink="http://www.w3.org/1999/xlink" overflow="scroll">
<msup xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math">
<mrow>
<mfenced separators="|">
<mrow>
<mi>x</mi>
<mo>+</mo>
<mi>a</mi>
</mrow>
</mfenced>
</mrow>
<mrow>
<mi>n</mi>
</mrow>
html pdf 转换器代码是这样的:
OutputStream os = new FileOutputStream("outputPDF.pdf");
ITextRenderer renderer = new ITextRenderer();
String url = new File("inputHtml.html").toURI().toURL().toString();
renderer.setDocument(url);
renderer.layout();
renderer.createPDF(os);
os.close();
问题在于,在 pdf 中,除了方程之外的所有工作。这是 pdf 中的方程 Equation in pdf
有没有办法在 pdf 中应用函数?或者在 Java 中应用其他方式?谢谢!
【问题讨论】:
标签: java html pdf math mathjax