We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Exception when adding SVG image to word document

Hi, 

When I add a very minimal SVG file to a Word document, I get the following exception:

System.Xml.XmlException: 'For security reasons DTD is prohibited in this XML document. To enable DTD processing set the DtdProcessing property on XmlReaderSettings to Parse and pass the settings into XmlReader.Create method.'

The following code generates the exception. Also attached is the SVG file.

WordDocument document = new WordDocument();

IWSection section = document.AddSection();

IWParagraph firstParagraph = section.AddParagraph();

byte[] imageBytes = File.ReadAllBytes("images/hello.png");

byte[] svgData = File.ReadAllBytes("images/hello.svg");

IWPicture picture = firstParagraph.AppendPicture(svgData, imageBytes);


Attachment: hello_f586246a.zip

1 Reply

PR Poorani Rajendran Syncfusion Team August 13, 2019 07:40 AM UTC

Hi Benny,

Thank you for contacting Syncfusion support.

On analyzing the given SVG file, we have found that the document is prohibited with DTD type for some security reason. So, the reported exception throws. To resolve the reported problem, you need to remove the DTD type in file level. We have prepared a sample application along with modified SVG file and code snippet and it can be downloaded from the below link:
https://www.syncfusion.com/downloads/support/forum/146655/ze/GenerateWord1702988728

Note: Please find the input SVG and PNG file in the “Data” folder of above sample application.

Please refer the below link to know more about the reported exception problem.
https://social.msdn.microsoft.com/Forums/sqlserver/en-US/1be6ab1c-7c89-4dc5-8474-f7d0770431f0/for-security-reasons-dtd-is-prohibited-in-this-xml-document-to-enable-dtd-processing-set-the?forum=sqlreportingservices

Please let us know if you have any other questions.

Regards,

Poorani Rajendran
 


Loader.
Up arrow icon