Example usage for com.lowagie.text Rectangle BOX

List of usage examples for com.lowagie.text Rectangle BOX

Introduction

In this page you can find the example usage for com.lowagie.text Rectangle BOX.

Prototype

int BOX

To view the source code for com.lowagie.text Rectangle BOX.

Click Source Link

Document

This represents a type of border.

Usage

From source file:questions.importpages.HelloWorldImportedPages.java

public static void main(String[] args) {
    // we create a PDF file
    createPdf(SOURCE);/*  w w  w . ja v a  2 s  .  c  o  m*/
    // step 1
    Document document = new Document(PageSize.A4);
    try {
        // we create a PdfReader object
        PdfReader reader = new PdfReader(SOURCE);
        // step 2
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(RESULT));
        // step 3
        document.open();
        // step 4
        PdfImportedPage page;
        for (int i = 1; i <= reader.getNumberOfPages(); i++) {
            page = writer.getImportedPage(reader, i);
            Image image = Image.getInstance(page);
            image.scalePercent(15f);
            image.setBorder(Rectangle.BOX);
            image.setBorderWidth(3f);
            image.setBorderColor(new GrayColor(0.5f));
            image.setRotationDegrees(-reader.getPageRotation(i));
            document.add(image);
            document.add(new Paragraph("This is page: " + i));
        }
    } catch (IOException e) {
        e.printStackTrace();
    } catch (DocumentException e) {
        e.printStackTrace();
    }
    // step 5
    document.close();
}