Hello,
I’m back with a problem we have for a long time. Images are not always very clean and especialy when formulas are translated as pictures.
I’ve read somewhere that it’s possible to plug another image library to have better results. Would that solve my issue ?
We tried to set the ImageResolution to 300 but then another problem occured. Every images become very huge in size.
Could you please help me ? What is the best solution to have clean formulas ? Can we translate them as vectorial images ? I already tried to plug another image library but it didn’t work.
I’m using java and maven. Could you tell me what dependency and what I must configure to use the best library you know of ? We are not eligible to GNU GPL problems.
@rodrigue.leopold Could you please attach your input and problematic output documents along with code that will allow us to reproduce the problem? We will check the issue and provide you more information.
Here is my code. As you will see, I’m not doing anything special. The images are not as clean as the text. My goal is that there is no difference between the text and the images. Crystal clear images
resources.zip (36.7 KB)
@rodrigue.leopold Thank you for additional information. We will consider adding an option to export OfficeMath
as SVG. The feature request is logged as WORDSNET-23802. We will keep you informed and let you know once it is resolved.
Currently you can export OfficeMath
as MathML:
Document doc = new Document("C:\\Temp\\in.docm");
HtmlSaveOptions saveOptions = new HtmlSaveOptions(SaveFormat.HTML);
saveOptions.setOfficeMathOutputMode(HtmlOfficeMathOutputMode.MATH_ML);
doc.save("C:\\Temp\\out.html", saveOptions);
1 Like
OK. Thanks. Will I be allowed to use the version with this feature ? Will you do it before the end of the year ?
@rodrigue.leopold Unfortunately, currently there is no estimate for this feature. We will keep you updated and let you know once it is available.
For now, you can convert office math nodes in your document to EMF metafiles and then use SVG as metafile format while saving document to HTML:
Document doc = new Document("C:\\Temp\\in.docm");
DocumentBuilder builder = new DocumentBuilder(doc);
for (OfficeMath m : (Iterable<OfficeMath>)doc.getChildNodes(NodeType.OFFICE_MATH, true))
{
// process only top level OfficeMath.
if (m.getAncestor(NodeType.OFFICE_MATH) == null)
{
// Save office math as EMF metafile.
ByteArrayOutputStream tmpStream = new ByteArrayOutputStream();
m.getMathRenderer().save(tmpStream, new ImageSaveOptions(SaveFormat.EMF));
builder.moveTo(m);
builder.insertImage(new ByteArrayInputStream(tmpStream.toByteArray()));
m.remove();
}
}
HtmlSaveOptions opt = new HtmlSaveOptions();
opt.setMetafileFormat(HtmlMetafileFormat.SVG);
doc.save("C:\\Temp\\out.html", opt);
In this case OfficeMath
nodes will be exported to HTML as SVG vector images.
out.zip (3.3 KB)
1 Like