| 1: | using System; | |
| 2: | using System.IO; | |
| 3: | ||
| 4: | using iTextSharp.text; | |
| 5: | using iTextSharp.text.pdf; | |
| 6: | using iTextSharp.text.xml; | |
| 7: | ||
| 8: | namespace iTextSharp.tutorial.Chap07 | |
| 9: | { | |
| 10: | /// <summary> | |
| 11: | /// Custom Tags | |
| 12: | /// </summary> | |
| 13: | public class Chap0703 | |
| 14: | { | |
| 15: | ||
| 16: | public Chap0703() | |
| 17: | { | |
| 18: | ||
| 19: | Console.WriteLine("Chapter 7 example 3: parsing an XML document with custom tags"); | |
| 20: | ||
| 21: | // step 1: creation of a document-object | |
| 22: | Document document = new Document(PageSize.A4, 80, 50, 30, 65); | |
| 23: | ||
| 24: | try | |
| 25: | { | |
| 26: | ||
| 27: | // step 2: | |
| 28: | // we create a writer that listens to the document | |
| 29: | // and directs a XML-stream to a file | |
| 30: | PdfWriter.GetInstance(document, new FileStream("Chap0703.pdf", FileMode.Create)); | |
| 31: | ||
| 32: | // step 3: we create a parser and set the document handler | |
| 33: | ||
| 34: | ITextmyHandler h = new ITextmyHandler(document, new TagMap("tagmap0703.xml")); | |
| 35: | ||
| 36: | // step 4: we parse the document | |
| 37: | h.Parse("Chap0703.xml"); | |
| 38: | ||
| 39: | } | |
| 40: | catch(Exception e) | |
| 41: | { | |
| 42: | Console.Error.WriteLine(e.StackTrace); | |
| 43: | Console.Error.WriteLine(e.Message); | |
| 44: | } | |
| 45: | } | |
| 46: | } | |
| 47: | } |