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(final float margin) 

Source Link

Document

Returns the lower left y-coordinate, considering a given margin.

Usage

From source file:direccion.GeneradorFormato.java

@Override
public void onEndPage(PdfWriter writer, Document document) {

    Rectangle rect = writer.getBoxSize("art");
    Image imghead = null;//from w ww  .  j  a  v a 2  s.c  o  m
    PdfContentByte cbhead = null;

    //        try {
    //            imghead = Image.getInstance("LogoSapito5.png");
    //            imghead.setAbsolutePosition(0, 0);
    //            imghead.setAlignment(Image.ALIGN_CENTER);
    //            imghead.scalePercent(10f);
    //            cbhead = writer.getDirectContent();
    //            PdfTemplate tp = cbhead.createTemplate(100, 150);
    //            tp.addImage(imghead);
    //            cbhead.addTemplate(tp, 100, 715);
    //        } catch (BadElementException e) {
    //            e.printStackTrace();
    //        } catch (IOException e) {
    //            e.printStackTrace();
    //        } catch (DocumentException e) {
    //            e.printStackTrace();
    //        }

    Phrase headPhraseImg = new Phrase(cbhead + "",
            FontFactory.getFont(FontFactory.TIMES_ROMAN, 7, Font.NORMAL));

    Calendar c1 = Calendar.getInstance();
    Calendar c2 = new GregorianCalendar();
    String dia, mes, annio;
    dia = Integer.toString(c1.get(Calendar.DATE));
    mes = Integer.toString(c1.get(Calendar.MONTH));
    annio = Integer.toString(c1.get(Calendar.YEAR));
    Date fecha = new Date();
    String fechis = dia + "/" + mes + "/" + annio;

    Paragraph parrafo5 = new Paragraph(fechis,
            FontFactory.getFont(FontFactory.TIMES_ROMAN, 11, Font.NORMAL, BaseColor.BLACK));
    ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_CENTER, new Phrase(parrafo5),
            rect.getRight(450), rect.getTop(-80), 0);

    Paragraph parrafo7 = new Paragraph("Empresa Sapito S.A. de C.V.",
            FontFactory.getFont(FontFactory.TIMES_ROMAN, 16, Font.BOLD, BaseColor.BLACK));
    ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_CENTER, new Phrase(parrafo7),
            rect.getBottom(250), rect.getTop(-60), 0);

    Paragraph parrafo8 = new Paragraph("Reporte algoooooo",
            FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.BOLD, BaseColor.BLACK));
    ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_CENTER, new Phrase(parrafo8),
            rect.getBottom(250), rect.getTop(-40), 0);

    ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_BOTTOM, new Phrase(
            "      _____________________________________________________________________________________    "),
            rect.getBorder(), rect.getTop(650), 0);

    ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_BOTTOM, new Phrase(
            "      _____________________________________________________________________________________    "),
            rect.getBorder(), rect.getTop(-24), 0);

    ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_BOTTOM, new Phrase(
            "      _____________________________________________________________________________________    "),
            rect.getBorder(), rect.getTop(-20), 0);

    Paragraph parrafo6 = new Paragraph(String.format("Pg %d", writer.getPageNumber()),
            FontFactory.getFont(FontFactory.TIMES_ROMAN, 11, Font.NORMAL, BaseColor.BLACK));
    ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_CENTER, new Phrase(parrafo6),
            rect.getRight(-35), rect.getTop(-80), 0);
}

From source file:gov.nih.nci.firebird.service.pdf.AdditionalContent.java

License:Open Source License

private void addText(PdfReader reader, PdfStamper stamper, ColumnText text) throws DocumentException {
    Rectangle pageSize = reader.getPageSize(1);
    int newPageNumber = reader.getNumberOfPages() + 1;
    do {/*w w w.  j  ava  2 s .  com*/
        stamper.insertPage(newPageNumber, pageSize);
        PdfContentByte newContent = stamper.getOverContent(newPageNumber);
        text.setCanvas(newContent);
        text.setSimpleColumn(pageSize.getLeft(MARGIN_SIZE), pageSize.getTop(MARGIN_SIZE),
                pageSize.getRight(MARGIN_SIZE), pageSize.getBottom(MARGIN_SIZE));
        newPageNumber++;
    } while (ColumnText.hasMoreText(text.go()));
}