Hello,
I use Aspose.TeX to create an SVG from a TeX formula. If I now create this SVG and then read it in again and write it again, the SVG breaks.
SvgMathRendererOptions options = new SvgMathRendererOptions();
options.setPreamble("\\usepackage{amsmath}\n"
+ "\\usepackage{amsfonts}\n"
+ "\\usepackage{amssymb}\n"
+ "\\usepackage{color}");
options.setScale(10000);
options.setTextColor(java.awt.Color.BLACK);
options.setBackgroundColor(java.awt.Color.WHITE);
options.setLogStream(new FileOutputStream("simple-math-rendering.log"));
options.showTerminal(true);
com.aspose.tex.Size2D size = new com.aspose.tex.Size2D.Float();
final ByteArrayOutputStream stream = new ByteArrayOutputStream();
SvgMathRenderer mathRenderer = new SvgMathRenderer();
mathRenderer.render("$\int_{a}^{b}x dx$", stream, options, size);
try(OutputStream fileOutputStream = new FileOutputStream("simple-math-rendering_1.svg")) {
stream.writeTo(fileOutputStream );
}
try (Image image = SvgImage.load(new ByteArrayInputStream(stream.toByteArray()))) {
image.save(new FileOutputStream("simple-math-rendering_2.svg"));
} catch (Exception exc) {
LOGGER.error("svg conversion failed", exc);
}
My goal is to pack the TeX formula in a PDF, but I can’t do it because the SVG is “broken” after reading it.
simple-math-rendering.zip (63.0 KB)