/*/* * This code is free software. It may only be copied or modified * if you include the following copyright notice: * * --> Copyright 2000, 2001 by Bruno Lowagie <-- * --> Copyright 2004 by Kazuya Ujihara <-- * * This code is example code of 'iText .NET'. * See http://www.ujihara.jp/iTextdotNET/examples.html * * This code is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ using System; using com.lowagie.text; using com.lowagie.text.pdf; using System.IO; using GDI=System.Drawing; public class Chap0506 { public static void Main(String[] args) { Console.WriteLine("Chapter 5 example 6: spacing, padding, alignment"); // step 1: creation of a document-object Document document = new Document(); // step 2: // we create a writer that listens to the document // and directs a PDF-stream to a file PdfWriter.getInstance(document, new FileStream("Chap0506.pdf", FileMode.Create)); // step 3: we open the document document.open(); // step 4: we create a table and add it to the document Table table = new Table(3); table.setBorderWidth(1); table.setBorderColor(GDI.Color.Blue); table.setPadding(3); table.setSpacing(1); Cell cell = new Cell("header"); cell.setHeader(true); cell.setColspan(3); table.addCell(cell); cell = new Cell("example cell with colspan 1 and rowspan 2"); cell.setRowspan(2); cell.setBorderColor(GDI.Color.Red); table.addCell(cell); table.addCell("1.1"); table.addCell("2.1"); table.addCell("1.2"); table.addCell("2.2"); table.addCell("cell test1"); cell = new Cell("big cell"); cell.setRowspan(2); cell.setColspan(2); cell.setHorizontalAlignment(Element.__Value.ALIGN_CENTER); cell.setVerticalAlignment(Element.__Value.ALIGN_MIDDLE); cell.setBackgroundColor(GDI.Color.LightGray); table.addCell(cell); table.addCell("cell test2"); document.add(table); // step 5: we close the document document.close(); } }