Example usage for com.itextpdf.text Document left

List of usage examples for com.itextpdf.text Document left

Introduction

In this page you can find the example usage for com.itextpdf.text Document left.

Prototype


public float left() 

Source Link

Document

Returns the lower left x-coordinate.

Usage

From source file:net.digitstar.vanadio.AbstractReportPdf.java

License:Apache License

protected void writeHeaderFooter(Document document, PdfReader reader, PdfStamper writer, int pag,
        int totalPages, ReportOptions reportOptions) {
    if (reportOptions.isShowHeader()) {
        if (pag != 1 || reportOptions.isShowHeaderOnFirstPage()) {
            PdfPTable header = createHeader(document, pag, totalPages, reportOptions);
            header.writeSelectedRows(0, -1, document.left(), document.top() + header.getTotalHeight(),
                    writer.getOverContent(pag));
        }//  ww w. j a  v  a2 s  . c  om
    }
    if (reportOptions.isShowFooter()) {
        if (pag != 1 || reportOptions.isShowFooterOnFirstPage()) {
            PdfPTable footer = createFooter(document, pag, totalPages, reportOptions);
            footer.writeSelectedRows(0, -1, document.left(), document.bottom() - footer.getTotalHeight(),
                    writer.getOverContent(pag));
        }
    }
}

From source file:net.digitstar.vanadio.AbstractReportPdf.java

License:Apache License

protected PdfPTable createHeader(Document document, int page, int pageTotal, ReportOptions reportOptions) {
    PdfPTable header = new PdfPTable(3);
    header.setTotalWidth(document.right() - document.left());
    PdfPCell def = header.getDefaultCell();
    String left = "";
    String center = "";
    String right = "";

    if (reportOptions.isShowPageNumberIfOnePage()
            || (!reportOptions.isShowPageNumberIfOnePage() && pageTotal > 1)) {
        right = reportOptions.isShowPageTotal() ? Labels.PAGE_TOTAL.getLabelFormatted(page, pageTotal)
                : Labels.PAGE.getLabelFormatted(page);
    }//from ww w  .j  av a 2  s. co  m

    def.setFixedHeight(computeHeight(FontType.HEADERFOOTER.getFont()));

    def.setBorder(CellStyle.Border.NONE.getValue());
    if (reportOptions.isUseHrRuler())
        def.setBorder(CellStyle.Border.BOTTOM.getValue());

    def.setHorizontalAlignment(CellStyle.Align.LEFT.getValue());
    header.addCell(new Phrase(left, FontType.HEADERFOOTER.getFont()));
    def.setHorizontalAlignment(CellStyle.Align.CENTER.getValue());
    header.addCell(new Phrase(center, FontType.HEADERFOOTER.getFont()));
    def.setHorizontalAlignment(CellStyle.Align.RIGHT.getValue());
    header.addCell(new Phrase(right, FontType.HEADERFOOTER.getFont()));
    return header;
}

From source file:net.digitstar.vanadio.AbstractReportPdf.java

License:Apache License

protected PdfPTable createFooter(Document document, int page, int pageTotal, ReportOptions reportOptions) {
    PdfPTable footer = new PdfPTable(3);
    footer.setTotalWidth(document.right() - document.left());
    PdfPCell def = footer.getDefaultCell();
    String left = "";
    String center = "";
    String right = "";

    def.setFixedHeight(computeHeight(FontType.HEADERFOOTER.getFont()));
    def.setBorder(CellStyle.Border.NONE.getValue());
    if (reportOptions.isUseHrRuler())
        def.setBorder(CellStyle.Border.TOP.getValue());

    if (reportOptions.isShowPrintDate())
        right = Labels.PRINTED.getLabelFormatted(getDateTimeFormat().format(new Date()));

    def.setHorizontalAlignment(CellStyle.Align.LEFT.getValue());
    footer.addCell(new Phrase(left, FontType.HEADERFOOTER.getFont()));
    def.setHorizontalAlignment(CellStyle.Align.CENTER.getValue());
    footer.addCell(new Phrase(center, FontType.HEADERFOOTER.getFont()));
    def.setHorizontalAlignment(CellStyle.Align.RIGHT.getValue());
    footer.addCell(new Phrase(right, FontType.HEADERFOOTER.getFont()));
    return footer;
}

From source file:org.openlmis.web.view.pdf.PdfPageEventHandler.java

License:Open Source License

private void writeCurrentDate(Document document, PdfContentByte contentByte) {
    contentByte.setTextMatrix(document.left() + textAdjustment, document.bottom());
    String dateText = DATE_FORMAT.format(new Date());
    contentByte.showText(dateText);/* ww  w. j a  v a  2s .co  m*/
}

From source file:pdf.FooterHeader.java

License:Open Source License

@Override
public void onEndPage(PdfWriter writer, Document document) {
    PdfPTable table = new PdfPTable(3);
    try {//from   ww w  . jav  a  2  s  .  c om
        if (document.getPageNumber() > 1) {
            table.setWidths(new int[] { 24, 24, 2 });
            table.setTotalWidth(527);
            table.setLockedWidth(true);
            table.getDefaultCell().setFixedHeight(20);
            table.getDefaultCell().setBorder(Rectangle.BOTTOM);
            table.addCell(header);
            table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);
            table.addCell(String.format("Seite %d von", writer.getPageNumber()));
            PdfPCell cell = new PdfPCell(Image.getInstance(total));
            cell.setBorder(Rectangle.BOTTOM);
            table.addCell(cell);
            table.writeSelectedRows(0, -1, 34, 803, writer.getDirectContent());
        }
    } catch (DocumentException de) {
        throw new ExceptionConverter(de);
    }

    PdfContentByte cb = writer.getDirectContent();
    if (document.getPageNumber() > 1) {
        footer = new Phrase(document.getPageNumber() - 2);
        ColumnText.showTextAligned(cb, Element.ALIGN_CENTER, footer,
                (document.right() - document.left() - 30) / 2 + document.leftMargin(), document.bottom() + 10,
                0);
    }

}

From source file:se.inera.intyg.rehabstod.service.export.pdf.PageNumberingEventHandler.java

License:Open Source License

/**
 * Adds a header to every page.//from  w  w  w  .  j a v  a  2s . c o  m
 *
 * @see com.itextpdf.text.pdf.PdfPageEventHelper#onEndPage(com.itextpdf.text.pdf.PdfWriter,
 *      com.itextpdf.text.Document)
 */
@Override
public void onEndPage(PdfWriter writer, Document document) {

    try {
        PdfPTable table = new PdfPTable(2);

        table.setTotalWidth(document.getPageSize().getWidth());

        table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);
        table.getDefaultCell().setBorder(Rectangle.NO_BORDER);

        table.addCell(new Phrase(String.valueOf(writer.getPageNumber()), PdfExportConstants.TABLE_CELL_NORMAL));
        PdfPCell cell = new PdfPCell(Image.getInstance(total));
        cell.setBorder(Rectangle.NO_BORDER);
        table.addCell(cell);
        table.writeSelectedRows(0, -1, document.left(), document.bottom(), writer.getDirectContent());

    } catch (DocumentException de) {
        throw new ExceptionConverter(de);
    }
}

From source file:utilities.Footer.java

@Override
public void onEndPage(PdfWriter writer, Document document) {
    PdfContentByte cb = writer.getDirectContent();
    Phrase header = new Phrase("ZLECENIE SERWISOWE", ffont);

    Phrase footer = new Phrase("ZLECENIE SERWISOWE", ffont);
    ColumnText.showTextAligned(cb, Element.ALIGN_CENTER, footer,
            (document.right() - document.left()) / 2 + document.leftMargin(), 20, 0);

    ColumnText.showTextAligned(cb, Element.ALIGN_CENTER, header,
            (document.right() - document.left()) / 2 + document.leftMargin(), document.top() + 10, 0);

}