Hi Jason ,
I already tried the one you specified (
http://jeuclid.sourceforge.net/ ) , but i could not complete it
here is my code :
public String processEquation(String dirName,Node mathNode)
{
mmlString="";
++imageName;
File fileDir=new File(dirName);
if(!fileDir.exists())
{
fileDir.mkdirs();
}
String imgFile=fileDir.getAbsolutePath()+File.separator+"eqn"+imageName+".png";
String mmlFile=fileDir.getAbsolutePath()+File.separator+"eqn"+imageName+".mml";
File imgF = new File(imgFile);
try {
Transformer transformer = tFactory.newTransformer(new javax.xml.transform.stream.StreamSource("home/anbu/omml2mml.xsl"));
DOMSource ds=new DOMSource(mathNode);
StringWriter writer = new StringWriter();
StreamResult sr = new StreamResult(writer);
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
transformer.setOutputProperty(OutputKeys.METHOD, "xml");
//convert ooml to mathml
transformer.transform(ds,sr);
mmlString=writer.toString();
mml2PNG(mmlFile,mmlString,imgFile);
} catch (Exception e)
{
e.printStackTrace( );
}
return imgF.getName();
}
public void mml2PNG(String mmlFile, String mml,String imgFile)
{
try
{
System.out.println("MathProperty :"+mathPropHash);
formFileFromArray(mml.getBytes("UTF-16"),mmlFile);
//calling jeuclid here.
ArrayList<String> argList=new ArrayList<String>();
argList.add(mmlFile);
argList.add(imgFile);
argList.add("-backgroundColor");
if(mathPropHash.containsKey("backgroundColor"))
{
String colorHash=getColorHash((String)mathPropHash.get("backgroundColor"));
argList.add(colorHash);
}
else
{
argList.add("#FF00FF");
}
argList.add("-foregroundColor");
if(mathPropHash.containsKey("foregroundColor"))
{
String colorHash=getColorHash((String)mathPropHash.get("foregroundColor"));
argList.add(colorHash);
}
else
{
argList.add("#AA00BB");
}
argList.add("-antiAliasMinSize");
argList.add("1");
argList.add("-fontSize");
if(mathPropHash.containsKey("fontSize"))
{
argList.add((String)mathPropHash.get("fontSize"));
}
else
{
argList.add("50");
}
System.out.println("List:::::::::::"+argList);
String[] args=(String[])argList.toArray(new String[argList.size()]);
//System.out.println(Arrays.asList(args));
net.sourceforge.jeuclid.app.Mml2xxx.main(args);
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
just take "omml2mml.xsl" from this link "http://www.tei-c.org/release/xml/tei/stylesheet/docx/utils/maths/omml2mml.xsl" . Hope this link will help us
.
while executin am getting this error :
Error encountered during converion process
java.io.IOException: Bad file descriptor
at java.io.FileInputStream.read(Native Method)
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager$RewindableInputStream.read(XMLEntityManager.java:2622)
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(XMLEntityManager.java:997)
at com.sun.org.apache.xerces.internal.impl.XMLVersionDetector.determineDocVersion(XMLVersionDetector.java:184)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:798)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:250)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:292)
at net.sourceforge.jeuclid.parser.Parser.parseStreamSourceAsXml(Parser.java:318)
at net.sourceforge.jeuclid.parser.Parser.parseStreamSource(Parser.java:249)
at net.sourceforge.jeuclid.MathMLParserSupport.parseFile(MathMLParserSupport.java:123)
at net.sourceforge.jeuclid.converter.Converter.convert(Converter.java:141)
at net.sourceforge.jeuclid.app.Mml2xxx.main(Mml2xxx.java:130)
at com.zohocorp.zwimport.converter.OOML2MML.mml2PNG(OOML2MML.java:179)
at com.zohocorp.zwimport.converter.OOML2MML.processEquation(OOML2MML.java:93)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) .....
Can we able to fix this problem ?
Regards,
AnbuChezhian.S