Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
118 views
in Technique[技术] by (71.8m points)

c# - Can I replicate the table header when a table keep on in more pages?

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.

For example if a table begin in the page 1 and keep on in the table 2 I want have the following situation:

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.

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);

If you want the C# version of the examples taken from my book, you can find them here: http://tinyurl.com/itextsharpIIA2C04

These examples show you that the syntax in C# is slightly different, but still easy:

table.HeaderRows = 1;

In this line, we tell the table that the first row is a header row that should be repeated.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...