Auto Split Columns using iTextSharp

让人想犯罪 __ 提交于 2019-12-04 02:41:16

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/20042287/auto-split-columns-using-itextsharp

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!