How to convert inline SVG XML in HTML content to PDF

1 Answer 23 Views
Top achievements
Rank 1
Bill asked on 14 Sep 2022, 03:07 PM

I'm using the HTMLFormatProvider to import HTML content into a RadFlowDocument. This content contains inline <svg> XML. When I use a PdfFormatProvider to attempt to export the HTML page as a PDF, the image is blank. Is it possible to export the SVG as part of that PDF when it is not a file but the actual SVG xml in the page?


                string htmlContent = task.Result;

                HtmlFormatProvider htmlProvider = new HtmlFormatProvider();
                RadFlowDocument document = htmlProvider.Import(htmlContent);
                PdfFormatProvider pdfProvider = new PdfFormatProvider();

                Telerik.Windows.Documents.Extensibility.JpegImageConverterBase jpegImageConverter = new JpegImageConverter();
                Telerik.Windows.Documents.Extensibility.FixedExtensibilityManager.JpegImageConverter = jpegImageConverter;
                foreach(Section section in document.Sections)
                    section.PageMargins = new Telerik.Windows.Documents.Primitives.Padding(10);
                byte[] pdfBytes = pdfProvider.Export(document);

1 Answer, 1 is accepted

Sort by
Telerik team
answered on 15 Sep 2022, 10:55 AM

Hello Bill,

The HtmlFormatProvider does not support the SVG tag, which is why the image is not imported/exported. We have a feature request for this on our feedback portal. You can track its progress, subscribe to status changes, and add your comment to it here: WordsProcessing: Add support for the SVG element in HtmlFormatProvider.

I am afraid I cannot suggest an alternative solution for this.

I want to apologize for the inconvenience this missing functionality is causing you.

Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Asked by
Top achievements
Rank 1
Answers by
Telerik team
Share this question