Hi ,
I need to fix width of a particular column in a table.
builder.insertCell();
table.setStyleIdentifier(StyleIdentifier.TABLE_GRID);
builder.getFont().setBold(true);
builder.getCellFormat().setWidth(70);
I am trying to use the above code to do the same, but cannot achieve it.
Hi ,
I have to create a table in which i should have the width of first column fixed , rest should be based on the data assigned.
the text should be LEFT aligned.
Can you suggest me how to do this.
Hi Shilpa,
Please try using the following code:
<pre style=“background-color: rgb(255, 255, 255); font-family: “Courier New”; font-size: 9pt;”>Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
Table tab = builder.startTable();
builder.insertCell();
CellFormat cellFormat = builder.getCellFormat();
cellFormat.setWidth(72);
builder.writeln(“First”);
builder.insertCell();
cellFormat.setWidth(144);
builder.writeln(“second”);
builder.endRow();
builder.insertCell();
cellFormat = builder.getCellFormat();
cellFormat.setWidth(144);
builder.writeln(“third”);
builder.insertCell();
cellFormat.setWidth(72);
builder.writeln(“Fourth”);
builder.endRow();
builder.endTable();
tab.setAllowAutoFit(true);
tab.autoFit(AutoFitBehavior.FIXED_COLUMN_WIDTHS);
doc.save(“D:\temp\awjava-16.12.0.pdf”);
Best regards,