It seems that advanced text effects (used for WordArt or as standalone effects) are not reproduced when converting DOCX documents to HTML.
When converting DOCX documents to HTML, advanced text effects such as shadow, outline, reflection, glow, and 3D effects may not be preserved. To manage how these effects are rendered during the conversion process, you can utilize the HtmlSaveOptions
class in Aspose.Words.
Here are some key properties you can set in HtmlSaveOptions
to control the rendering of text effects:
-
DmlEffectsRenderingMode: This property allows you to specify how DrawingML effects are rendered. You can choose from options like
DmlEffectsRenderingMode.None
,DmlEffectsRenderingMode.Simplified
, orDmlEffectsRenderingMode.Fine
to control the level of detail in the rendering of effects. -
Dml3DEffectsRenderingMode: Similar to the above, this property determines how 3D effects are rendered. You can set it to
Dml3DEffectsRenderingMode.Basic
orDml3DEffectsRenderingMode.Advanced
based on your requirements. -
ExportShapesAsSvg: If you want to export shapes as SVG images instead of raster images, you can set this property to true. This can help maintain the quality of shapes during the conversion.
-
ExportFontsAsBase64: If you want to embed fonts directly into the HTML document, you can enable this option. This ensures that the document will render correctly regardless of the fonts available on the user’s system.
Here is a sample code snippet demonstrating how to set these options:
Document doc = new Document("path/to/your/document.docx");
HtmlSaveOptions options = new HtmlSaveOptions(SaveFormat.HTML);
// Set rendering modes for effects
options.setDmlEffectsRenderingMode(DmlEffectsRenderingMode.Fine);
options.setDml3DEffectsRenderingMode(Dml3DEffectsRenderingMode.Advanced);
options.setExportShapesAsSvg(true);
options.setExportFontsAsBase64(true);
// Save the document to HTML format
doc.save("path/to/output/document.html", options);
By configuring these options, you can enhance the fidelity of the converted HTML document and better preserve the visual effects from the original DOCX file.
@manfro Could you please attach the problematic input document here for testing? We will check the issue and provide you more information. Please note, Aspose.Words Document Object Model is designed to work with MS Word documents. HTML documents object model is quite different and it is not always possible to provide 100% fidelity after importing or exporting HTML document. Usually Aspose.Words mimics MS Word behavior when work with HTML documents.
If the output HTML is for viewing purposes, i.e. it is not supposed to be edited or processed, you can consider using HtmlFixed format. In this case the output should look exactly the same as it looks in MS Word:
Document doc = new Document("C:\\temp\\in.docx");
HtmlFixedSaveOptions opt = new HtmlFixedSaveOptions();
opt.setExportEmbeddedCss(true);
opt.setExportEmbeddedFonts(true);
opt.setExportEmbeddedImages(true);
opt.setExportEmbeddedSvg(true);
doc.save("C:\\Temp\\out.html", opt);
HtmlFixed format is designed to preserve original document layout for viewing purposes. So if your goal is to display the HTML on page, then this format can be considered as an alternative. But unfortunately, it does not support roundtrip to DOCX at all.
Thank you for your answer. I have created a simpler document to show which kind of effects are not converted:
Effects (2).docx (15,2 KB)
I can consider to use the HtmlFixed format which works as expected, the styles are only missing in the standard Html format.
@manfro
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): WORDSNET-28231
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.