Hi Team,
We are encountering a table width issue in the PDF documents generated by Aspose. We have a template that contains a table, where some columns are dynamically removed during Word document generation. However, when converting the Word document to PDF, we’ve noticed that the width of one of the tables gets reduced however it set to 100 percent.
We’ve tried using the autofit property for the table via code, which resolved the problem in some cases. However, we continue to face table width issues in PDFs for other documents. We also tried using the “Update Layout” option, but this did not resolve the issue. The problem occurs intermittently, not every document.
Upon further investigation, we’ve observed that the tables with width issues have the “Automatically resize to fit contents” property checked. When we unchecked this property and regenerated the template, the PDF width issue was resolved.
Could you please confirm whether this property is causing the table width to shrink? Additionally, could you explain why the issue only occurs in PDFs and not in Word documents? If this is a limitation, is there a way to resolve it programmatically?
Looking forward to your insights.
I have attached the template , generated document and generated pdf document. you can found discrepancy between word and pdf document output.
FM test template.docx (43.6 KB)
FM test__FM test template_2025-03-25 (1).pdf (5.2 KB)
FM test__FM test template_2025-03-25.docx (31.5 KB)
below is code snippet to convert word to pdf document
using MemoryStream pdfDocStream = new();
var pdfSaveOptions = new PdfSaveOptions();
var wordDocumentToSave = (Document)wordDocument.Clone(true);
try
{
wordDocument.Save(pdfDocStream, pdfSaveOptions);
}
catch
{
pdfDocStream.SetLength(0);
pdfDocStream.Position = 0;
wordDocumentToSave.Styles.DefaultParagraphFormat.ClearFormatting();
wordDocumentToSave.Save(pdfDocStream, pdfSaveOptions);
}
Screenshot 2025-04-03 203005.png (51.9 KB)