Example usage for com.itextpdf.kernel.pdf PdfPage put

List of usage examples for com.itextpdf.kernel.pdf PdfPage put

Introduction

In this page you can find the example usage for com.itextpdf.kernel.pdf PdfPage put.

Prototype

public PdfPage put(PdfName key, PdfObject value) 

Source Link

Document

Helper method that associate specified value with specified key in the underlined 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 {//from   w w  w .  ja va  2s .co 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();
        }
    }
}