Unable to download pdf with css parameters {HTML2PDFConverter}


I am trying to create an image using HTML2PDF Converter with a different font family.
I am using the method GenerateImage.
Am able to see the css changes on the page in code, but when i embed this image in a pdf and download it, the css changes are not shown.
Any suggestion how to resolve this?

My required flow is as below:

1. Take user input in an input box

2. Give this user input a different font family css

3. Convert this input as an image

4. Embed this image in a PDF and download it with the css.

My approach:

I tried to create a new page with the input parameter of the user input text. Defined the CSS classes and font family on this page for the input (which showed correct on the page) and gave this pages URL as an input to the  GenerateImage method on my parent page.
Still this image here is not taking the CSS i gave to it.
Am I missing something?

Please help.



Heavy CSS and HTML2PDF do not match very well. 

Try to use the email theme so the only CSS for the pages to download is the one you define for them. 

Also remember that the GenerateImage method will run in another session so session variables will be empty. 

Hope this helps

Good Easter 



Thank you Maria for the response.
I tried changing the layout to Email
But still it didn't work.

Thanks and take care,


Hi Anagha,

Instead printing the actual page that user is seeing, why not create other page that displays the image instead of the input and request to print that page?

We often create simpler pages to display the information with less elements and simpler in order to the process of convert the page to pdf became more simple.

Additionally, as Maria da Graça Peixoto mentioned Heavy CSS and HTML2PDF do not match very well, please take a look into the following blog post:


Why you don't also try the Ultimate PDF forge component

This component uses the same rendering engine as Chromium (an open-source version of Google Chrome) to transform web pages into PDF documents.

Unlike wkhtmltopdf, the Chromium project is actively developed, supports latest web standards, and predictably outputs the same results as the print preview from a browser.

Hope this helps you.

Best regards,

Daniel Martins