Table overlapped with contents below it when converted from DOC to PDF

I did a very simple Document.Save from DOC document to PDF, and the result is not correct. The table will be out of place and overlaps with contents below it.



This happens to all documents for my client, as they uses the same template for their archive documents. I am suppose to be able to utilize aspose to easily convert them to PDF. However, this issue makes Aspose not usable at all.



I had tried to set compliance level of PdfSaveOption, but to no avail. Any suggestions?



Sample file as attached:



input.doc --> input file for testing. I had replaced most contents with lorem ipsum, however, the issue can still be reproduced



output.pdf --> output file i generated from my code. you will see the table overlaps with the content below it.

Hi there,

Thanks for your inquiry.

I managed to reproduce the issue, I have linked your request and you will be notified as soon as the issue is resolved. The reason for the incorrect layout when rendering your document is because the first table in your document is floating. Aspose.Words does not fully support positioning floating tables upon rendering.

However you can easily refactor your document to use inline tables instead. There will be no real visible difference using inline tables in your document so this should cause cause no disruption. You will need to open the Table Properties of the first table in your document and set positioning from around to none. Please see the screen shot below.

After doing this your document renders correctly.

If I can help you with anything else, please feel free to ask.

Thanks,

Thank you so much for the prompt response!!



Unfortunately the floating table was part of the document template, which thousands of DOC documents are created from. Manually modifying all of them will be practically impossible. May I know will this be fixed in a update soon? Or I need to resort to work arounds and/or modify the document?

Hi there,

Thanks for this additional information.

We have been making good progress regarding positioning floating content upon rendering, recently we released an update which allows floating shapes to be rendered correctly. We are currently working on floating tables, but I'm afraid I can give no definite release date yet. I will keep you informed of any developments.

In the mean time I think you will have to use a work around. Hopefully you can use the code below. You should also beable to apply this to all tables in the document if you are not sure which ones will be floating or not and it shouldn't cause any problems.

The code will attempt to nest the first table in your document (the floating table) into an inline table. Using this inline table then renders correctly.

Document doc = new Document("input.doc");<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

ConvertToInlineTable(doc.FirstSection.Body.Tables[0]);

doc.Save("Document out.pdf");

///

/// Attempts to make a floating table inline by adding the table to an inline container table.

///

public static void ConvertToInlineTable(Table table)

{

Document doc = (Document)table.Document;

// Shouldn't need to do this for a table already nested within another table.

if (table.GetAncestor(NodeType.Table) == null)

{

// Create a new table and set the width to the width of the page.

Table newTable = new Table(doc); // Tables are created inline by default.

newTable.EnsureMinimum();

Cell firstCell = newTable.FirstRow.FirstCell;

firstCell.RemoveAllChildren(); // Remove empty first paragraph.

PageSetup pageSetup = ((Section)table.GetAncestor(NodeType.Section)).PageSetup;

firstCell.CellFormat.Width = pageSetup.PageWidth - pageSetup.LeftMargin - pageSetup.RightMargin;

// Nest the table within the created table and add it to the document.

table.ParentNode.InsertAfter(newTable, table);

newTable.FirstRow.FirstCell.AppendChild(table);

}

}

If you have any further queries, please feel free to ask.

Thanks,

The issues you have found earlier (filed as WORDSNET-1940) have been fixed in this .NET update and in this Java update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.
(36)