Blog

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