Aspose tag length affects HTML table column width

Table Column width is incorrect when generating DOC from HTML. For some reason column width depends on Aspose tag length. For example, if you have <td><<[name]>></td> than column will be small. But if you have <td><<[someLongNameGoesHere]>></td> the column width will suddenly become too wide. This is also true when accessing properties hierarchy using dot notation like <td><<[object.property.subproperty.andMore]>></td>

I suspect Aspose tries to fit tag into column, and probably it should instead try to fit output of the tag into column.

It is not always possible to make names very short. Would be good if Aspose could set column width based on real text being inserted into template.

Java sample attached. It creates two documents that contain a table. Table columns have predefined width. All columns respect width, except for one that contains Aspose tag. The only difference between those documents is Aspose tag length.

fieldNameIsLong.doc shows what is being generated when Aspose tag is long. Column that holds text “BMW” is very wide, eating up space for other columns.
fieldNameIsShort.doc shows what is being generated when Aspose tag is short. Column that holds text “BMW” is OK.

Expected output: fieldNameIsLong.doc has 2nd column width 10%, because text “BMW” fits into such width. Column 2 is expected to be the same width as columns 1 and 3.

HtmlWidth.zip (28.8 KB)

Note: i had to remove aspose jar from attachment because it was not possible to upload 12Mb. So please put “aspose-words-19.4-jdk17.jar” into sample’s “lib” folder.

@zuzuzu

We have not found any issue with the shared output documents (fieldNameIsShort.doc and fieldNameIsLong.doc). MS Word 2016 shows the correct width of table’s cell that is 10%. Please check the following image for detail.

https://i.imgur.com/q6rnfgo.png

My bad, was opening doc files in LibreOffice Word. Sorry. Probably MS Word performs auto-resize on load.

Fixed sample project to generate PDF files intead of DOC so that you could see the issue. Updated sources attached.

HtmlWidth.zip (61.3 KB)

@zuzuzu

We have tested the scenario and have managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as WORDSNET-18659. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

@zuzuzu

As a workaround of this issue, please use the DOCX report template with a table without cell spacing. Hope this helps you.

Thank you for quick replies and for a suggestion. I’m afraid this wouldn’t work as our users create templates in online html editor. So will wait for update.

@zuzuzu

We regret to share with you that the issue (WORDSNET-18659) has been postponed due to missing feature WORDSNET-832 ( Make table layout as close to Word as possible ) which is related to it.

After the fix of WORDSNET-832, we will look into this issue. We will be sure to inform you via this forum thread as soon as this feature is available. We apologize for your inconvenience.

The issues you have found earlier (filed as WORDSNET-18659) have been fixed in this Aspose.Words for Java 23.8 update.