1

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  |     |    |
Bruno Lowagie
  • 75,994
  • 9
  • 109
  • 165
DCoder
  • 3,486
  • 7
  • 36
  • 68
  • Did you try changing the widths of the column? That's not clear from your question. The different columns already like to have a different width in your example. – Bruno Lowagie Jun 10 '14 at 13:19
  • there is no option to set width of column explicitly in Itext library. space is divided equally in total no of columns. – DCoder Jun 10 '14 at 13:22
  • I'm the original developer of iText and the author of the iText books. I know for a fact that there's more than one way to set the width of columns in iText ;-) – Bruno Lowagie Jun 10 '14 at 13:27
  • ohhh... My apology. iText is awesome.. actually for whole time I was working on cell. – DCoder Jun 10 '14 at 13:34
  • No problem. See the smiley I added ;-) – Bruno Lowagie Jun 10 '14 at 14:41

1 Answers1

3

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.

Bruno Lowagie
  • 75,994
  • 9
  • 109
  • 165