Free Support Forum - aspose.com

Convert HTML to PDF using Aspose.PDF for .NET - CSS rendering in not consistent through out the PDF

Hi,
I am try to generate a pdf from html string or a html file but the CSS is not rendering consistent through out the PDF. My Html has table and the border for table are dark for some rows and column while lite for others. I have used two approach for this and i am getting same result from both approach.

My First Approach:

StringBuilder html = new StringBuilder();

string PdfHtmlTemplateHead = @"";
html.Append(PdfHtmlTemplateHead);
html.Append(File.ReadAllText(“E:\CSS\PdfCOOPPremManulifeCss.css”));
string PdfHtmlTemplateBody = @" HTML TABLE HERE ";
html.Append(PdfHtmlTemplateBody);

  		HtmlLoadOptions objLoadOptions = new HtmlLoadOptions();
            objLoadOptions.PageInfo.Margin.Bottom = 10;
            objLoadOptions.PageInfo.Margin.Top = 30;
            objLoadOptions.PageInfo.Margin.Left = 10;
            objLoadOptions.PageInfo.Margin.Right = 10;
            objLoadOptions.PageInfo.Width = Aspose.Pdf.PageSize.A4.Width;

            Document doc = new Document(new MemoryStream(Encoding.UTF8.GetBytes(html.ToString())), objLoadOptions);
            string FileName = "Sample_" + DateTime.Now.ToString("dd-MM-yyyy") + ".pdf";
            //Save PDF file on local hard drive or database or as you wish          
            doc.Save(@"E:\Aspose\" + FileName);

My Second approach:

String basePath = @“E:\CSS2”;
HtmlLoadOptions objLoadOptions = new HtmlLoadOptions(basePath);
objLoadOptions.PageInfo.Margin.Bottom = 10;
objLoadOptions.PageInfo.Margin.Top = 30;
objLoadOptions.PageInfo.Margin.Left = 10;
objLoadOptions.PageInfo.Margin.Right = 10;
objLoadOptions.PageInfo.Width = Aspose.Pdf.PageSize.A4.Width;

            //Load HTML string into MemoryStream using Aspose document class
            Document doc = new Document(@"E:\CSS2\testqc.html", objLoadOptions);
            string FileName = "Sample_" + DateTime.Now.ToString("dd-MM-yyyy") + ".pdf";
            //Save PDF file on local hard drive or database or as you wish          
            doc.Save(@"E:\Aspose\" + FileName);

I am using this piece of CSS to apply border in my table:

table, tr{
border: 1px solid black;
border-collapse: collapse;
}

But the output is not consistent. I am attaching screenshot of the output.aspose_output.PNG (62.1 KB)

@PankajToshiwal,

Can you please share source files along with generated PDF so that we may further investigate to help you out.

Hi Please find the Source file and sample pdf. Same pdf is generated from both approach.Aspose.zip (106.0 KB)

@PankajToshiwal,

We have tested the scenario in our environment and were able to notice the issue. We have logged it as PDFNET-47540 in our issue tracking system. We will further look into details of the issue and keep you posted with the status of its correction. Please be patient and spare us little time.

We are sorry for the inconvenience.

Hi Team,

Please let me know when will i get a solution for PDFNET-47540.

@PankajToshiwal,

I like to inform this issue has been added recently in our issue tracking system and as per our company policy, the first priority for investigation is given to the Paid Support i.e. Enterprise and Priority Support on first come first serve basis. After that the issues from normal support forum are scheduled for investigation on first come first serve basis. I request for your patience and we will share good news with you soon.

Hi Team,

I am attaching my paid account details as attachment. Please prioritize my request that is logged under PDFNET-47540 and provide us a solution as soon as possible.

Thanks
AccountDetails.zip (294 Bytes)

@PankajToshiwal,

I like to inform that if you are entitled to priority support than please visit Paid support helpdesk to get your issue resolve as soon as possible.

@Adnan.Ahmad,

Can you please transfer my request to paid support or i have to generate a new request on paid support help desk?

Thanks

@PankajToshiwal,

I like to inform that you have to create new request on paid support help desk.

Hi Team,

We don’t have paid support, we have license only, so please move on with this normal ticket. Can you please provide us a tentative timeline when it will get implemented?

Thanks

@PankajToshiwal,

Please spare us sometime and we will share ETA with you soon.

Hi Team,

Any update regarding ETA?

Thanks

@PankajToshiwal,

I like to inform that we have raised issue priority and will share good news with you soon.