Columns widths and heights are not maintained in table

Hi,

We are using aspose words in our application to create word documents through html input.

  1. The columns are shown much squeezed than the original width in table. The referenced html “Table.zip” is attached.

Table.zip (878 Bytes)

The actual output “Aspose Output.zip” is attached.

Aspose Output.zip (8.6 KB)

  1. The height of the cells is increased too

Please see snapshot “Role Administration Screen.png”

Role Administration Screen.png (48.9 KB)

Please look in to the issues and let us know if any other thing is required.

Regards,
Asif.

@asifsharif,

After an initial test, we were unable to reproduce this issue on our end. We used the following simple code for testing on our end:

Document doc = new Document("E:\\temp\\Table\\Table.html");
doc.Save("E:\\temp\\Table\\19.2.docx");

Please also create a standalone simple console application (source code without compilation errors) that helps us to reproduce your problem on our end and attach it here for testing. Please do not include Aspose DLL files in it to reduce the file size. Thanks for your cooperation.

awais, issue is reproducible with the following code:

string filePath = @"[DirectoryName]:\Myhtmlfile.html";
Document htmlDoc = new Document(filePath, new Aspose.Words.HtmlLoadOptions() {LoadFormat =LoadFormat.Html, Encoding = Encoding.UTF8});
SaveOutputParameters param = htmlDoc.Save(filePath);

Please check it.

Regards.

@asifsharif,

We tested the scenario and have managed to reproduce the same problem on our end. For the sake of correction, we have logged this problem in our issue tracking system. The ID of this issue is WORDSNET-18175. We will further look into the details of this problem and will keep you updated on the status of correction. We apologize for your inconvenience.

awais, have you managed to produce both the issues?

In case cell height issue is not producible please find the attached file “Smart Report of Cell Height Doc.zip” which shows the output and “Smart Report of Cell Height.zip” which contains the html file to produce the issue.

Smart Report of Cell Height Doc.zip (12.7 KB)

Smart Report of Cell Height.zip (3.1 KB)

Regards,
Asif.

@asifsharif,

You have attached a new set of input/output documents. Please also provide a comparison screenshot highlighting the problematic areas in Aspose.Words generated DOCX file with respect to your input HTML and attach it here for our reference. Thanks for your cooperation.

@awais.hafeez the document i shared earllier also contains this height issue but i attached new documents for clarification. I am attaching difference snapshots’ for both sets of inputs.

SetOne-Comparision.png (16.8 KB)

SetTwo-Comparision.png (38.6 KB)

“SetTwo-Comparision.png” this is the second set snapshot and “SetOne-Comparision.png” this is the snapshot which i shared in the first post.

Regards,
Asif.

@asifsharif,

For second set of documents, we used the following code on our end for testing:

Document doc = new Document("E:\\Smart Report of Cell Height\\Smart Report of Cell Height.html", new Aspose.Words.HtmlLoadOptions() { LoadFormat = LoadFormat.Html, Encoding = Encoding.UTF8 });
doc.Save("E:\\Smart Report of Cell Height\\19.2.docx");

We also converted your HTML to DOCX format by using MS Word 2019. In this case Aspose.Words for .NET 19.2 produces an output similar to what MS Word 2019 produces (see Comparison-Docs.zip (24.5 KB)). So, this seems to be an expected behavior. If we can help you with anything else, please feel free to ask.

Hi Owais.

After digging the issue down further there is an update to the scenario:

We use word templates “.dotx” to produce word documents. Please use following code to produce the scenario:

string filePath = @"[DirectoryName]:\Myhtmlfile.html";
string dotxFilePath = @"[DirectoryName]:\MyWordTemplate.dotx";
string docxFilePath = @"[DirectoryName]:\MyOutputWord.docx";

Document htmlDoc = new Document(filePath, new Aspose.Words.HtmlLoadOptions() {LoadFormat =LoadFormat.Html, Encoding = Encoding.UTF8});
Document templateDoc = new Document(dotxFilePath );

templateDoc .AppendDocument(htmlDoc, ImportFormatMode.UseDestinationStyles);
SaveOutputParameters param = templateDoc.Save(docxFilePath );

We executed scenarios on both version 19.2(latest one) and the version which we are using in our production environment. The results are different in both cases

18.11:
The cell height is too narrow in this case. See attached output document “18.11 without doc prop(34).docx” for reference

18.11 without doc prop(34).docx.zip (12.7 KB)

19.2:
The cell height is more than as shown in html. Please see previously uploaded files for reference

The html input file is same as previously given. Blank.dotx is also attached to produce the issue.

Blank.zip (9.6 KB)

Please note our clients use word 2013 and 2016 as their tool. Secondly, this is not an expected behaviour as converted word documents should be similar to html and as we can see that same word version shows different behaviours from different aspose versions.

Regards,
Asif.

@asifsharif,

Thanks for the additional information. We tested the scenario and now have managed to reproduce the same problem on our end by using the following code:

Document htmlDoc = new Document("E:\\18.11 without doc prop(34)\\Smart Report of Cell Height.html", new Aspose.Words.HtmlLoadOptions() { LoadFormat = LoadFormat.Html, Encoding = Encoding.UTF8 });
Document templateDoc = new Document("E:\\18.11 without doc prop(34)\\Blank.dotx");

templateDoc.AppendDocument(htmlDoc, ImportFormatMode.UseDestinationStyles);

SaveOutputParameters param = templateDoc.Save("E:\\18.11 without doc prop(34)\\19.2-AppendDocument.docx");

See attachment: test-docs.zip (25.3 KB)

For the sake of correction, we have logged this problem in our issue tracking system. The ID of this issue is WORDSNET-18200. We will further look into the details of this problem and will keep you updated on the status of correction. We apologize for your inconvenience.

@asifsharif,

Regarding WORDSNET-18200, we have completed the work on your issue and concluded to close this issue as ‘Not a Bug’. Please see the following analysis details:

Default paragraph formatting of the template document (SpaceAfter: 10pt; LineSpacing: 1.15) is different from paragraph formatting used when the HTML document is being loaded (SpaceAfter: 0; LineSpacing: 1). When imported text is inserted into the template document, its paragraph formatting changes according to defaults from the template. In order to avoid this effect, please do any of the following:

  • Either use ImportFormatMode.KeepSourceFormatting instead of ImportFormatMode.UseDestinationStyles when appending imported text to the template document.
  • Or use DocumentBuilder.InsertHtml with useBuilderFormatting=false to insert text into the template.

Please also see the following code:

DocumentBuilder builder = new DocumentBuilder(new Document("Blank.dotx"));

string html = File.ReadAllText("Smart Report of Cell Height.html", Encoding.UTF8);
builder.InsertHtml(html, false);

builder.Document.Save("out.docx");

Hope, this helps.

The issues you have found earlier (filed as WORDSNET-18175) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by mudassir.raza