1: | using System; | |
2: | using System.IO; | |
3: | ||
4: | using iTextSharp.text; | |
5: | using iTextSharp.text.pdf; | |
6: | ||
7: | ||
8: | namespace iTextSharp.tutorial.Chap11 | |
9: | { | |
10: | /// <summary> | |
11: | /// Chap1111 ժҪ˵ | |
12: | /// </summary> | |
13: | public class Chap1111 | |
14: | { | |
15: | public Chap1111() | |
16: | { | |
17: | Console.WriteLine("Chapter 11 example 11: page labels"); | |
18: | ||
19: | // step 1: creation of a document-object | |
20: | Document document = new Document(PageSize.A4, 50, 50, 50, 50); | |
21: | try { | |
22: | // step 2: | |
23: | // we create a writer that listens to the document | |
24: | PdfWriter writer = PdfWriter.GetInstance(document, new FileStream("Chap1111.pdf", FileMode.Create)); | |
25: | // step 3: we open the document | |
26: | document.Open(); | |
27: | // step 4: | |
28: | // we add some content | |
29: | for (int k = 1; k <= 10; ++k) { | |
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(DocumentException de) | |
40: | { | |
41: | Console.Error.WriteLine(de.Message); | |
42: | } | |
43: | catch(IOException ioe) | |
44: | { | |
45: | Console.Error.WriteLine(ioe.Message); | |
46: | } | |
47: | ||
48: | // step 5: we close the document | |
49: | document.Close(); | |
50: | } | |
51: | } | |
52: | } |