Hello,
We import SVG-based Charts into a Document via the DocumentBuilder.insertHtml
method (link). We’ve noticed that in some cases, text elements within the SVG are not aligned properly. Specifically, it seems the ‘dominant-baseline
’ attribute is being ignored.
For example, if you render the attached svg_chart.html file in any major Browser, you should see that all the text elements (Chart Title and Legend) align properly. But when the same HTML file is imported into a Word document, the text elements are shifted upwards - as shown in the attached svg_chart_Aspose.docx document. Specifically, it seems the following attribute is being ignored by Words: dominant-baseline="text-before-edge"
This can be reproduced using the latest Aspose Words for Java version 20.1, the attached svg_chart.html
file and the following code:
final String htmlSrc = [PATH] +"svg_chart.html";
// create new blank document
Document wdDoc = new Document();
DocumentBuilder builder = new DocumentBuilder(wdDoc);
// add a new paragraph to the end of the doc
Paragraph para = new Paragraph(wdDoc);
wdDoc.getLastSection().getBody().appendChild(para);
builder.moveTo(para);
// load & insert the HTML into the doc - keep HTML formatting intact
String html = new String(Files.readAllBytes(Paths.get(htmlSrc)), "UTF-8");
builder.insertHtml(html, false);
final String newDoc = htmlSrc.replace(".html", "_Aspose.docx");
Files.deleteIfExists(Paths.get(newDoc));
wdDoc.save(newDoc);
System.out.println("Saved Document: " + newDoc);
Environment information:
- Aspose Words for Java version 20.1
- Java Version 1.8.0_77
- OS: Windows 10
Thank you.