Example usage for com.lowagie.text Rectangle getLeft

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

Introduction

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

Prototype

public float getLeft() 

Source Link

Document

Returns the lower left x-coordinate.

Usage

From source file:com.estate.pdf.PageBorder.java

public void drawNoBorder(Document doc, String pageNum) {
    try {/*from  www  .  ja  v  a  2s .  c o m*/
        PdfContentByte cb = writer.getDirectContentUnder();
        BaseFont fontBold = BaseFont.createFont(Locations.getFontLocation() + "timesbd.ttf", BaseFont.CP1252,
                BaseFont.EMBEDDED);
        BaseFont font = BaseFont.createFont(Locations.getFontLocation() + "times.ttf", BaseFont.CP1252,
                BaseFont.EMBEDDED);
        Rectangle rct = new Rectangle(doc.getPageSize());
        float boxSize = (.1875f * 72);

        // Adjust the top
        rct.setTop(rct.getTop() - (.5f * 72));

        // Do the lower right box
        Rectangle pnRect = new Rectangle(0, 0);
        pnRect.setLeft(rct.getRight() - ((.5f + 0.09375f) * 72));
        pnRect.setTop(((.5f - 0.09375f) * 72) - 9);
        pnRect.setRight(pnRect.getLeft() + boxSize);
        pnRect.setBottom(pnRect.getTop() - boxSize);

        cb.rectangle(pnRect.getLeft(), pnRect.getTop(), boxSize, boxSize);
        cb.setRGBColorFill(0, 72, 117);
        cb.closePathFillStroke();

        // Now we do the page number if one is supplied.
        if (pageNum.length() > 0) {
            float pnHeight = fontBold.getAscentPoint(pageNum, 9) - fontBold.getDescentPoint(pageNum, 9) - 4.5f;
            float pnWidth = fontBold.getWidthPoint(pageNum, 9);

            float l = pnRect.getLeft() + ((boxSize - pnWidth) / 2);
            float b = pnRect.getTop() + ((boxSize - pnHeight) / 2) - 4.5f;

            cb.beginText();
            cb.setFontAndSize(fontBold, 9);
            cb.setRGBColorFill(255, 255, 255);
            cb.setTextMatrix(l, b);
            cb.showText(pageNum);
            cb.endText();
        }

        // Display the copyright
        SimpleDateFormat df = new SimpleDateFormat("yyyy");
        char cs = 0x00a9; // Unicode for the copyright symbol
        String copyRight = "Advanced Practice Network " + cs + " " + df.format(new Date());
        float crWidth;
        float crLeft;

        crWidth = font.getWidthPoint(copyRight, 8);
        cb.beginText();

        cb.setFontAndSize(font, 8);
        cb.setRGBColorFill(0, 0, 0);

        crLeft = (doc.getPageSize().getRight() - crWidth) / 2;
        cb.setTextMatrix(crLeft, .375f * 72); // Place the base of the
        // copyright at 3/8" up from
        // the bottom
        cb.showText(copyRight);
        cb.endText();

        if (license != null) {
            // Fix a licensee at left
            cb.beginText();
            cb.setFontAndSize(font, 8);
            cb.setRGBColorFill(0, 0, 0);
            cb.showTextAligned(PdfContentByte.ALIGN_RIGHT, " Licensee: " + getLicense(), (10.2f * 72),
                    .375f * 72, 0);
            cb.endText();
        }

    } catch (Exception e) {
        System.out.println(e.getMessage());
    }
}

From source file:com.estate.report.Scenario.java

public Rectangle placeHeading() {
    Rectangle rect = new Rectangle(document.getPageSize());
    BaseFont font = PageUtils.LoadFont("GARA.TTF");
    rect.setBottom(rect.getTop() - (72 * .6f));
    HeadingText ht = new HeadingText(this.writer);
    rect.setBottom(rect.getBottom() - (72 * .33f));
    ht.setColor(57, 57, 57);//ww  w  .ja  va2 s  .  c o  m
    ht.setCapsColor(98, 98, 98);
    if (sc1)
        ht.display(rect, 12f, font, 3f, heading, HeadingText.DHT_CENTER);
    else
        ht.display(rect, 12f, font, 3f, heading2, HeadingText.DHT_CENTER);

    rect.setTop(rect.getBottom() - _1_8TH);
    rect.setBottom(prctFull.getBottom());
    rect.setLeft(_1_2TH);
    rect.setRight(rect.getLeft() + (11.f * 72));
    PageBorder pb = new PageBorder(writer);
    pb.setLicense(userInfo.getPlannerFirstName() + " " + userInfo.getPlannerLastName());
    pb.drawNoBorder(document, Integer.toString(pageNum));

    try {
        Rectangle rct = new Rectangle(document.getPageSize());
        float iconBase = (.75f * 72); // This is the base of the icons on
        // the page
        Image icon = Image.getInstance(Locations.getImageLocation() + "pawn.png");
        //    Image box = Image.getInstance(Locations.ImageLocation() +
        //    "blueBOX.png");
        icon.scalePercent(23);
        float scale = .23f;
        float iconLeft = (icon.getWidth() / 2) * scale;

        // Adjust the top
        rct.setTop(rct.getTop());

        // Place the Icon
        icon.setAbsolutePosition((.5f * 72) - iconLeft, rct.getTop() - iconBase);
        document.add(icon);
    } catch (Exception e) {
        System.err.println(e.getMessage());
    }

    drawLifeExp();

    return rect;
}

From source file:com.estate.report.Scenario.java

public void page1() {
    float tallest = 0;
    int colCount = MAX_COLS;
    CFRow continueRow = null;/*from  w  w  w  . j av a 2 s .  co m*/
    float baseWidths[] = initWidths(colCount - 1);
    float widths[] = calcWidths(baseWidths, 11f * 72);
    drawHeader(userInfo.getClientHeading(), "");

    Rectangle agt = placeHeading();
    Rectangle rct = new Rectangle(prctFull);
    rct.setLeft(_1_4TH);
    rct.setRight(rct.getLeft() + 756);
    Rectangle r = doRow(leList(), widths, agt, 17);
    rct.setTop(r.getBottom());
    r = doRow(agesList(), widths, rct, 17);
    rct.setTop(r.getBottom());
    r = doRow(fiscalYearList(), widths, rct, 17);
    rct.setTop(r.getBottom());

    tallest = tallest < r.getHeight() ? r.getHeight() : tallest;

    for (CFRow row : rowList) {
        boolean flag = false;
        if (row.getColNumber() == 0 && row.getIndentLevel() == 0) {
            continueRow = row;
        }

        do {
            flag = false;
            String pdfRow[] = buildRow(row, colCount);
            if (row.isNewPage()) {
                newPage();
                drawHeader(userInfo.getClientHeading(), "");

                agt = placeHeading();
                //rct = new Rectangle(prctFull);
                rct.setLeft(_1_4TH);
                rct.setRight(rct.getLeft() + 756);
                r = doRow(leList(), widths, agt, 17);
                rct.setTop(r.getBottom());
                r = doRow(agesList(), widths, rct, 17);
                rct.setTop(r.getBottom());
                r = doRow(fiscalYearList(), widths, rct, 17);
                rct.setTop(r.getBottom());

                tallest = tallest < r.getHeight() ? r.getHeight() : tallest;
                if (continueRow != null) {
                    if (!row.equals(continueRow)) {
                        row = continueRow;
                        row.setHeader(row.getHeader() + " (cont.)");
                        flag = true;
                    }
                }
            }

            r = doRow(pdfRow, widths, rct, colCount - 1);
            rct.setTop(r.getBottom());
            tallest = tallest < r.getHeight() ? r.getHeight() : tallest;

        } while (flag == true);
    }
}

From source file:com.estate.report.Scenario.java

public Rectangle nextPage(float[] widths) {
    newPage();/*from   ww  w.  j a v  a 2  s .c o  m*/
    String user = userInfo.getClientHeading();
    drawHeader(user, "");
    Rectangle agt = placeHeading();
    Rectangle rct = new Rectangle(prctFull);
    rct.setLeft(_1_4TH);
    rct.setRight(rct.getLeft() + 756);
    Rectangle r = null;
    r = doRow(leList(), widths, agt, 17);
    rct.setTop(r.getBottom());
    r = doRow(agesList(), widths, rct, 17);
    rct.setTop(r.getBottom());
    rct.setTop(r.getBottom());
    r = doRow(fiscalYearList(), widths, rct, 17);
    rct.setTop(r.getBottom());
    return rct;
}

From source file:com.teag.reports.CashFlows.java

private void page1() {
    CashFlowTable cft = new CashFlowTable();
    ClientBean cb = new ClientBean();
    CFRow row;/*from  w ww .j av a  2s. com*/
    CFRow continueRow = null;
    float tallest = 0;

    cb.setPrimaryId(clientID);

    cft.setCb(cb);
    cft.init();
    cft.genTable();

    cft.reset();
    int colCount = MAX_ROWS;

    drawHeader(userInfo.getClientHeading(), "");
    Rectangle agt = placeHeading();

    float baseWidths[] = this.initWidths(colCount - 1);
    float widths[] = this.calcWidths(baseWidths, 11.f * 72);

    Rectangle rct = new Rectangle(prctFull);
    rct.setLeft(_1_4TH);
    rct.setRight(rct.getLeft() + 756);

    Rectangle r = doRow(leList(), widths, agt, 17);
    rct.setTop(r.getBottom());
    r = doRow(agesList(), widths, rct, 17);

    rct.setTop(r.getBottom());

    r = doRow(fiscalYearList(), widths, rct, 17);
    rct.setTop(r.getBottom());

    tallest = tallest < r.getHeight() ? r.getHeight() : tallest;

    while ((row = cft.getRow()) != null) {
        boolean flag;
        if (row.getColNumber() == 0 && row.getIndentLevel() == 0) {
            continueRow = row;
        }

        do {
            flag = false;
            boolean nPage = false;
            String pdfRow[] = buildRow(row, colCount);
            if (row.getHeader().startsWith("III.") && !row.getHeader().endsWith("(cont.)")) {
                nPage = true;
            }
            if (row.getHeader().startsWith("IV.") && !row.getHeader().endsWith("(cont.)")) {
                nPage = true;
            }

            // Rectangle r = doSimpleRow(pdfRow, rct);
            if (nPage) {
                // need to span to a new page
                newPage();
                drawHeader(client, "");
                agt = placeHeading();
                rct.setLeft(_1_4TH);
                rct.setRight(rct.getLeft() + 756);

                r = doRow(leList(), widths, agt, 17);
                rct.setTop(r.getBottom());
                r = doRow(agesList(), widths, rct, 17);
                rct.setTop(r.getBottom());
                r = doRow(fiscalYearList(), widths, rct, 17);
                rct.setTop(r.getBottom());
                tallest = tallest < r.getHeight() ? r.getHeight() : tallest;
                if (continueRow != null) {
                    if (!row.equals(continueRow)) {
                        row = continueRow;
                        row.setHeader(row.getHeader() + " (cont.)");
                        flag = true;

                    }
                }
                nPage = false;
            }

            r = this.doRow(pdfRow, widths, rct, colCount - 1);
            tallest = tallest < r.getHeight() ? r.getHeight() : tallest;
            rct.setTop(r.getBottom());

            if (rct.getTop() < (.5f * 72) + tallest) {
                // need to span to a new page
                newPage();
                drawHeader(client, "");
                agt = placeHeading();

                rct.setLeft(_1_4TH);
                rct.setRight(rct.getLeft() + 756);

                r = doRow(leList(), widths, agt, 17);
                rct.setTop(r.getBottom());
                r = doRow(agesList(), widths, rct, 17);
                rct.setTop(r.getBottom());
                r = doRow(fiscalYearList(), widths, rct, 17);
                rct.setTop(r.getBottom());
                tallest = tallest < r.getHeight() ? r.getHeight() : tallest;

                if (continueRow != null) {
                    if (!row.equals(continueRow)) {
                        row = continueRow;
                        row.setHeader(row.getHeader() + " (cont.)");
                        flag = true;
                    }
                }
            }
        } while (flag == true);
    }
    cft.cleanUp();
}

From source file:com.teag.reports.CashFlows.java

private Rectangle placeHeading() {

    String header = "Estimate Of Net Worth & Estate Distribution - Scenario #1 As Is (in 000's)";
    BaseFont font = PageUtils.LoadFont("GARA.TTF");

    Rectangle rect = new Rectangle(document.getPageSize());
    rect.setBottom(rect.getTop() - (72 * .6f));
    HeadingText ht = new HeadingText(this.writer);
    rect.setBottom(rect.getBottom() - (72 * .33f));
    ht.setColor(57, 57, 57);/*from   w w w . j  ava2s  .  c  o  m*/
    ht.setCapsColor(98, 98, 98);
    ht.display(rect, 12f, font, 3f, header, HeadingText.DHT_CENTER);
    rect.setTop(rect.getBottom() - _1_8TH);
    rect.setBottom(prctFull.getBottom());
    rect.setLeft(_1_2TH);
    rect.setRight(rect.getLeft() + 11.f * 72);
    PageBorder pb = new PageBorder(writer);
    pb.setLicense(userInfo.getPlannerFirstName() + " " + userInfo.getPlannerLastName());
    pb.drawNoBorder(document, Integer.toString(pageNum));
    drawLifeExp();
    return (rect);
}

From source file:com.teag.reports.EstatePlan.java

private void page1() {
    EstatePlanTable ept = new EstatePlanTable();
    ClientBean cb = new ClientBean();
    CFRow row;//from  w  w w  .j  a va2s. c  om
    float tallest = 0;

    drawHeader(client, "");
    String header = "Estimate Of Cash Flows - Scenario #2 After (in 000's)";

    Rectangle agt = placeHeading(header);
    cb.setPrimaryId(clientID);
    cb.initialize();

    ept.setClient(cb);
    ept.setScenarioId(epg.getScenarioId());
    ept.setEstate(epg);
    ept.initialize();
    ept.resetRows();

    int colCount = MAX_COLS;

    float baseWidths[] = this.initWidths(colCount - 1);
    float widths[] = this.calcWidths(baseWidths, 11.0f * 72);

    Rectangle rct = new Rectangle(prctFull);
    rct.setLeft(_1_4TH);
    rct.setRight(rct.getLeft() + 756);
    Rectangle r = doRow(leList(), widths, agt, colCount - 1);
    rct.setTop(r.getBottom());
    r = doRow(agesList(), widths, rct, colCount - 1);
    rct.setTop(r.getBottom());
    r = doRow(fiscalYearList(), widths, rct, colCount - 1);
    rct.setTop(r.getBottom());
    tallest = tallest < r.getHeight() ? r.getHeight() : tallest;

    boolean nPage = false;

    while ((row = ept.getRow()) != null) {
        if (rct.getTop() < (.5f * 72) + tallest) {
            // need to span to a new page
            newPage();
            drawHeader(client, "");
            header = "Estimate Of Net Worth - Scenario #2 After (in 000's)";
            agt = placeHeading(header);
            rct = new Rectangle(prctFull);
            rct.setLeft(_1_4TH);
            rct.setRight(rct.getLeft() + 756);
            r = doRow(leList(), widths, agt, colCount - 1);
            rct.setTop(r.getBottom());
            r = doRow(agesList(), widths, rct, colCount - 1);
            rct.setTop(r.getBottom());
            r = doRow(fiscalYearList(), widths, rct, colCount - 1);
            rct.setTop(r.getBottom());
            tallest = tallest < r.getHeight() ? r.getHeight() : tallest;
            nPage = true;
        }
        String pdfRow[] = buildRow(row, colCount);
        //Rectangle r = doSimpleRow(pdfRow, rct);

        if ((row.getHeader().startsWith("III.") || row.getHeader().startsWith("IV."))
                || row.getHeader().startsWith("II") && !nPage) {
            //              need to span to a new page
            newPage();
            drawHeader(client, "");
            header = "Estimate Of Net Worth - Scenario #2 After (in 000's)";
            agt = placeHeading(header);
            rct = new Rectangle(prctFull);
            rct.setLeft(_1_4TH);
            rct.setRight(rct.getLeft() + 756);
            r = doRow(leList(), widths, agt, colCount - 1);
            rct.setTop(r.getBottom());
            r = doRow(agesList(), widths, rct, colCount - 1);
            rct.setTop(r.getBottom());
            r = doRow(fiscalYearList(), widths, rct, colCount - 1);
            rct.setTop(r.getBottom());
            tallest = tallest < r.getHeight() ? r.getHeight() : tallest;
        }
        nPage = false;

        r = this.doRow(pdfRow, widths, rct, colCount - 1);
        tallest = tallest < r.getHeight() ? r.getHeight() : tallest;
        rct.setTop(r.getBottom());
        /*
        if(rct.getTop() < (.5f * 72) + tallest)
        {
           // need to span to a new page
           newPage();
           drawHeader(client, "");
             header = "Estimate Of Net Worth - Scenario #2 After (in 000's)";
           agt = placeHeading(header);
           rct = new Rectangle(prctFull);
           rct.setLeft(_1_4TH);
           rct.setRight(rct.getLeft() + 756);
           r = doRow(leList(), widths, agt, colCount-1);
           rct.setTop(r.getBottom());
           r = doRow(agesList(),widths,rct,colCount-1);
           rct.setTop(r.getBottom());
           r = doRow(fiscalYearList(),widths,rct,colCount-1);
           rct.setTop(r.getBottom());
           tallest = tallest < r.getHeight() ? r.getHeight() : tallest;
        nPage = true;
        }
        */

    }
}

From source file:com.teag.reports.EstatePlan.java

private Rectangle placeHeading(String header) {

    BaseFont font = PageUtils.LoadFont("GARA.TTF");

    Rectangle rect = new Rectangle(document.getPageSize());
    rect.setBottom(rect.getTop() - (72 * .6f));
    HeadingText ht = new HeadingText(this.writer);
    rect.setBottom(rect.getBottom() - (72 * .33f));
    ht.setColor(57, 57, 57);/*  w ww. j  a  v a2  s  .  com*/
    ht.setCapsColor(98, 98, 98);
    ht.display(rect, 12f, font, 3f, header, HeadingText.DHT_CENTER);
    rect.setTop(rect.getBottom() - _1_8TH);
    rect.setBottom(prctFull.getBottom());
    rect.setLeft(_1_2TH);
    rect.setRight(rect.getLeft() + 11.0f * 72);
    drawHeader(client, "");
    PageBorder pb = new PageBorder(writer);
    pb.setLicense(userInfo.getPlannerFirstName() + " " + userInfo.getPlannerLastName());
    pb.drawNoBorder(document, Integer.toString(pageNum));
    drawLifeExp();

    return (rect);
}

From source file:es.gob.afirma.signers.pades.PdfPreProcessor.java

License:Open Source License

/** Sobreimpone una imagen en un documento PDF.
 * @param extraParams Datos de la imagen a a&ntilde;adir como <a href="doc-files/extraparams.html">par&aacute;metros adicionales</a>
 * @param stp Estampador de PDF, debe abrirse y cerrarse fuera de este m&eacute;todo
 * @throws IOException Cuando ocurren errores de entrada / salida */
static void addImage(final Properties extraParams, final PdfStamper stp) throws IOException {

    if (extraParams == null || stp == null) {
        return;/*  w  ww  . ja  v  a2 s .  c  o  m*/
    }

    final String imageDataBase64 = extraParams.getProperty("image"); //$NON-NLS-1$
    if (imageDataBase64 == null || imageDataBase64.length() < 1) {
        return;
    }
    final byte[] image = Base64.decode(imageDataBase64);

    final Rectangle rect = getPositionOnPage(extraParams, "image"); //$NON-NLS-1$

    if (rect == null) {
        return;
    }

    final String imagePage = extraParams.getProperty("imagePage"); //$NON-NLS-1$
    if (imagePage == null) {
        return;
    }

    final int pageNum;
    try {
        pageNum = Integer.parseInt(imagePage);
    } catch (final NumberFormatException e) {
        throw new IOException(
                "Se ha indicado un numero de pagina con formato invalido para insertar la imagen (" + imagePage //$NON-NLS-1$
                        + "): " + e, //$NON-NLS-1$
                e);
    }

    addImage(image, (int) rect.getWidth(), (int) rect.getHeight(), (int) rect.getLeft(), (int) rect.getBottom(),
            pageNum, null, stp);

    LOGGER.info("Anadida imagen al PDF antes de la firma"); //$NON-NLS-1$
}

From source file:jdbreport.model.io.pdf.itext2.PdfWriter.java

License:Apache License

private PdfPTable createPdfTable(int columnCount, float[] widths, Rectangle pageSize) throws DocumentException {
    PdfPTable table;//w w  w  .j av  a 2s  .c o  m
    table = new PdfPTable(columnCount);
    table.setHorizontalAlignment(PdfPTable.ALIGN_LEFT);
    table.setTotalWidth(widths);
    float widthPercentage = table.getTotalWidth() / (pageSize.getRight() - pageSize.getLeft()) * 100f;
    table.setWidthPercentage(widthPercentage);
    return table;
}