We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How to convert HTML to PDF including images and CSS styles?


We have some HTML with CSS styles and an embedded SVG which we want to convert to PDF.

We are using just creating a new Document:

public void WriteToPDF(Stream streamToWriteTo)
Document document = new Document(new MemoryStream(Encoding.UTF32.GetBytes(_htmlTemplateText)));
document.Save(streamToWriteTo, SaveFormat.Pdf);

This does not render styles or embedded SVG’s however.

Is this just a limitation of the rendering engine?

Is there a list of the limitations of converting HTML to PDF with Aspose somewhere?

Hi Nick,

Thanks for your inquiry. Could you please attach your input HTML file and output PDF document showing the undesired behaviour here for testing? I will investigate the issue on my side and provide you more information.

Secondly, you can find a list of certain limitations i.e. applied when importing from HTML file and exporting Word document to HTML file in the documentation below:

Best regards,


Before I take the time to provide examples, can you confirm whether or not these features are SUPPOSED to be supported? I have read the documentation here: http://www.aspose.com/docs/display/wordsnet/Style+Features+Supported+on+PDF+Export
…and here: http://www.aspose.com/docs/display/wordsnet/Drawing+Object+Features+Supported+on+PDF+Export

I read this as when converting HTML to PDF:
* SVG embedded is NOT supported
* CSS stylesheets or embedded styles are NOT supported

Is that correct please?



Thanks for your inquiry.

1) The latest version of Aspose.Words (13.5.0) supports import of SVG images from HTML and preserves these images during rendering HTML to PDF. Internally in Aspose.Words document model the SVG images are converted to PNG images using resolution of 96 dpi. For example, the following HTML mark-up is supported:




<h1>Embed SVG code directly into the HTML</h1>

<svg xmlns="http://www.w3.org/2000/svg" version="1.1">

<circle cx="100" cy="50" r="40" stroke="black" stroke-width="2" fill="red" />





2) Please note that it is not guaranteed that Aspose.Words generated output PDF document will look exactly the same as the input HTML. This is because Aspose.Words was originally designed to work with Microsoft Word documents and HTML documents are quite different. However, we strive to continuously improve Aspose.Words' HTML/CSS import engine. Please refer to the following section of the documentation which outlines everything you need to know about Style Features Supported on HTML Import:

Best regards,