We have upgraded aspose library in our application 20.6.0.0 to 24.9.0.0
After upgrading it created issue in tables which are in PDF report. content goes beyond right margin, previously it was adjusting content as per document.
Is there any changes done in new version, if yes then what is solution to fix the same.
It appears that the upgrade to version 24.9.0 of the Aspose library has introduced changes affecting the layout of tables in your PDF reports, specifically causing content to extend beyond the right margin.
Cause: The changes in the library may have altered how tables are rendered, impacting their layout and alignment.
Solution: To resolve this issue, please follow these steps:
-
Check Table Properties: Ensure that the table’s properties, such as column widths and alignment, are set correctly. Explicitly defining the widths of your columns can prevent them from exceeding the page width.
-
Adjust Page Margins: Review the page margins in your PDF generation code. If the margins have changed in the new version, adjust them to accommodate your table layout.
-
Update HTML/CSS: If you are converting HTML to PDF, ensure that your HTML and CSS are compatible with the new version. Changes in rendering can affect how content is displayed.
-
Test with Sample Data: Create a minimal example with a simple table to determine if the issue persists. This can help isolate whether the problem is with your specific data or a broader issue with the library.
-
Review Release Notes: Check the release notes for version 24.9.0 for any documented changes related to table rendering or layout that might affect your implementation.
Next Steps: If you continue to experience issues after following these steps, please share a code snippet or more details about how you are generating the PDF. I am here to assist you further.
Thank you, and I look forward to your response!
where can i find release note?
Would you please upgrade to the latest version which is 25.7 at the moment. Also, you can find the information about release notes at the below link:
In case you still face any kind of issues, please share minimal sample code snippet with us so that we can try to replicate the issue in our environment and address it accordingly.
Here is code
// Area where we create html data-----------------------
string html = string.Format(@"table style='width:100%;padding-left:5px;padding-right:5px;'> tr>td style='{2}'>{0}/td>/tr>
tr>td> /td>/tr>
tr>td >{1}/td>/tr>
</table"
, title
, subTableHtml
, this.Level1TitleCss
, this.CellBorderCss);
html = ASRExportHelper.PP_STYLE + html;
// Area where we create html data-----------------------
---------Area where the html is bing to builder-------------
builder.InsertHtml(section.HtmlContent);
pdf saving --------------------------
Document doc = new Document(tempPath);
DocumentBuilder builder = new DocumentBuilder(doc);
doc.Save(path, Aspose.Words.SaveFormat.Pdf);
Looks like you are using Aspose.Words. We have moved this topic to the respective forum category where you will be assisted accordingly.
@mayurih Could you please attach your problematic input HTML, temporary and problematic output documents here for testing? We will check the issue and provide you more information.
@mayurih Thank you for additional information. Unfortunately, I cannot reproduce the problem on my side. I used the following simple code for testing:
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.InsertHtml(File.ReadAllText(@"C:\Temp\in.html"));
doc.Save(@"C:\Temp\out.pdf");
out.pdf (63.1 KB)
which aspose version your are using at your end?
tempdoc.docx (75.3 KB)
we are using this document file as base template and appending dynamic table through html code in it. does this template have any issue?
@mayurih Yes, with your template the problem is reproducible. As a workaround, you can load your HTML into a separate document and then insert this document instead of HTML string. Please see the following code:
Document doc = new Document(@"C:\Temp\in.docx");
DocumentBuilder builder = new DocumentBuilder(doc);
builder.MoveToDocumentEnd();
Document htmlDoc = new Document(@"C:\Temp\in.html");
builder.InsertDocument(htmlDoc, ImportFormatMode.KeepSourceFormatting);
doc.Save(@"C:\Temp\out.pdf");
out.pdf (121.6 KB)
I have tried this solution my data gets adjusted properly but left side column data gets wrapped automatically.
@mayurih Please try modifying the code like this:
Document doc = new Document(@"C:\Temp\in.docx");
DocumentBuilder builder = new DocumentBuilder(doc);
builder.MoveToDocumentEnd();
Document htmlDoc = new Document(@"C:\Temp\in.html");
foreach (Table t in htmlDoc.GetChildNodes(NodeType.Table, true))
t.AutoFit(AutoFitBehavior.FixedColumnWidths);
builder.InsertDocument(htmlDoc, ImportFormatMode.KeepSourceFormatting);
doc.Save(@"C:\Temp\out.pdf");
out.pdf (121.5 KB)
this code is not working at my end.
NodeCollection tables = htmlDoc.GetChildNodes(NodeType.Table, true);
foreach (Aspose.Words.Tables.Table table in tables)
table.AutoFit(AutoFitBehavior.AutoFitToWindow);
@mayurih In the above code AutoFitBehavior.FixedColumnWidths was suggested not AutoFitBehavior.AutoFitToWindow. Please try using AutoFitBehavior.FixedColumnWidths.
it worked, but is there any way not to write content in html file as this may lead to creation of file on server and for each user we might need to create new.

