Reputation: 41
I am having problems setting relative column widths for a table in iText 7.0.4. I tried Bruno's example code from here: https://stackoverflow.com/a/41428692/8804951. If I execute the example with iText 7.0.1 I get exactly the result from Bruno's answer:
but for later versions the result looks like this:
The original example on the iText web page does not seem to reflect this change in behaviour yet.
Upvotes: 1
Views: 584
Reputation: 341
This worked for me for setting the column width in itext-7.1.3 ., you can try this.
Table content = new Table(UnitValue.createPercentArray(new float[]{3,5,10}));
content.setWidth(UnitValue.createPercentValue(100));
content.setFixedLayout();
Upvotes: 1
Reputation: 41
The table layout algoritm changed in version 7.0.2 as is stated in the API docs (http://itextsupport.com/apidocs/itext7/latest/com/itextpdf/layout/element/Table.html#Table-float:A-boolean-). The simplest solution is to add a second parameter with the value true
to the constructor of Table
:
Table htable = new Table(new float[] {3, 8, 5, 10, 5, 10, 30}, true);
The one-parameter version of the constructor now takes absolute column widths in points.
Upvotes: 0