Free Support Forum - aspose.com

Convert html with svgs to word document

Hi,


I’m using the licensed version of Aspose.Words to convert html into word document.
I have an html file with svg icons in it.When I try to convert it to word document, I don’t get anything in it. Attached is one sample document.

Can you please help me get svg icons in converted word document?

Regards,
Dipak Mahajan

Hi Dipak,

Thanks for your inquiry. I have tested the scenario and have managed to reproduce the same issue at my side. For the sake of correction, I have logged this problem in our issue tracking system as WORDSNET-11629. I have linked this forum thread to the same issue and you will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

Hi Tahir,


Thanks for looking into it.
Just wanted to convey one thing, I know if I open this html directly in word, it won’t support SVG as Microsoft Word does not support SVG at all. But I want to know is there a way aspose can help me to get these icons converted to may be in png format and those are rendered at the place of svg.

Regards,
Dipak Mahajan

Hi Dipak,

Thanks for your inquiry. The SVG is imported as Shape node into Aspose.Words DOM and you can export the shape node to image using following code example.


<!–[if gte mso 9]>
<w:WordDocument>
<w:View>Normal</w:View>
<w:Zoom>0</w:Zoom>
<w:TrackMoves/>
<w:TrackFormatting/>
<w:PunctuationKerning/>
<w:ValidateAgainstSchemas/>
<w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
<w:IgnoreMixedContent>false</w:IgnoreMixedContent>
<w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
<w:DoNotPromoteQF/>
<w:LidThemeOther>EN-US</w:LidThemeOther>
<w:LidThemeAsian>ZH-CN</w:LidThemeAsian>
<w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript>
<w:Compatibility>
<w:BreakWrappedTables/>
<w:SnapToGridInCell/>
<w:WrapTextWithPunct/>
<w:UseAsianBreakRules/>
<w:DontGrowAutofit/>
<w:SplitPgBreakAndParaMark/>
<w:EnableOpenTypeKerning/>
<w:DontFlipMirrorIndents/>
<w:OverrideTableStyleHps/>
<w:UseFELayout/>
</w:Compatibility>
<m:mathPr>
<m:mathFont m:val=“Cambria Math”/>
<m:brkBin m:val=“before”/>
<m:brkBinSub m:val="–"/>
<m:smallFrac m:val=“off”/>
<m:dispDef/>
<m:lMargin m:val=“0”/>
<m:rMargin m:val=“0”/>
<m:defJc m:val=“centerGroup”/>
<m:wrapIndent m:val=“1440”/>
<m:intLim m:val=“subSup”/>
<m:naryLim m:val=“undOvr”/>
</m:mathPr></w:WordDocument>
<![endif]–><!–[if gte mso 10]>

/* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-parent:""; mso-padding-alt:0pt 5.4pt 0pt 5.4pt; mso-para-margin-top:0pt; mso-para-margin-right:0pt; mso-para-margin-bottom:8.0pt; mso-para-margin-left:0pt; line-height:107%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri",sans-serif; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin;}

<![endif]–>

Document doc = new Document(MyDir + "in.html");

int i = 1;

foreach (Shape shape in doc.GetChildNodes(NodeType.Shape, true))

{

shape.GetShapeRenderer().Save(MyDir + "Out"+i+".png", new ImageSaveOptions(SaveFormat.Png));

i++;

}


This issue (WORDSNET-11629) is related to your input document. The Svg is not imported correctly into Aspose.Words DOM. The above code example does not export the svg to png correctly. We will update you via this forum thread once this issue is resolved. We apologize for your inconvenience.

Hi Tahir,


I have tried modifying the html a bit. Attached is the html I’m using now and the converted word document. The icons in the word document are not matching the source svg icon. Can you please check this as well?

Regards,
Dipak Mahajan

Hi Dipak,

Thanks for sharing the detail. Perhaps, you are using an older version of Aspose.Words; as with Aspose.Words v15.2.0, I am unable to reproduce this problem on my side. I would suggest you please upgrade to the latest version of Aspose.Words i.e. v15.2.0
and let us know how it goes on your side. I hope, this will help. I
have attached the output document with this post for your kind
reference.

The issues you have found earlier (filed as WORDSNET-11629) have been fixed in this .NET update and this Java update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.