1: | using System; | |
2: | using System.IO; | |
3: | ||
4: | using iTextSharp.text; | |
5: | using iTextSharp.text.pdf; | |
6: | ||
7: | namespace iTextSharp.tutorial.Chap10 | |
8: | { | |
9: | public class Chap1005 | |
10: | { | |
11: | ||
12: | public Chap1005() | |
13: | { | |
14: | ||
15: | Console.WriteLine("Chapter 10 example 5: Simple Columns"); | |
16: | ||
17: | // step 1: creation of a document-object | |
18: | Document document = new Document(); | |
19: | ||
20: | try | |
21: | { | |
22: | ||
23: | // step 2: | |
24: | // we create a writer that listens to the document | |
25: | // and directs a PDF-stream to a file | |
26: | PdfWriter writer = PdfWriter.GetInstance(document, new FileStream("Chap1005.pdf", FileMode.Create)); | |
27: | ||
28: | // step 3: we open the document | |
29: | document.Open(); | |
30: | ||
31: | // step 4: | |
32: | ||
33: | // we create some content | |
34: | BaseFont bf = BaseFont.CreateFont(BaseFont.COURIER, BaseFont.CP1252, BaseFont.NOT_EMBEDDED); | |
35: | Font font = new Font(bf, 11, Font.NORMAL); | |
36: | ||
37: | Phrase unicodes = new Phrase(15, "UNI\n", font); | |
38: | Phrase characters = new Phrase(15, "\n", font); | |
39: | Phrase names = new Phrase(15, "NAME\n", font); | |
40: | ||
41: | for (int i = 0; i < 27; i++) | |
42: | { | |
43: | unicodes.Add(uni[i] + "\n"); | |
44: | characters.Add(code[i] + "\n"); | |
45: | names.Add(name[i] + "\n"); | |
46: | } | |
47: | ||
48: | // we grab the ContentByte and do some stuff with it | |
49: | PdfContentByte cb = writer.DirectContent; | |
50: | ||
51: | ColumnText ct = new ColumnText(cb); | |
52: | ct.SetSimpleColumn(unicodes, 60, 300, 100, 300 + 28 * 15, 15, Element.ALIGN_CENTER); | |
53: | ct.Go(); | |
54: | cb.Rectangle(103, 295, 52, 8 + 28 * 15); | |
55: | cb.Stroke(); | |
56: | ct.SetSimpleColumn(characters, 105, 300, 150, 300 + 28 * 15, 15, Element.ALIGN_RIGHT); | |
57: | ct.Go(); | |
58: | ct.SetSimpleColumn(names, 160, 300, 500, 300 + 28 * 15, 15, Element.ALIGN_LEFT); | |
59: | ct.Go(); | |
60: | ||
61: | } | |
62: | catch(DocumentException de) | |
63: | { | |
64: | Console.Error.WriteLine(de.Message); | |
65: | } | |
66: | catch(IOException ioe) | |
67: | { | |
68: | Console.Error.WriteLine(ioe.Message); | |
69: | } | |
70: | ||
71: | // step 5: we close the document | |
72: | document.Close(); | |
73: | } | |
74: | ||
75: | public static String[] uni = new String[27]; | |
76: | public static String[] code = new String[27]; | |
77: | public static String[] name = new String[27]; | |
78: | ||
79: | static Chap1005() | |
80: | { | |
81: | uni[0]="\\u0152"; | |
82: | code[0]="\u0152"; | |
83: | name[0]="LATIN CAPITAL LIGATURE OE"; | |
84: | ||
85: | uni[1]="\\u0153"; | |
86: | code[1]="\u0153"; | |
87: | name[1]="LATIN SMALL LIGATURE OE"; | |
88: | ||
89: | uni[2]="\\u0160"; | |
90: | code[2]="\u0160"; | |
91: | name[2]="LATIN CAPITAL LETTER S WITH CARON"; | |
92: | ||
93: | uni[3]="\\u0161"; | |
94: | code[3]="\u0161"; | |
95: | name[3]="LATIN SMALL LETTER S WITH CARON"; | |
96: | ||
97: | uni[4]="\\u0178"; | |
98: | code[4]="\u0178"; | |
99: | name[4]="LATIN CAPITAL LETTER Y WITH DIAERESIS"; | |
100: | ||
101: | uni[5]="\\u017D"; | |
102: | code[5]="\u017D"; | |
103: | name[5]="LATIN CAPITAL LETTER Z WITH CARON"; | |
104: | ||
105: | uni[6]="\\u017E"; | |
106: | code[6]="\u017E"; | |
107: | name[6]="LATIN SMALL LETTER Z WITH CARON"; | |
108: | ||
109: | uni[7]="\\u0192"; | |
110: | code[7]="\u0192"; | |
111: | name[7]="LATIN SMALL LETTER F WITH HOOK"; | |
112: | ||
113: | uni[8]="\\u02C6"; | |
114: | code[8]="\u02C6"; | |
115: | name[8]="MODIFIER LETTER CIRCUMFLEX ACCENT"; | |
116: | ||
117: | uni[9]="\\u02DC"; | |
118: | code[9]="\u02DC"; | |
119: | name[9]="SMALL TILDE"; | |
120: | ||
121: | uni[10]="\\u2013"; | |
122: | code[10]="\u2013"; | |
123: | name[10]="EN DASH"; | |
124: | ||
125: | uni[11]="\\u2014"; | |
126: | code[11]="\u2014"; | |
127: | name[11]="EM DASH"; | |
128: | ||
129: | uni[12]="\\u2018"; | |
130: | code[12]="\u2018"; | |
131: | name[12]="LEFT SINGLE QUOTATION MARK"; | |
132: | ||
133: | uni[13]="\\u2019"; | |
134: | code[13]="\u2019"; | |
135: | name[13]="RIGHT SINGLE QUOTATION MARK"; | |
136: | ||
137: | uni[14]="\\u201A"; | |
138: | code[14]="\u201A"; | |
139: | name[14]="SINGLE LOW-9 QUOTATION MARK"; | |
140: | ||
141: | uni[15]="\\u201C"; | |
142: | code[15]="\u201C"; | |
143: | name[15]="LEFT DOUBLE QUOTATION MARK"; | |
144: | ||
145: | uni[16]="\\u201D"; | |
146: | code[16]="\u201D"; | |
147: | name[16]="RIGHT DOUBLE QUOTATION MARK"; | |
148: | ||
149: | uni[17]="\\u201E"; | |
150: | code[17]="\u201E"; | |
151: | name[17]="DOUBLE LOW-9 QUOTATION MARK"; | |
152: | ||
153: | uni[18]="\\u2020"; | |
154: | code[18]="\u2020"; | |
155: | name[18]="DAGGER"; | |
156: | ||
157: | uni[19]="\\u2021"; | |
158: | code[19]="\u2021"; | |
159: | name[19]="DOUBLE DAGGER"; | |
160: | ||
161: | uni[20]="\\u2022"; | |
162: | code[20]="\u2022"; | |
163: | name[20]="BULLET"; | |
164: | ||
165: | uni[21]="\\u2026"; | |
166: | code[21]="\u2026"; | |
167: | name[21]="HORIZONTAL ELLIPSIS"; | |
168: | ||
169: | uni[22]="\\u2030"; | |
170: | code[22]="\u2030"; | |
171: | name[22]="PER MILLE SIGN"; | |
172: | ||
173: | uni[23]="\\u2039"; | |
174: | code[23]="\u2039"; | |
175: | name[23]="SINGLE LEFT-POINTING ANGLE QUOTATION MARK"; | |
176: | ||
177: | uni[24]="\\u203A"; | |
178: | code[24]="\u203A"; | |
179: | name[24]="SINGLE RIGHT-POINTING ANGLE QUOTATION MARK"; | |
180: | ||
181: | uni[25]="\\u20AC"; | |
182: | code[25]="\u20AC"; | |
183: | name[25]="EURO SIGN"; | |
184: | ||
185: | uni[26]="\\u2122"; | |
186: | code[26]="\u2122"; | |
187: | name[26]="TRADE MARK SIGN"; | |
188: | } | |
189: | } | |
190: | } |