/* * This code is free software. It may only be copied or modified * if you include the following copyright notice: * * --> Copyright 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; public class Chap0401 { public static void Main(String[] args) { Console.WriteLine("Chapter 4 example 1: Headers en Footers"); // step 1: creation of a document-object Document document = new Document(); // step 2: we create a writer that listens to the document PdfWriter.getInstance(document, new FileStream("Chap0401.pdf", FileMode.Create)); // we add a Footer that will show up on PAGE 1 HeaderFooter footer = new HeaderFooter(new Phrase("This is page: "), true); footer.setBorder(Rectangle.NO_BORDER); document.setFooter(footer); // step 3: we open the document document.open(); // we add a Header that will show up on PAGE 2 HeaderFooter header = new HeaderFooter(new Phrase("This is a header"), false); document.setHeader(header); // step 4: we add content to the document // PAGE 1 document.add(new Paragraph("Hello World")); // we trigger a page break document.newPage(); // PAGE 2 // we add some more content document.add(new Paragraph("Hello Earth")); // we remove the header starting from PAGE 3 document.resetHeader(); // we trigger a page break document.newPage(); // PAGE 3 // we add some more content document.add(new Paragraph("Hello Sun")); document.add(new Paragraph("Remark: the header has vanished!")); // we reset the page numbering document.resetPageCount(); // we trigger a page break document.newPage(); // PAGE 4 // we add some more content document.add(new Paragraph("Hello Moon")); document.add(new Paragraph("Remark: the pagenumber has been reset!")); // step 5: we close the document document.close(); } }