| 1: | using System; | |
| 2: | using System.IO; | |
| 3: | ||
| 4: | using iTextSharp.text; | |
| 5: | using iTextSharp.text.pdf; | |
| 6: | ||
| 7: | namespace iTextSharp.tutorial.Chap11 | |
| 8: | { | |
| 9: | public class Chap1110 | |
| 10: | { | |
| 11: | ||
| 12: | public Chap1110() | |
| 13: | { | |
| 14: | ||
| 15: | Console.WriteLine("Chapter 11 example 10: page labels"); | |
| 16: | ||
| 17: | // step 1: creation of a document-object | |
| 18: | Document document = new Document(PageSize.A4, 50, 50, 50, 50); | |
| 19: | try | |
| 20: | { | |
| 21: | // step 2: | |
| 22: | // we create a writer that listens to the document | |
| 23: | PdfWriter writer = PdfWriter.GetInstance(document, new FileStream("Chap1110.pdf", FileMode.Create)); | |
| 24: | // step 3: we open the document | |
| 25: | document.Open(); | |
| 26: | // step 4: | |
| 27: | // we add some content | |
| 28: | for (int k = 1; k <= 10; ++k) | |
| 29: | { | |
| 30: | document.Add(new Paragraph("This document has the logical page numbers: i,ii,iii,iv,1,2,3,A-8,A-9,A-10\nReal page " + k)); | |
| 31: | document.NewPage(); | |
| 32: | } | |
| 33: | PdfPageLabels pageLabels = new PdfPageLabels(); | |
| 34: | pageLabels.AddPageLabel(1, PdfPageLabels.LOWERCASE_ROMAN_NUMERALS); | |
| 35: | pageLabels.AddPageLabel(5, PdfPageLabels.DECIMAL_ARABIC_NUMERALS); | |
| 36: | pageLabels.AddPageLabel(8, PdfPageLabels.DECIMAL_ARABIC_NUMERALS, "A-", 8); | |
| 37: | writer.PageLabels = pageLabels; | |
| 38: | } | |
| 39: | catch (Exception de) | |
| 40: | { | |
| 41: | Console.Error.WriteLine(de.Message); | |
| 42: | Console.Error.WriteLine(de.StackTrace); | |
| 43: | } | |
| 44: | ||
| 45: | // step 5: we close the document | |
| 46: | document.Close(); | |
| 47: | } | |
| 48: | } | |
| 49: | } |