Free Support Forum - aspose.com

Preserve Table Layout during Saving Word DOCX Document As PDF using C# .NET

Hi,

I’ve found issue similar to fixed WORDSNET-17941. When saving attached word document to Word text in cell is all in one line. When doing the same, but saving to PDF the output changes and text ‘Invoice Date:’ and date in next cell are split across two lines. I’m using:

file.UpdateTableLayout();

between reading the document and saving it (workaround for other issue suggested by your team) - but it has no impact on document saved as word. Could you please investigate?

Files:
SaveToPdf_Aspose.zip (74.5 KB)

Thanks,
Mateusz

@acturisaspose,

In this case, the problem is occurring because of Document.UpdateTableLayout method call. Please note that you do not normally need to call this method as cell and table widths are maintained automatically. You can call this method before exporting to PDF (or any other fixed-page format), only in rare cases where you confirmed that tables appear incorrectly laid out in the output document. Calling this method might help to correct the output. You do not need to call this method if the tables appear correct in the output document. In this case, please just use the following code:

Document doc = new Document("C:\\SaveToPdf_Aspose\\SaveToPdf\\test.docx");
doc.Save("C:\\SaveToPdf_Aspose\\SaveToPdf\\21.4.pdf");