Example usage for com.itextpdf.text Rectangle getBottom

List of usage examples for com.itextpdf.text Rectangle getBottom

Introduction

In this page you can find the example usage for com.itextpdf.text Rectangle getBottom.

Prototype

public float getBottom() 

Source Link

Document

Returns the lower left y-coordinate.

Usage

From source file:se.billes.pdf.renderer.request.factory.CellBlockEvent.java

License:Open Source License

public PdfPCellEvent createEvent(final Block block) {
    return new PdfPCellEvent() {
        public void cellLayout(PdfPCell cell, Rectangle rect, PdfContentByte[] canvas) {

            float radiusInPs = SizeFactory.millimetersToPostscriptPoints(block.getRadius());
            PdfContentByte cb = canvas[PdfPTable.LINECANVAS];
            PdfTemplate template = cb.createTemplate(rect.getWidth(), rect.getHeight());
            template.roundRectangle(0, 0, rect.getWidth(), rect.getHeight(), radiusInPs);
            template.clip();//ww  w.ja  va  2 s  . co  m
            template.newPath();

            if (block.getBaseColor() != null) {
                template.setColorFill(block.getBaseColor());
            }

            Border border = block.getBorder();

            if (border != null) {
                template.setLineWidth(SizeFactory.millimetersToPostscriptPoints(border.getThickness()));
                template.setColorStroke(border.getBaseColor());
            }

            template.roundRectangle(0, 0, rect.getWidth(), rect.getHeight(), radiusInPs);

            if (block.getBaseColor() != null || border != null) {
                if (block.getBaseColor() != null && border != null) {
                    template.fillStroke();
                } else if (block.getBaseColor() != null) {
                    template.fill();
                } else {

                    template.stroke();
                }
            }
            cb.addTemplate(template, rect.getLeft(), rect.getBottom());
        }
    };
}

From source file:timeclock.reports.HeaderFooter.java

/**
 * Adds the header and the footer.//w w w .j ava  2 s .c om
 *
 * @see com.itextpdf.text.pdf.PdfPageEventHelper#onEndPage(
 * com.itextpdf.text.pdf.PdfWriter, com.itextpdf.text.Document)
 */
@Override
public void onEndPage(PdfWriter writer, Document document) {
    Rectangle rect = writer.getBoxSize("art");

    // Show page header at top center
    ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_CENTER, header,
            (rect.getLeft() + rect.getRight()) / 2, rect.getTop() + 12, 0);

    // Show page number at bottom center
    ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_CENTER,
            new Phrase(String.format("page %d", pagenumber)), (rect.getLeft() + rect.getRight()) / 2,
            rect.getBottom() - 18, 0);
}