How to change width of single column of a table?

2019-08-14 14:42发布

问题:

hello I have created table in PDF file using Itext library heading of my table columns are Medicine Name, Doses, time

My problem is: this is how my columns look like:

|Medicin|Doses|time|
| e name|     |    |

as you can see e falls in new line I have tried many things but cant figure out how to arrange my columns like :

|Medicine|Doses|time|
|  name  |     |    |

回答1:

The ColumnWidths example demonstrates different ways of changing the width of a column. This is one specific way:

PdfPTable table = new PdfPTable(3);
table.setWidths(new int[]{2, 1, 1});

Now the width of the first column is double the size of the second and third column. See the complete example for other ways to change the widths of columns.