Example usage for com.itextpdf.text.pdf PdfImportedPage getBoundingBox

List of usage examples for com.itextpdf.text.pdf PdfImportedPage getBoundingBox

Introduction

In this page you can find the example usage for com.itextpdf.text.pdf PdfImportedPage getBoundingBox.

Prototype

public Rectangle getBoundingBox() 

Source Link

Usage

From source file:be.rheynaerde.pufmanager.gui.workers.ExportFullPdfWorker.java

License:Open Source License

private void addPdfToDocument(ByteArrayOutputStream baos, PdfCopy copy, String stampText)
        throws IOException, BadPdfFormatException {
    PdfReader reader = new PdfReader(new ByteArrayInputStream(baos.toByteArray()));
    int n = reader.getNumberOfPages();
    for (int page = 1; page <= n; page++) {
        PdfImportedPage importedPage = copy.getImportedPage(reader, page);
        PdfCopy.PageStamp stamp = copy.createPageStamp(importedPage);
        Rectangle rectangle = importedPage.getBoundingBox();
        ColumnText.showTextAligned(stamp.getUnderContent(), Element.ALIGN_RIGHT, new Phrase(stampText),
                rectangle.getRight() - 20f, rectangle.getTop() - 20f, 0);
        stamp.alterContents();/*w  ww .  j a v a2s .co m*/
        copy.addPage(importedPage);
    }
}