We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Tables in Office 2013 100% width not correct

Dear,


for Word 2013 Documents (see attachments) a simple table having a width of 100% can cause issues. Only tables that have ‘default cell margins’ of 0 are rendered in the correct position with the correct width. When this cell margin is the default value of 0.19 cm, the tables are not rendered correctly (see PDF).

I have already attempted to use doc.updateTableLayout(); as suggested in another post, this does not help.

Regards

Hi there,

Thanks for your inquiry. Perhaps, you are using an older version of Aspose.Words; as with Aspose.Words v14.6.0, I am unable to reproduce this problem on my side. I would suggest you please upgrade to the latest version of Aspose.Words i.e. v14.6.0 and let us know how it goes on your side. I have attached the output Pdf file with this post for your kind reference.

I suggest you please use CompatibilityOptions.optimizeFor method as shown below to get the required output. Please let us know if you have any more queries.


Document doc = new Document(MyDir + "table_bug.docx");

doc.getCompatibilityOptions().optimizeFor(MsWordVersion.WORD_2013);

doc.save(MyDir + "Out.pdf");

Dear,


the problem is indeed not reproducible for the example I gave in the previous post. However, once a table is given a preferred percentage (100%) and at least one cell has a preferred width of 60%, the issue is visible. Using the latest version 14.6.0. See attached input and output file. The table should end where the text ends on the right.

Regards

Hi there,

Thanks for your inquiry. I have tested the scenario using following code example and have not found the shared issue. I have attached the output Pdf file with this post for your kind reference.


Document doc = new Document(MyDir + "table_100%.docx");

doc.getCompatibilityOptions().optimizeFor(MsWordVersion.WORD_2013);

doc.save(MyDir + “Out.pdf”);

Could you please share the following detail for investigation purposes?

What environment are you running on?

  • OS (Windows Version or Linux Version)
  • Architecture (32 / 64 bit)
  • Java version


Dear,


this is my code:

Document doc = new Document(docxFile);
doc.getCompatibilityOptions().optimizeFor( MsWordVersion.WORD_2013);
doc.updateTableLayout();
PdfSaveOptions opts = new PdfSaveOptions();
opts.setJpegQuality(90);
doc.save(outputFilePath, opts);

I also need to run the updateTableLayout, otherwise the tables (in most other cases) do not follow the preferred widths, but rather each column takes only the width of the content. So without updateTableLayout, the preferred table width (100%) is ignored. With it the width is overestimated.

Regards

PS: I’m getting this issue on 64-bit machines both on Windows and Linux (as one would expect with Java :-). Using JDK 1.7. I believe the implementation of the updateTableLayout must be at fault here, but only when combined with the Word_2013 preference. When indicating an older Word version, the table width is the same as it would be in older Words (<=2010) (with ends sticking out on both ends in regards to the flowing text).


Regards

Hi there,

Thanks for sharing the detail. 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.

Regarding your issue, I have managed to reproduce the same issue at my side. For the sake of correction, I have logged this problem in our issue tracking system as WORDSNET-10453. I have linked this forum thread to the same issue and you will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

Hi there,

Thanks for your patience.

It is to inform you that our development team has completed the work on the issue (WORDSNET-10453)
and has come to a conclusion that this issue and the undesired behavior
you’re observing is actually not a bug in Aspose.Words. So, we have
closed this issue as ‘Not a Bug’.

Your issue is related to missing feature WORDSNET-832 (Make table layout as close to Word as possible). I have linked this forum thread to the same feature request. We will update you via this forum thread once this feature is available.

We apologize for your inconvenience.