1: | using System; | |
2: | using System.IO; | |
3: | using System.Diagnostics; | |
4: | ||
5: | using iTextSharp.text; | |
6: | using iTextSharp.text.pdf; | |
7: | ||
8: | ||
9: | namespace iTextSharp.tutorial.Chap01 | |
10: | { | |
11: | /// <summary> | |
12: | /// Most these pageSizes are in PORTRAIT-format. If you want them to be in LANDSCAPE, all you have to do is rotate() the Rectangle: | |
13: | /// </summary> | |
14: | public class Chap0103 | |
15: | { | |
16: | public Chap0103() | |
17: | { | |
18: | Console.WriteLine("Chapter 1 example 3: PageSize"); | |
19: | ||
20: | // step 1: creation of a document-object | |
21: | Document document = new Document(PageSize.A4.Rotate()); | |
22: | ||
23: | try | |
24: | { | |
25: | ||
26: | // step 2: | |
27: | // we create a writer that listens to the document | |
28: | // and directs a PDF-stream to a file | |
29: | ||
30: | PdfWriter.GetInstance(document, new FileStream("Chap0103.pdf", FileMode.Create)); | |
31: | ||
32: | // step 3: we open the document | |
33: | document.Open(); | |
34: | ||
35: | // step 4: we add some phrases to the document | |
36: | for (int i = 0; i < 20; i++) | |
37: | { | |
38: | document.Add(new Phrase("Hello World, Hello Sun, Hello Moon, Hello Stars, Hello Sea, Hello Land, Hello People. ")); | |
39: | } | |
40: | ||
41: | } | |
42: | catch(DocumentException de) | |
43: | { | |
44: | Console.Error.WriteLine(de.Message); | |
45: | } | |
46: | catch(IOException ioe) | |
47: | { | |
48: | Console.Error.WriteLine(ioe.Message); | |
49: | } | |
50: | ||
51: | // step 5: we close the document | |
52: | document.Close(); | |
53: | ||
54: | } | |
55: | } | |
56: | } |