user3003722
user3003722

Reputation: 3

Auto Split Columns using iTextSharp

I have a grid that need to be exported to PDF, grid has 28 columns. I am using iText to write the pdf. Issue -Itext is writting only 13 columns rest columns are not coming in PDF.

Page Size is set as A4.Rotate().

Is there any way that remaining columns can be auto written on next page?

Upvotes: 0

Views: 1533

Answers (1)

Chris Haas
Chris Haas

Reputation: 55427

iText will split a table at rows but not at columns. If you want to do that you'll have to do it manually. PdfPTable has a method called WriteSelectedRows() that allows you to specify an X,Y coordinate to draw a given range of rows and columns to. To do that you'll probably need to know the width/height of the table, see the post here for an example of how to do it.

The other way, which is a little weirder but more obvious and less error prone, would be to just make extra tables. Table 1 has 13 columns, Table 2 has 10 columns and Table 3 has 5 columns (or whatever works for your data). At the end of the day, the result is pretty much the same but you also get automatic table headers and row splitting and you don't have to calculate widths and/or heights.

Upvotes: 2

Related Questions