开发者

itextSharp: Table disappears when added to Paragraph with KeepTogether=true

I am exporting some data to a PDF and I have been using iTextSharp with a lot of success, but I just hit a wall.

I have a group of information I need to keep on a single page. This information includes a handful of other Paragraph obj开发者_高级运维ects and tables. I can add 3 Paragraphs to another parent Paragraph and set that parent's KeepTogether property to true and everything works great.

When I add a PdfPTable to the Paragraph with KeepTogether set to true, the table disappears. No Exceptions or error messages, the table just disappears.

Any clue as to what is happening? Is there a work around? Should I be coding differently, like is there a better parent control than Paragraph to keep text and tables together on one page?


So I fixed the issue by approaching it a different way. Now I make sure to never set a KeepTogether property to true for paragraphs or tables.

Then, when I want a Paragraph that contains child paragraphs and PdfPTables, I add it to a one column, one cell, PdfPTable with its KeepTogether flag set to true.

So that works perfectly, just a little dirty.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜