/* * 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 Chap0507 { public static void Main(String[] args) { Console.WriteLine("Chapter 5 example 7: borders"); // 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("Chap0507.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.setBorder(Rectangle.TOP | Rectangle.BOTTOM); table.setPadding(5); table.setSpacing(5); Cell cell = new Cell("header"); cell.setHeader(true); cell.setBorderWidth(3); cell.setBorder(Rectangle.TOP | Rectangle.BOTTOM); 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); cell.setBorder(Rectangle.LEFT | Rectangle.BOTTOM); 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.setBorder(Rectangle.NO_BORDER); cell.setGrayFill(0.9f); table.addCell(cell); table.addCell("cell test2"); document.add(table); // step 5: we close the document document.close(); } }