Convert HTML to PDF using Aspose.HTML for .NET - Tables are not rendered correctly on pdf

Hi team,

We’re trying to generate PDF from HTML template but after conversion tables are not rendered in pdf as showing in html.

We’re using Aspose.Html.Converters.Converter.ConvertHTML(HTMLDocument document, PdfSaveOptions options, ICreateStreamProvider provider) method for converting html to pdf.

We are fetching data from external source and replacing values in template. Now we are converting html template to aspose template and then converting to pdf.
below is the small portion of our code -

//Fetching data
var summary = await _summaryRepository.GetItemAsync(id.ToString());

string serializedJson = JsonConvert.SerializeObject(summary);

// Setup default template with placeholders(only a portion of code)
string documentPath = Path.Combine(templatePath, “summarytemplate.html”);
HTMLDocument templateDocument = new HTMLDocument(documentPath);
templateDocument.Title = summary?.Company;

// Overlay data from datastore in the default template

templateDocument.GetElementById(“uwRationaleNotes”).InnerHTML = summary?.UWRationale?.Notes ?? “”;
if (summary.UWRationale.Notes == “” || summary.UWRationale.Notes == null)
{
templateDocument.GetElementById(“uwRationale”).SetAttribute(“style”, “display:none”);
}

//After preparing template, below is the code for pdf generation.

// Setup Template Options with Serialized json from repository
TemplateContentOptions templateOptions = new TemplateContentOptions(serializedJson, TemplateContent.JSON);
using (var streamProvider = new MemoryStreamProvider())
{
// Initialize HTML Template Merge
using (var mergedTemplate = Converter.ConvertTemplate(templateDocument, new TemplateData(templateOptions), new TemplateLoadOptions()))
{
// Convert HTML to PDF and load output to MemoryStreamProvider
Aspose.Html.Converters.Converter.ConvertHTML(mergedTemplate, new Aspose.Html.Saving.PdfSaveOptions(), streamProvider);

// Get access to the memory stream that contains the result data
	var pdfStream = streamProvider.Streams.First();
	pdfStream.Seek(0, System.IO.SeekOrigin.Begin);

Document pdfDocument = new Document(pdfStream);
PdfFileInfo pfi = new PdfFileInfo(pdfDocument);
pfi.Title = summary?.Company;

string headerText = summary?.Company + " - " + summary?.Title + " - " + summary?.SubmissionNo;
	
AddHeaderToDocument(pdfDocument, headerText);
AddPageNumberToDocument(pdfDocument);

	pdfDocument.Save(pdfStream);


	return pdfStream.ToArray();
}

Attached html and pdf file for reference. Please compare all the tables on both the files.
Issue 1 - For one table, Column width is not maintained in converted pdf.
Issue 2 - Other tables are getting cut off in converted pdf.

Please suggest what to do to resolve this issue.
Aspose_Generated_Pdf.zip (402.0 KB)

Aspose_HTML.zip (43.1 KB)

Thank you,
Tushar Sahu

Aspose_Generated_Pdf.zip (402.0 KB)

Aspose_HTML.zip (43.1 KB)

@tusharsahu

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): HTMLNET-5160

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

Hi @asad.ali , any update on this?

Could you please provide any update or tentative timeline for getting it resolved or processed?

@tusharsahu

We are afraid that the earlier logged ticket has not been fully investigated yet. Therefore, we are not in a position to share any reliable ETA. However, we will surely prioritize it on a first come first serve basis and as soon as we have some news about its resolution or fix ETA, we will share with you. Please spare us some time. We are sorry for the inconvenience.

@tusharsahu

We would like to share that the issue is resolved and will be a part of of the 24.2.0 release.

@asad.ali
Could you please provide the ETA for 24.2.0 release? we’ve been waiting for almost 2 months.

@tusharsahu

24.2 version is expected to be released in the first or second week of February, 2024. We will notify you once its available.

The issues you have found earlier (filed as HTMLNET-5160) have been fixed in this update. This message was posted using Bugs notification tool by avpavlysh