Free Support Forum - aspose.com

HTML to PDF Conversion with @media print query

Hi Aspose,


We have your .net HTML to PDF generator running in our web application. It appears to load embedded CSS, as it should. But the client wants a PDF only design, without affecting the web application.

So in other words, can I load an aspose.css file to ONLY load when a PDF is generated from HTML?

This way I can add CSS !important overrides to the aspose.css file to make the design of the final PDF match the intended design.

Thank you.

Hi Mitchell,


Thanks for your inquiry. As per my understanding you want a feature in HTML to PDF conversion to control CSS, whether embedded CSS should be honored or not in the conversion. We will appreciate it if you please share your source HTML along with current resultant PDF and expected PDF. It will help us to understand your requirement exactly and address it accordingly.

Best Regards,

Not sure how easy it would be to share the HTML, but maybe there’s a simpler question:


When using the browser’s native print function, the page looks perfect.

Is there a way to have Aspose HTML to PDF follow print media query CSS?

Hi Mitchell,


Thanks for your feedback. I am afraid currently Aspose.Pdf does not honor @media print query in HTML to PDF conversion. However we will appreciate if you share your sample HTML with @media print query so we will log a ticket for investigation and rectification accordingly.

We are sorry for the inconvenience.

Best Regards,