Free Support Forum - aspose.com

UpdateTableLayout does not update the layout of table using .NET

Hi Aspose team,

we are currently experiencing an issue with tables inside a document. In the past, we already had an issue similar to this, which was solved by calling UpdateTableLayout . See this issue: PDF conversion with margins and tables in doc files

Now, the above method is causing issues for another customer of us with his documents. We already reduced the document to the problemtaic table. We already found an intresting fact, that the behaviour of Aspose is depending of the content in the second table bottom right cell. The original document of our customer has two paragraphs with the second paragraph breaking into a new line. If you reduce that parapgraphs content so it will not break into a new line, the generated PDF will be fine.

Here is the example code:

            var lic = new License();
            lic.SetLicense(@"S:\Aspose.Total.lic");

            var doc = new Document(@"S:\test_1.docx");
            doc.Save(@"S:\1_out.pdf");

            doc = new Document(@"S:\test_1.docx");
            doc.UpdateTableLayout();
            doc.Save(@"S:\1_out_updated.pdf");

            doc = new Document(@"S:\test_2.docx");
            doc.Save(@"S:\2_out.pdf");

            doc = new Document(@"S:\test_2.docx");
            doc.UpdateTableLayout();
            doc.Save(@"S:\2_out_updated.pdf");

I attached an zip archive with includes two testing documents and 6 pdf outputs: 4 by aspose and 2 created with word for comparison.

test_1.docx -> first document with modified of second table bottom right cell (two paragraphs, each fits into one line)
1_word.pdf -> test_1.docx converted to PDF with MS Word as reference
1_out.pdf -> test_1.docx converted to PDF with Aspose without calling UpdateTableLayout: WRONG OUTPUT (There is space missing compared to the pdf generated by word.)
1_out_updated.pdf -> test_1.docx converted to PDF with Aspose with calling UpdateTableLayout: CORRECT OUTPUT

test_2.docx -> second document which is representing the customers original document and problem. second table bottom right cell has two paragraphs, second paragraph breaks into new line.
2_word.pdf -> test_2.docx converted to PDF with MS Word as reference
2_out.pdf -> test_2.docx converted to PDF with Aspose without calling UpdateTableLayout: WRONG OUTPUT (There is space missing compared to the pdf generated by word.)
2_out_updated.pdf -> test_2.docx converted to PDF with Aspose with calling UpdateTableLayout: WRONG OUTPUT (There is space missing compared to the pdf generated by word. Additionally there is white space before the second table.)

I hope you can have a look into the issue any may solve it. I do not know if the issues might be related but we also have another issue ([.Net] PDF conversion using margins and tables) opened, which is related to UpdateTableLayout for over a year now but that other ticket was related to margins, this is without. I also hope the things we found out with the line breaking paragraph and such will help you solving the issue.

example.zip (1.4 MB)

Kind regards,
Daniel

@Serraniel

We are investigating this issue and will get back to you soon.

@Serraniel

We have logged these problems in our issue tracking system as WORDSNET-18880 and WORDSNET-18881. You will be notified via this forum thread once these issues are resolved.

We apologize for your inconvenience.

@Serraniel

As a workaround of this issue, please use PdfSaveOptions.UpdateFields property with false value. Hope this helps you.

Hi Tahir,

thanks for your hint. I have tried this anbd it seems to work for the first test document. For the second, it still fails when we also kepp calling UpdateTableLayout method, so 2_out_updated still have that white space.

Are there any side effects when using that method? In our productive code, when working with a document, we have the following steps:
1: Setting margins (if configured)
2: Replacing header and footer (if configured)
3: Adding watermark to the document (via headers) (if configured)
4: Replacing our own fields
5: Updating document ( UpdatePageLayout (if required) `UpdateTableLayout, Updating each of our own fields, updating TOC fields
6: Print or save in target format.

Do we need to expect any differences in the output when using that SaveOption?

Kind Regards,
Daniel

EDIT: For this specific document, headers and footers will not be replaced. I also tested the full document with the productive code and the workaround without success as the original document matches the second document and we are using the UpdateTableLayout method, which is the still failing case.

@Serraniel

Please do not call Document.UpdateTableLayout method for both cases. Please only use PdfSaveOptions.UpdateFields property.

Hi @tahir.manzoor,

it works without the UpdateTableLayout call. However, as we have been suggested by a moderator to use that method in this topic to solve an : PDF conversion with margins and tables in doc files
I have tried the document from the old topic. The pdf still is broken without calling UpdateTableLayout method. So we somehow are in a situation where we have to call that method to fix a document but it generates issues for other documents (I assume WORDSNET-16492, WORDSNET-17306 from [.Net] PDF conversion using margins and tables which are blocked by WORDSNET-832 according to your post) deal with the same topic in the end. Tables are broken in the PDF in some cases, which seem to be related to the UpdateTableLayout which fixes other problems. I personally do not feel very comfortable to change something, knowing it will reopen an old issue and breaks other documents which has been working before. Shall I reupload you the documents from topic 18614 for you again as they seem to be lost since the forum migration? What would you suggest what we should do now, as both paths are not working correctly for us in the end?

Kind Regards,
Daniel

As this relates to other issues we had with tables and is split across at least three different topics, should I recreate one large topics for the issues were I sum up all issues again including the examples and such, so you have a better overview on how they may connect to each other to solve the issue in a way, which does not break other documents?

@Serraniel

There is no need to create separate topic for your issues. We will inform you via this forum thread once your issues are resolved. We apologize for your inconvenience.

Hi @tahir.manzoor,

I have an update regarding WORDSNET-18880 (assuming this is the issue related to test_1.docx from original post) as we have retested the issues with Aspose 20.1.0.

The original reported issue isn´t reproducable with the above code and new Aspose version. However I noticed a small difference in the column width of first column of the last table in the document content. I also recognized that the font is thicker than in the PDF generated by word in my original post.

I attached you an archive including the original PDF generated by word from my old post, the old PDF documents generated by Aspose when I created the topic and the new PDF generated by Aspose 20.1.

Can you please check the issue again or update it? test_2.docx still generates the same wrong output as at the time I created the issue. If the first one is resolved meanwhile that may help you checking the second one again, too, if you can fix it now.

Kind Regards,
Daniel

wordsnet-18880.zip (221.4 KB)

@Serraniel

Thanks for sharing the detail. The output generated by latest version of Aspose.Words 20.1 is better. We have logged the shared detail in our issue tracking system. We will inform you via this forum thread once there is any update available on this issue.

Thanks for your patience and understanding.

@Serraniel

We have logged separate issue for this case as WORDSNET-19861.

We have logged separate issue for this case as WORDSNET-19862.

We have not found this issue in output PDF file. Could you please point problematic text along with screenshots for this issue issue?

Here is a screenshot with both versions side by side. On the left is 1_word.pdf and on the right you see new/1_out.pdf from my last zip file.

At least when viewing theme with edge browser, the fonts do look different with aspose:
grafik.png (192.0 KB)

@Serraniel

We have checked the shared PDF files with Edge browser and have not found this issue. Please check the attached image for detail. Edge browser.png (126.1 KB)

It seems that this issue is related to viewer. You can check the output PDF files with some other PDF viewers.

Thanks for your feedback. I tried with chrome and it looks correct for me, too. Weird that Edge show different results for me but I think it´s not a bug in the PDF then.

@Serraniel

Thanks for your feedback. We have closed WORDSNET-18880 and WORDSNET-19861 issues. The issues do not reproduce using latest version of Aspose.Words for .NET 20.1.

We will inform you via this forum thread once WORDSNET-18881 and WORDSNET-19862 issues are resolved.

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