Example usage for com.lowagie.text Document bottom

List of usage examples for com.lowagie.text Document bottom

Introduction

In this page you can find the example usage for com.lowagie.text Document bottom.

Prototype


public float bottom() 

Source Link

Document

Returns the lower left y-coordinate.

Usage

From source file:questions.tables.TableColumns.java

public static void main(String[] args) {
    Document document = new Document(PageSize.A4.rotate());
    try {/*  ww  w. j a v  a  2 s  .  co  m*/
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(RESULT));

        document.open();

        // the content of the columns
        ColumnText content = new ColumnText(writer.getDirectContent());
        PdfPTable items = new PdfPTable(2);
        items.setWidthPercentage(100);
        for (int i = 0; i < 100; ++i) {
            items.addCell("item " + i);
            items.addCell("some item");
        }
        content.addElement(items);

        // adding the stuff to the document
        int column = 0;
        float height = 0;
        float[][] x = { { document.left(), document.left() + 380 },
                { document.right() - 380, document.right() } };
        int status = ColumnText.START_COLUMN;
        while (ColumnText.hasMoreText(status)) {
            if (column == 0) {
                PdfPTable table = new PdfPTable(1);
                table.setWidthPercentage(100);
                table.addCell("EmployeeSheets");
                table.addCell("Page " + writer.getPageNumber());
                document.add(table);
                height = table.getTotalHeight();
            }
            content.setSimpleColumn(x[column][0], document.bottom(), x[column][1],
                    document.top() - height - 10);
            status = content.go();
            if (++column >= x.length) {
                column = 0;
                document.newPage();
            }
        }
    } catch (DocumentException de) {
        System.err.println(de.getMessage());
    } catch (IOException ioe) {
        System.err.println(ioe.getMessage());
    }
    document.close();
}

From source file:questions.tables.TablesWriteSelected.java

public static void main(String[] args) {
    Document document = new Document(PageSize.A4.rotate());
    try {//w  w  w. j  av  a2 s  .  co m
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(RESULT));

        document.open();

        // the content of the columns
        PdfPTable items = new PdfPTable(2);
        items.setTotalWidth(TOTAL_WIDTH);
        for (int i = 0; i < 100; ++i) {
            items.addCell("item " + i);
            items.addCell("some item");
        }
        int rows = items.size();

        // adding the stuff to the document
        int column = 0;
        int start;
        int end = 0;
        int row = 0;
        float available = 0;
        float[][] x = { { document.left(), document.left() + TOTAL_WIDTH },
                { document.right() - TOTAL_WIDTH, document.right() } };
        while (row < rows) {
            start = row;
            if (column == 0) {
                PdfPTable table = new PdfPTable(1);
                table.setWidthPercentage(100);
                table.addCell("EmployeeSheets");
                table.addCell("Page " + writer.getPageNumber());
                document.add(table);
                available = document.top() - table.getTotalHeight() - 10 - document.bottom();
            }
            float needed = items.getRowHeight(start);
            while (needed < available && row < rows) {
                needed += items.getRowHeight(++row);
                end = row;
            }
            items.writeSelectedRows(start, end, x[column][0], document.bottom() + available,
                    writer.getDirectContent());
            if (++column >= x.length) {
                column = 0;
                document.newPage();
            }
        }
    } catch (DocumentException de) {
        System.err.println(de.getMessage());
    } catch (IOException ioe) {
        System.err.println(ioe.getMessage());
    }
    document.close();
}