ABCPdf Convert Svg Stream to PDF

I would like to convert an Svg stream to Pdf using ABCPdf in C #. The stream I receive contains XML Svg. I am using the Doc.AddImageHtml method provided by ABCPdf. Since I only receive XML from the stream, I prefix and suffix the html and body tags to it to make it HTML. I use the following code for this:

Doc abcPdfDoc = new Doc();                                
XmlDocument xDocument = new XmlDocument();
xDocument.Load(stream);
abcPdfDoc.AddImageHtml("<html><body>" + xDocument.InnerXml + "</html></body>");
abcPdfDoc.Save(@"MyPdf.pdf");
abcPdfDoc.Clear();   

      

The problem is the tables in my SVG are not being saved. Result in my PDF text without tables. (Straight for specific)

Any pointers on what can be done to keep the format, or a better way to achieve the same using ABCPdf?

+3


source to share


1 answer


You don't need to use AddImageHtml. Assuming you're using a fairly standard SVG based on the SVG Tiny spec, you can just Doc.Read the SVG straight out. It's fast, simple, and efficient, and it works well for most SVG documents.



If your SVG is more complex, you can use the Gecko engine. For this you can use AddImageHtml with SVG setting for Doc.HtmlOptions.Engine property for EngineType.Gecko. The Gecko engine includes a lot of overhead, but provides full coverage of the SVG specification.

+2


source







All Articles