We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Conversion from Docx to png and pdf- issues on tables with autofit

Dear Aspose Team,
our customers often complain that tables used in word documents are not rendered correctly when using “fit to content” setting.
The table is always using fix column widths.
If you open such document with MS Word the table are looking fine as MS Word corrects the layout of the table. But if you directly convert the document to PNG or PDF, the tables are not rendered as expected.
Tested with Aspose.Words for .Net 15.3.0
Please find attached the source document for reproducing the issue.
Code to reproduce the issue (no hotfix required):

String docFilepath = @"...docx";
global::Aspose.Words.Document doc = new global::Aspose.Words.Document(docFilepath);
String imageFilePath = @"...png"; 
String pdfFilePath = @"....pdf";
doc.Save(imageFilePath);
doc.Save(pdfFilePath);

Please have a look into the problem.
Wolfgang

Hi Wolfgang,

Thanks for your inquiry. I have tested the scenario and have managed to reproduce the same issue at my side. For the sake of correction, I have logged this problem in our issue tracking system as WORDSNET-11845. I have linked this forum thread to the same issue and you will be notified via this forum thread once this issue is resolved. We apologize for your inconvenience.

In your case, I suggest you please use Table.AutoFit method with AutoFitBehavior.AutoFitToWindow value as shown in following code snippet. Hope this helps you.

Document doc = new Document(MyDir + "tableAutofit.docx");
Table table = (Table)doc.GetChild(NodeType.Table, 0, true);
table.AutoFit(AutoFitBehavior.AutoFitToWindow);
doc.Save(MyDir + "Out.pdf");
doc.Save(MyDir + "Out.png");

Hi Tahir,

thanks for the feedback!

Unfortunately, the workaround is not providing the behavior that our customers are expecting.

Could you please provide an ETA, when this issue is planned to be resolved?

Thanks and cheers
Wolfgang

Hi Wolfgang,

Thanks for your inquiry. We regret to share with you that your issue (WORDSNET-11845) has been postponed due to missing feature WORDSNET-832 (Make table layout as close to Word as possible) which is related to your issue.

After the fix of WORDSNET-832, our product team will look into your issue. We will be sure to inform you via this forum thread as soon as this issue is resolved.

We apologize for your inconvenience.

The issues you have found earlier (filed as WORDSNET-11845) have been fixed in this Aspose.Words for .NET 18.9 update and this Aspose.Words for Java 18.9 update.

The issues you have found earlier (filed as ) have been fixed in this Aspose.Words for .NET 18.12 update and this Aspose.Words for Java 18.12 update.