Example to use:
<canvas id="myCanvas" width="0" height="0"></canvas>
<script>
FMATH.ApplicationConfiguration.setFolderUrlForFonts("fonts");
FMATH.ApplicationConfiguration.setFolderUrlForGlyphs("glyphs");
/*
* draw a mathml formula on html5
* id = the canvas element's id
* mathml = the mathml formula to be displayed
*/
function drawFormulaOnCanvas( id, mathml){
var c=document.getElementById(id);
var formula = new FMATH.MathMLFormula();
formula.drawImage(c, mathml);
}
/*
* draw a latex formula on html5
* id = the canvas element's id
* latex = the latex formula to be displayed
*/
function drawLatexFormulaOnCanvas( id, latex){
var c=document.getElementById(id);
if(c==null) return;
var formula = new FMATH.MathMLFormula();
var mathml = formula.convertToMathML(latex)
formula.drawImage(c, mathml);
}
/*
* Generate word document in javascript
* mathml - the mathml
* fileName - the name of generated file
*/
function exportToWord(mathml, fileName){
var formula = new FMATH.MathMLFormula();
formula.downloadWordFromMathML(mathml, fileName);
}
drawFormulaOnCanvas("myCanvas", '<math ><mtext style="border:1px;">FMATH MathML</mtext></math>');
</script>
|