tags:

views:

36

answers:

1

I need to set page numbers on a pdf I'm creating, so that the first 3 pages would be i,ii,iii and then the following pages starting from 1,2,3,4,5...and so on..

How can i do it with itextsharp?? Thanks Sander

A: 

Check out the example in Massoud Mazar's blog. Look at his override for the OnEndPage event in the TwoColumnHeaderFooter class and see how he prints out page numbers.

What you can do is examine the event's PdfWriter parameter's PageNumber property and custom set the string you'll use for the displayed page number.

Something like this:

String text = "";
int pageN = writer.PageNumber;
if (pageN == 1) {
    text = "i";
} else if (pageN == 2) {
    text = "ii";
} else if (pageN == 3) {
    text = "iii";
} else {
    text = (pageN - 3).ToString();
}

Would replace his original:

String text = "Page " + pageN + " of ";
Jay Riggs