Free Support Forum - aspose.com

Css not applying in the output pdf

Hi Team,


Am facing issue while generating pdf from html.
I have used css for sectioning out the data on the page. But when I convert, it all comes one after another.
It might be logical but is there any way, I can get the exact structure of html in the pdf with color combination set.
Attached is my html, css and below is the code.

Pdf pdf = new Pdf();
pdf.HtmlInfo.ImgUrl = @“C:\MyLearning\PdfConvertPOC\PdfConvertPOC\Resources\images”;

Section section = pdf.Sections.Add();
StreamReader r = File.OpenText(basePath);

Text text2 = new Text(section, r.ReadToEnd());
text2.IsHtmlTagSupported = true;
text2.IfHtmlTagSupportedOverwriteHtmlFontNames = true;

section.Paragraphs.Add(text2);

pdf.Save(pdfOutput);

MessageBox.Show(“Conversion done!”);

Hi Anju,


Thanks for your inquiry. Please note you are using old generator(Aspose.Pdf.Generator). It is recommended to use new generator for HTML to PDF conversion. However unfortunately it is not working as expected with your source HTML and CSS, So I have logged a ticket PDFNET-41565 in our issue tracking system for further investigation and rectification. We will notify you as soon as it is resolved.

We are sorry for the inconvenience.

Best Regards,

Hi Tilal Ahmad,
Thanks for your reply.

How would I get the latest generator.

I have installed the “Aspose.Pdf for .NET” and it details of the ref is as follows:

Version 12.0.0.0
Runtime version: v4.0.30319

Hi Anju,


Thanks for your inquriy. Please note no extra installation required for using new generator, a namespace(Aspose.Pdf) already included in Aspose.Pdf. Please check following documentation link for working with new generator(Aspose.Pdf). Please feel free to contact us for any query in this regard.


Best Regards,

Hi Tilal,
Is there any update on my issue above?

Am not able to apply css properly and image is not visible, in the output pdf.
Also, the layout is not as per the html.

Its urgent, so pls help as early as posiible.

Thanks.

Hi Anju,


Thanks for your patience.

As we recently have noticed the earlier reported issue, so its pending for review and is not yet resolved. However the product team will surely consider investigating/fixing it as per development schedule and as soon as we have some definite updates regarding its resolution, we will let you know. Please be patient and spare us little time. We are sorry for this delay and inconvenience.