我正在开发一个自动生成发票的程序。我想始终在特定位置添加表格(例如,在底角处,或稍微向左)。
PdfContentByte cb = writer.DirectContent;
PdfPTable table = new PdfPTable(1);
table.TotalWidth = 400f;
table.AddCell("Test");
table.WriteSelectedRows(0, -1, 200, 50, cb);
我在Google上获得了上述代码。但是我不明白如何使用WriteSelectedRows
以及括号中的每个数字的含义。
我希望输出代码能够将表格放置在页面上任何想要的位置。
值的平均值,according to the documentation:
通过使用rowStart = 0和rowEnd = -1,表示您要写入所有行。之后的参数表示渲染表格的绝对位置,在您的情况下,是从左侧200像素,从顶部50像素。
另请参见:*itextsharp: what is the height of a regular PDF page in pixels?* How to give an absolute position to a table in iTextsharp