2

I am trying to convert HTML page to pdf. Html page contains css, js code with svg images. I used wkhtmltopdf, iTextSharp and IronPdf dlls to get the exact html page into pdf. Functionality present in each of the above dll gives me pdf file containing content of html,css and js but excludes svg images. Is there any way to render the svg images into pdf. I am pasting code snippet here:

HtmlToPdf HtmlToPdf = new HtmlToPdf();
HtmlToPdf.PrintOptions.EnableJavaScript = true;
HtmlToPdf.PrintOptions.CssMediaType =PdfPrintOptions.PdfCssMediaType.Screen;
PdfResource PDF = HtmlToPdf.RenderUrlAsPdf(new Uri(htmlFilePath));
PDF.SaveAs(pdfFilePath);
Stephanie
  • 600
  • 13
  • 24
Prasad Telkikar
  • 15,207
  • 5
  • 21
  • 44

1 Answers1

2

IronPDF extract SVG images, To convert html page containing SVG images we need to set height with some values on SVG tag. If we did not mention height in SVG tag it will be considered as default i.e. to 0px.

This can be achieved using style= height:400px in SVG tag.

Prasad Telkikar
  • 15,207
  • 5
  • 21
  • 44
  • 2
    I got IronPDF to work with SVG files after i set a style="height:400px;" attribute on the SVG tag. Otherwise the image did not render (or was 0px high). – Snellface Oct 17 '17 at 13:07