| 1: | using System; | |
| 2: | using System.IO; | |
| 3: | ||
| 4: | using iTextSharp.text; | |
| 5: | using iTextSharp.text.pdf; | |
| 6: | ||
| 7: | namespace iTextSharp.tutorial.Chap09 | |
| 8: | { | |
| 9: | /// <summary> | |
| 10: | /// True Types (embedded) | |
| 11: | /// </summary> | |
| 12: | public class Chap0903 | |
| 13: | { | |
| 14: | public Chap0903() | |
| 15: | { | |
| 16: | ||
| 17: | Console.WriteLine("Chapter 9 example 3: True Types (embedded)"); | |
| 18: | ||
| 19: | // step 1: creation of a document-object | |
| 20: | Document document = new Document(); | |
| 21: | ||
| 22: | try | |
| 23: | { | |
| 24: | ||
| 25: | // step 2: | |
| 26: | // we create a writer that listens to the document | |
| 27: | // and directs a PDF-stream to a file | |
| 28: | PdfWriter.GetInstance(document, new FileStream("Chap0903.pdf", FileMode.Create)); | |
| 29: | ||
| 30: | // step 3: we open the document | |
| 31: | document.Open(); | |
| 32: | ||
| 33: | // step 4: we add content to the document | |
| 34: | BaseFont bfComic = BaseFont.CreateFont("c:\\winnt\\fonts\\comic.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED); | |
| 35: | Font font = new Font(bfComic, 12); | |
| 36: | String text1 = "This is the quite popular True Type font 'Comic'."; | |
| 37: | String text2 = "Some greek characters: \u0393\u0394\u03b6"; | |
| 38: | String text3 = "Some cyrillic characters: \u0418\u044f"; | |
| 39: | document.Add(new Paragraph(text1, font)); | |
| 40: | document.Add(new Paragraph(text2, font)); | |
| 41: | document.Add(new Paragraph(text3, font)); | |
| 42: | } | |
| 43: | catch(DocumentException de) | |
| 44: | { | |
| 45: | Console.Error.WriteLine(de.Message); | |
| 46: | } | |
| 47: | catch(IOException ioe) | |
| 48: | { | |
| 49: | Console.Error.WriteLine(ioe.Message); | |
| 50: | } | |
| 51: | ||
| 52: | // step 5: we close the document | |
| 53: | document.Close(); | |
| 54: | } | |
| 55: | } | |
| 56: | } |