当表格保留在更多页面中时,可以复制表格标题吗? [英] Can I replicate the table header when a table keep on in more pages?
问题描述
在以下情况下,使用iTextSharp创建PDF.
I have the following situation creating a PDF with iTextSharp.
我有一些页面包含一些表格.表格可能会在页面中开始并在下一页中继续显示.
I have some pages that contains some tables. It could be happen that a table begin in a page and keep on in the following page.
我想知道在下一页中保留表格时,是否可以在新页面中复制"表格标题.
I want to know if, when a table keep on in the following page, is it possible to "replicate" the table header in the new page.
例如,如果一个表从第1页开始,并保持在表2中,则我希望出现以下情况:
For example if a table begin in the page 1 and keep on in the table 2 I want have the following situation:
该表从其页眉在第1页开始,并在第2页继续,因此在第2页的开头,我又有了该表头. Microsoft Word中的表会发生类似的情况.
The table begin with its header in page 1 and keep on in page 2 so at the beginning of page 2 I have again the table header. Something like happen with table in Microsoft Word.
我可以做类似的事情吗?
Can I do something like it?
Tnx
推荐答案
您要的是所谓的重复表头".您可以在官方iText网站的页面上找到一些关键字 PdfPTable>标头行<的示例. /a>.
You are asking for something called "repeating table headers". You can find some examples on the official iText site on the page for the keyword PdfPTable > header rows.
例如,如果您有一个名为table
的PdfPTable
实例,并且您一直添加的前两行实际上是标头,则可以将它们定义为标头行,如下所示:
For instance, if you have an instance of PdfPTable
named table
, and the first two rows you've been adding are actually the header, then you can define them as header rows like this:
table.setHeaderRows(2);
如果您想从我的书中获取示例的C#版本,可以在此处: http://tinyurl.com/itextsharpIIA2C04
If you want the C# version of the examples taken from my book, you can find them here: http://tinyurl.com/itextsharpIIA2C04
这些示例向您展示C#的语法略有不同,但仍然很简单:
These examples show you that the syntax in C# is slightly different, but still easy:
table.HeaderRows = 1;
在这一行中,我们告诉table
第一行是应该重复的标题行.
In this line, we tell the table
that the first row is a header row that should be repeated.
这篇关于当表格保留在更多页面中时,可以复制表格标题吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!