| 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 Chap1009 | |
| 10: | { | |
| 11: | ||
| 12: | public Chap1009() | |
| 13: | { | |
| 14: | Console.WriteLine("Chapter 10 example 9: a PdfPTable at an absolute position"); | |
| 15: | ||
| 16: | // step 1: creation of a document-object | |
| 17: | Document document = new Document(PageSize.A4, 50, 50, 50, 50); | |
| 18: | try | |
| 19: | { | |
| 20: | // step 2: we create a writer that listens to the document | |
| 21: | PdfWriter writer = PdfWriter.GetInstance(document, new FileStream("Chap1009.pdf", FileMode.Create)); | |
| 22: | // step 3: we open the document | |
| 23: | document.Open(); | |
| 24: | // step 4: we add some content | |
| 25: | PdfPTable table = new PdfPTable(4); | |
| 26: | table.DefaultCell.Border = Rectangle.LEFT_BORDER | Rectangle.RIGHT_BORDER; | |
| 27: | for (int k = 0; k < 24; ++k) | |
| 28: | { | |
| 29: | table.AddCell("cell " + k); | |
| 30: | } | |
| 31: | table.TotalWidth = 300; | |
| 32: | table.WriteSelectedRows(0, -1, 100, 600, writer.DirectContent); | |
| 33: | // step 5: we close the document | |
| 34: | document.Close(); | |
| 35: | } | |
| 36: | catch (Exception de) | |
| 37: | { | |
| 38: | Console.WriteLine(de.Message); | |
| 39: | Console.WriteLine(de.StackTrace); | |
| 40: | } | |
| 41: | } | |
| 42: | } | |
| 43: | } |