如何将MS Word中的数学方程转换为Java中的图像?
我有一个MS Word 2013文档,其中包含数学公式,我想通过编程将其转换为图像 我尝试的是:如何将MS Word中的数学方程转换为Java中的图像?,java,ms-word,mathml,omml,Java,Ms Word,Mathml,Omml,我有一个MS Word 2013文档,其中包含数学公式,我想通过编程将其转换为图像 我尝试的是: 自Office 2007以来,Microsoft已将数学公式的表示形式更改为Office MathML(OMML)格式 我可以将OMML格式的公式转换为MathML格式。 我的Java代码与此相同: //获取xslt StreamSource xlsStreamSource = new StreamSource("D:/TEMP/OMML2MML.XSL"); //Get the document.
自Office 2007以来,Microsoft已将数学公式的表示形式更改为Office MathML(OMML)格式
StreamSource xlsStreamSource = new StreamSource("D:/TEMP/OMML2MML.XSL");
//Get the document.xml from .docx file
StreamSource xmlStreamSource = new StreamSource("D:/TEMP/word/document.xml");
//Using xalan transformer factory.
TransformerFactory transformerFactory = TransformerFactory.newInstance("org.apache.xalan.processor.TransformerFactoryImpl", null);
File pathToHTMLFile = new File("D:/TEMP/Newfolder/word/documentModified.xml");
StreamResult result = new StreamResult(pathToHTMLFile);
Transformer transformer = transformerFactory.newTransformer(xlsStreamSource);
transformer.transform(xmlStreamSource, result);
/**
* Write to Clipboard.
* @param s string containing MathML representation
* @param owner
*/
public static void writeToClipboard(String s, ClipboardOwner owner)
{
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
Transferable transferable = new StringSelection(s);
clipboard.setContents(transferable, owner);
}
/**
* Read clipboard data as image
* @return Image
* @throws Exception
*/
public static Image getImageFromClipboard() throws Exception
{
Transferable transferable = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null);
if (transferable != null&& transferable.isDataFlavorSupported(DataFlavor.imageFlavor)) {
return (Image) transferable.getTransferData(DataFlavor.imageFlavor);
} else {
return null;
}
}
我想将MathML(XML)写入剪贴板,这样我就可以从中读取图像味道。
我如何将这个MathML公式格式写入剪贴板,这样我就可以从中获得图像的味道
注:我不确定我的方向是否正确。如果
有任何现有的API可用于相同的,这将是更多
更容易做到这一点
请参阅更新的问题。实际上,我尝试使用JavaFX实现此转换,但未能成功。嗨,专家们,有什么答案吗?可能重复的不是重复的。在这里,我想将数学方程(OMathML格式)转换为图像。请参考更新的问题。事实上,我试图用JavaFX实现这个转换,但我没有成功。嗨,专家们,有什么答案吗?这可能是重复的,但不是重复的。在这里,我想把数学方程(OMathML格式)转换成图像。