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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Exception when adding SVG image to word document

Thread ID:

Created:

Updated:

Platform:

Replies:

146655 Aug 12,2019 10:55 AM UTC Aug 13,2019 07:40 AM UTC WinForms 1
loading
Tags: DocIO
Benny Ben-Ami
Asked On August 12, 2019 10:55 AM UTC

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

Poorani Rajendran [Syncfusion]
Replied On 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
 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon