Example usage for com.itextpdf.kernel.pdf PdfDocument getPage

List of usage examples for com.itextpdf.kernel.pdf PdfDocument getPage

Introduction

In this page you can find the example usage for com.itextpdf.kernel.pdf PdfDocument getPage.

Prototype

public PdfPage getPage(PdfDictionary pageDictionary) 

Source Link

Document

Gets the PdfPage instance by PdfDictionary .

Usage

From source file:org.nih.nci.App.java

protected void addPageNumbers(PdfDocument pdfDocument) {

    int numPages = pdfDocument.getNumberOfPages();

    for (int i = 1; i <= numPages; i++) {
        PdfPage page = pdfDocument.getPage(i);
        page.put(new PdfName("Tabs"), PdfName.S);
        try {/*ww w.j av  a2  s  .  c  o  m*/
            new PdfCanvas(page).beginText()
                    .setFontAndSize(PdfFontFactory.createFont(FontConstants.HELVETICA), 10)
                    .beginMarkedContent(PdfName.Artifact).moveText(255, 25)
                    .showText("Page " + i + " of " + numPages).endText().stroke().endMarkedContent();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}