Table doesn't use the entire page width

Hi Team,

When I set page size to 6000 and have 35 columns in a table, only part of the page width is being used. I tested this in Aspose.Words For Java 15.6. However, if I go back and use Aspose 13.5, table uses the entire page width. See attached documents from both the versions.

You could use the standalone code below to replicate the issue.

Thanks,
Kumar

public static void main(String[] args) throws Exception
{
TestAsposeUtils.setupLicense(TestAsposeUtils.lICENSE_FILE_PATH);

Document doc = new Document();
DocumentBuilder docBuilder = new DocumentBuilder(doc);

// set page width
docBuilder.getCurrentSection().getPageSetup().setPageWidth(6000);

addWideTable(docBuilder);

// doc.updateFields();
// doc.updatePageLayout();

String baseFolder = System.getProperty("java.io.tmpdir");
String unique = UUID.randomUUID().toString().replaceAll(" ", "_");
String docpath = baseFolder + "test_" + unique + "_" + BuildVersionInfo.getVersion(); //$NON-NLS-1$ //$NON-NLS-2$
doc.save(docpath + ".pdf"); //$NON-NLS-1$
System.out.println(docpath + ".pdf");
}

private static void addWideTable(DocumentBuilder docBuilder) throws Exception
{
Table table = docBuilder.startTable();
int numOfRows = 3;
int numOfColumns = 35;

// number of rows
for (int i = 0; i < numOfRows; i++)
{
// number of columns
for (int j = 0; j < numOfColumns; j++)
{
docBuilder.insertCell();
docBuilder.write(". Row " + i + " column " + j + " .");
}
docBuilder.endRow();
}

docBuilder.endTable();
table.setPreferredWidth(PreferredWidth.fromPercent(100));
table.setAllowAutoFit(true);
}

Hi Kumar,


Thanks for your inquiry. First off, please upgrade to the latest version 15.8.0 from the following link:
http://www.aspose.com/community/files/72/java-components/aspose.words-for-java/default.aspx

Secondly, in this case, calling Document.UpdateTableLayout method before saving to PDF fixes this issue.

Best regards,

Hi Awais,


Does upgrading to Aspose 15.8 fix the solution?

We’ve had issues with updateTableLayout and updatePageLayout earlier with respect to functionality and performance. We’ve an open enterprise ticket for the same - 518748- updateTableLayout() for PDF output using Aspose.Words

I’m looking for a better solution.

Thanks,
Kumar

Hi Kumar,


Thanks for your inquiry. The issue is fixed when you use 15.8.0 AND Document.UpdateTableLayout method.

However, we have logged the issue you reported here in this thread in our issue tracking system. The ID of this issue is WORDSNET-12477. Your thread has been linked to this issue and you will be notified as soon as it is resolved. Sorry for the inconvenience.

Best regards,

Hi Awais,

Any update on this defect?

Regards,
Kumar

Hi Kumar,

Thanks for your inquiry.

Unfortunately, your issue is not resolved yet. The issue occurs because Aspose.Words currently restricts the maximum table width to imitate MS Word behavior. If the document is saved to a flow format such as Docx, MS Word restricts the table width as well. Your code has stopped working as intended in 13.9.0. We introduced a check during document validation to set the table size to "MaxSizeTwip" and resize the cells. So, Aspose.Words currently works as designed, but unfortunately your scenario is broken.

We believe that 1584 pt is the maximum size in MS Word because in twips it gets really close to short int maximum. That is, probably, how MS Word stores this value (inherited from earlier versions). We do not think we shall allow sizes above this limit. If you want big tables, etc, why not scale everything down? Use font of 3 pt size, etc.?

Best regards,

Hi Awais,

In the pdf output, I see lots of space available since the width is set to 6000. This space must be utilized. See the attached snapshot.

Thanks,
Akash

Hi Akash,


We have passed these details to our product team and will update you as soon as there is more information available.

Best regards,

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


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

Hi Team,

The notification states that

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

But I can still see the issue persist with the latest Aspose Version 17.7.1.
Could you please look into this ?

Thanks
Tejashree

@tejashreegupta,

Thanks for your inquiry. After an initial test with Aspose.Words 17.8, we were unable to reproduce this issue on our end. We would suggest you please upgrade to the latest version of Aspose.Words. You can download it from the following link:

We have also created a separate thread for you. In case you still face this issue, please follow the other thread for further proceedings.

Best regards,