Html to PDF Include colors

I am converting a Html document to PDF and the text colors and background colors within are being stripped out. To me it seems like Aspose.PDF is getting a “Print” ready version of the document in place.

This occurs with css class defined background colors as well as inline background colours.

e.g.

<div style="background-color: red">This text should have a red background</div>

Can I force Aspose to retain all colours?

HTML View:

image.png (6.3 KB)

PDF View:

image.png (12.1 KB)

Thanks
-Chris

@ct14it

Thank you for contacting support.

We would like to request you to share the source files including all necessary resources, CSS, Images, etc., if any, along with the generated PDF document and the source code you are using for this conversion so that we may try to reproduce and investigate it in our environment. Kindly ZIP all relevant files and share with us.

Hi Farhan, on creating a demo project for you I can see that the background colours are being set as expected. This makes me wonder if I have a media -> print style definition interfering with things in my main project.

I’m happy to admit that this is my issue and not one with Aspose!

Thanks
-Chris

Just to update, it was the Bootstrap 3 @media print queries that were (correctly) stopping the backgrounds and colours from being visible. I’m now referencing a modified Bootstrap.css file with the @media print style definitions removed and all is well!

Thanks

@ct14it

Thank you for your kind feedback.

We are glad to know that your issue has been resolved. Please keep using our APIs and feel free to contact us in event of any further query.