Search in sources :

Example 1 with WebPageOutputOptions

use of uk.ac.ed.ph.snuggletex.WebPageOutputOptions in project xwiki-platform by xwiki.

the class SnuggleTexFormulaRenderer method renderImage.

@Override
protected ImageData renderImage(String formula, boolean inline, FormulaRenderer.FontSize size, FormulaRenderer.Type type) throws IllegalArgumentException, IOException {
    SnuggleSession session = this.engine.createSession();
    SnuggleInput input = new SnuggleInput(wrapFormula(formula, inline));
    session.parseInput(input);
    ByteArrayOutputStream output = new ByteArrayOutputStream();
    CustomMathMLImageSavingCallback callback = new CustomMathMLImageSavingCallback(output, size.getSize());
    WebPageOutputOptions options = JEuclidUtilities.createWebPageOptions(false, callback);
    session.writeWebPage(options, new NullOutputStream());
    return new ImageData(output.toByteArray(), type);
}
Also used : SnuggleInput(uk.ac.ed.ph.snuggletex.SnuggleInput) ImageData(org.xwiki.formula.ImageData) SnuggleSession(uk.ac.ed.ph.snuggletex.SnuggleSession) WebPageOutputOptions(uk.ac.ed.ph.snuggletex.WebPageOutputOptions) ByteArrayOutputStream(org.apache.commons.io.output.ByteArrayOutputStream) NullOutputStream(org.apache.commons.io.output.NullOutputStream)

Aggregations

ByteArrayOutputStream (org.apache.commons.io.output.ByteArrayOutputStream)1 NullOutputStream (org.apache.commons.io.output.NullOutputStream)1 ImageData (org.xwiki.formula.ImageData)1 SnuggleInput (uk.ac.ed.ph.snuggletex.SnuggleInput)1 SnuggleSession (uk.ac.ed.ph.snuggletex.SnuggleSession)1 WebPageOutputOptions (uk.ac.ed.ph.snuggletex.WebPageOutputOptions)1