CSS in not applying while convert HTML page to PDF

Hi,

I have tried below code to convert HTML page to PDF. The content is written correctly. But the CSS is not applied. I have got the sample code from ASPOSE. Even though it is not working.

Actually I am getting error while use UseNewConversionEngine property. This is not coming. It is giving compile time error.

HtmlLoadOptions options = new HtmlLoadOptions();
// use the new conversion engine
options.UseNewConversionEngine = true;
// load HTML file
Document pdfDocument = new Document(“Input.html”, options);
// save output as PDF format
pdfDocument.Save(myDir + “Output.pdf”);

Thanks,

Sankar Ganesh. C

Hi Sankar,


Thanks for contacting support.

Please remove the code line stating options.UseNewConversionEngine = true;

In case you still face similar issue or you have any further query, please feel free to contact.

Hi,


Thanks for your response. When I removed those line. The CSS is not applied while generating PDF.

Please share the sample code for convert the HTML page to PDF. HTML page has image and external CSS.

Thanks,
Sankar Ganesh. C

Hi Sankar,


Thanks for sharing the details.

In order to load/reference external images/CSS during HTML to PDF conversion, you need to pass the path information as argument to HtmlLoadOptions(…) constructor. For further details, please visit Convert HTML to PDF - Resource Loading Callback

In case you still face the same issue, please share the input files, so that we can further look into this matter. We are sorry for this inconvenience.