Setting 100% table width

Hi ,


I am using licensed Aspose 11.0.0 java

I want to set the table width as 100%.
Meaning the table should have the width of the container.

I want this feature as the container width is changing dynamically by user.

I cannot propagate the container width to the table.

Can you please point me in a direction.


Hi there,


Thanks for your inquiry. Yes you can set column widths in % to accommodate your table in the Page as following. Hopefully it will help you to accomplish the task.

com.aspose.pdf.Table table = new
com.aspose.pdf.Table();
<o:p></o:p>

table.setColumnWidths("30% 70%");


Please feel free to contact us for any further assistance.

Best Regards,

Hi,


Thanks for the reply.
The solution works fine.

There was a extra table due to which the 100% width was not getting applied.
It was taking 100% width of default 100 width.

Thanks again.

Hi there,


Thanks for your feedback. It is good to know that suggestion worked for you.

Please keep using Aspose.Pdf and feel free to contact us for any question or concern, we will be more than happy to extend our support.

Best Regards,

Hi,

sorry for reopening this question, but I would like to notify you of something.
I have 3 tables under each other, touching, so there’s no space between them.
First table has one 100% column, Second has five columns and the Third has two (each has default column widths set as percentages)

The problem is, that the cells have borders, and these are added to the whole width of my tables, so on the right side, the five-column table is a few pixels wider than the others. They should all be the same width, because the sum of the DefaultColumnWidths is always 100%

No rush, I solved this somehow. I added a sixth column with no border and set its width to 0.3% (lowered the fifth to 11.7%)
Just saying, it would be better to include the cell borders to the column width.

Thanks for your good work.

@empee

Thanks for posting your inquiry.

The reason of this behavior was that, API was adding width of the border into total width of the table. In order to avoid that, Aspose.Pdf offers a Boolean property (i.e Table.IsBordersIncluded), which can be specified during PDF generation process to tell API whether border width should be included with total width of table or not.

You may please set above mentioned property in order to resolve the issue and in case issue still occurs, please share your sample PDF document along with working code snippet, so that we can test the scenario in our environment and address it accordingly.

It would be great if IsBordersIncluded defaulted to true, since that’s probably the expected behavior for a majority of use cases. If there’s a reason to keep it as-is, I’d love to know.

@canonmc

We need to check the technical background and history of this property at our end. We will collect related information and let you know soon.

@canonmc

There isn’t any specific reason and we have logged a feature request as PDFNET-58565 in our issue tracking system to make it true by default. As soon as the ticket is resolved, we will inform you. Please spare us some time.

1 Like

Thank you very much. No rush