Add rectangle into pdfpcell itextsharp

半腔热情 提交于 2019-12-06 07:09:15
Bruno Lowagie

The simple answer is: draw the Rectangle as a Form XObject (PdfTemplate), wrap it inside an Image object, and add that image to the table.

However: there are several ways to do this, and there may be only one way that results in the desired output. That's why I've made you an example: rectangle_in_cell.pdf

Take a close look at this PDF. In the top margin you see a line that measures 120 pt in length. In the different tables, you see three rectangles that were created as a rectangle measuring 120 by 80 pt. Only one rectangle seems to have the correct size.

When adding objects to a table, iText often resizes the content to make it fit into a cell. The RectangleInCell example shows you the differences in code between the three approaches. It's written in Java, but I'm sure you'll be able to adapt it to C#.

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