Example usage for com.lowagie.text Element ALIGN_RIGHT

List of usage examples for com.lowagie.text Element ALIGN_RIGHT

Introduction

In this page you can find the example usage for com.lowagie.text Element ALIGN_RIGHT.

Prototype

int ALIGN_RIGHT

To view the source code for com.lowagie.text Element ALIGN_RIGHT.

Click Source Link

Document

A possible value for paragraph alignment.

Usage

From source file:oscar.oscarLab.ca.all.pageUtil.LabPDFCreator.java

License:Open Source License

private void addLabCategory(String header) throws DocumentException {

    float[] mainTableWidths = { 5f, 3f, 1f, 3f, 2f, 4f, 2f };
    PdfPTable table = new PdfPTable(mainTableWidths);
    table.setHeaderRows(3);//w  w w.  ja  v a  2 s  .c  om
    table.setWidthPercentage(100);

    PdfPCell cell = new PdfPCell();
    // category name
    cell.setPadding(3);
    cell.setPhrase(new Phrase("  "));
    cell.setBorder(0);
    cell.setColspan(7);
    table.addCell(cell);
    cell.setBorder(15);
    cell.setPadding(3);
    cell.setColspan(2);
    cell.setPhrase(new Phrase(header.replaceAll("<br\\s*/*>", "\n"), new Font(bf, 12, Font.BOLD)));
    table.addCell(cell);
    cell.setPhrase(new Phrase("  "));
    cell.setBorder(0);
    cell.setColspan(5);
    table.addCell(cell);

    // table headers
    cell.setColspan(1);
    cell.setBorder(15);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setBackgroundColor(new Color(210, 212, 255));
    cell.setPhrase(new Phrase("Test Name(s)", boldFont));
    table.addCell(cell);
    cell.setPhrase(new Phrase("Result", boldFont));
    table.addCell(cell);
    cell.setPhrase(new Phrase("Abn", boldFont));
    table.addCell(cell);
    cell.setPhrase(new Phrase("Reference Range", boldFont));
    table.addCell(cell);
    cell.setPhrase(new Phrase("Units", boldFont));
    table.addCell(cell);
    cell.setPhrase(new Phrase("Date/Time Completed", boldFont));
    table.addCell(cell);
    cell.setPhrase(new Phrase("Status", boldFont));
    table.addCell(cell);

    // add test results
    int obrCount = handler.getOBRCount();
    int linenum = 0;
    cell.setBorder(12);
    cell.setBorderColor(Color.BLACK); // cell.setBorderColor(Color.WHITE);
    cell.setBackgroundColor(new Color(255, 255, 255));

    if (handler.getMsgType().equals("MEDVUE")) {

        //cell.setBackgroundColor(getHighlightColor(linenum));
        linenum++;
        cell.setPhrase(new Phrase(handler.getRadiologistInfo(), boldFont));
        cell.setColspan(7);
        cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        table.addCell(cell);
        cell.setPaddingLeft(100);
        cell.setColspan(7);
        cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        cell.setPhrase(new Phrase(handler.getOBXComment(1, 1, 1).replaceAll("<br\\s*/*>", "\n"), font));
        table.addCell(cell);

    } else {
        for (int j = 0; j < obrCount; j++) {
            boolean obrFlag = false;
            int obxCount = handler.getOBXCount(j);
            for (int k = 0; k < obxCount; k++) {
                String obxName = handler.getOBXName(j, k);

                if (!handler.getOBXResultStatus(j, k).equals("TDIS")) {

                    // ensure that the result is a real result
                    if ((!handler.getOBXResultStatus(j, k).equals("DNS") && !obxName.equals("")
                            && handler.getObservationHeader(j, k).equals(header))
                            || (handler.getMsgType().equals("EPSILON")
                                    && handler.getOBXIdentifier(j, k).equals(header) && !obxName.equals(""))
                            || (handler.getMsgType().equals("PFHT") && !obxName.equals("")
                                    && handler.getObservationHeader(j, k).equals(header))) { // <<-- DNS only needed for
                        // MDS messages
                        String obrName = handler.getOBRName(j);

                        // add the obrname if necessary
                        if (!obrFlag && !obrName.equals("") && !(obxName.contains(obrName) && obxCount < 2)) {
                            // cell.setBackgroundColor(getHighlightColor(linenum));
                            linenum++;
                            cell.setPhrase(new Phrase(obrName, boldFont));
                            cell.setColspan(7);
                            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
                            table.addCell(cell);
                            cell.setColspan(1);
                            obrFlag = true;
                        }

                        // add the obx results and info
                        Font lineFont = new Font(bf, 8, Font.NORMAL,
                                getTextColor(handler.getOBXAbnormalFlag(j, k)));
                        // cell.setBackgroundColor(getHighlightColor(linenum));
                        linenum++;
                        cell.setHorizontalAlignment(Element.ALIGN_LEFT);
                        cell.setPhrase(new Phrase((obrFlag ? "   " : "") + obxName, lineFont));
                        table.addCell(cell);
                        cell.setPhrase(new Phrase(handler.getOBXResult(j, k).replaceAll("<br\\s*/*>", "\n"),
                                lineFont));
                        cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
                        table.addCell(cell);
                        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                        cell.setPhrase(new Phrase(
                                (handler.isOBXAbnormal(j, k) ? handler.getOBXAbnormalFlag(j, k) : "N"),
                                lineFont));
                        table.addCell(cell);
                        cell.setHorizontalAlignment(Element.ALIGN_LEFT);
                        cell.setPhrase(new Phrase(handler.getOBXReferenceRange(j, k), lineFont));
                        table.addCell(cell);
                        cell.setPhrase(new Phrase(handler.getOBXUnits(j, k), lineFont));
                        table.addCell(cell);
                        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                        cell.setPhrase(new Phrase(handler.getTimeStamp(j, k), lineFont));
                        table.addCell(cell);
                        cell.setPhrase(new Phrase(handler.getOBXResultStatus(j, k), lineFont));
                        table.addCell(cell);

                        if (!handler.getMsgType().equals("PFHT")) {
                            // add obx comments
                            if (handler.getOBXCommentCount(j, k) > 0) {
                                // cell.setBackgroundColor(getHighlightColor(linenum));
                                linenum++;
                                cell.setPaddingLeft(100);
                                cell.setColspan(7);
                                cell.setHorizontalAlignment(Element.ALIGN_LEFT);
                                for (int l = 0; l < handler.getOBXCommentCount(j, k); l++) {

                                    cell.setPhrase(new Phrase(
                                            handler.getOBXComment(j, k, l).replaceAll("<br\\s*/*>", "\n"),
                                            font));
                                    table.addCell(cell);

                                }
                                cell.setPadding(3);
                                cell.setColspan(1);
                            }
                        }
                        // if (DNS)
                    } else if ((handler.getMsgType().equals("EPSILON")
                            && handler.getOBXIdentifier(j, k).equals(header) && obxName.equals(""))
                            || (handler.getMsgType().equals("PFHT") && obxName.equals("")
                                    && handler.getObservationHeader(j, k).equals(header))) {
                        // cell.setBackgroundColor(getHighlightColor(linenum));
                        linenum++;
                        cell.setPaddingLeft(100);
                        cell.setColspan(7);
                        cell.setHorizontalAlignment(Element.ALIGN_LEFT);
                        cell.setPhrase(
                                new Phrase(handler.getOBXResult(j, k).replaceAll("<br\\s*/*>", "\n"), font));
                        table.addCell(cell);
                        cell.setPadding(3);
                        cell.setColspan(1);

                    }
                    if (handler.getMsgType().equals("PFHT") && !handler.getNteForOBX(j, k).equals("")
                            && handler.getNteForOBX(j, k) != null) {
                        // cell.setBackgroundColor(getHighlightColor(linenum));
                        linenum++;
                        cell.setPaddingLeft(100);
                        cell.setColspan(7);
                        cell.setHorizontalAlignment(Element.ALIGN_LEFT);
                        cell.setPhrase(
                                new Phrase(handler.getNteForOBX(j, k).replaceAll("<br\\s*/*>", "\n"), font));
                        table.addCell(cell);
                        cell.setPadding(3);
                        cell.setColspan(1);

                        if (handler.getOBXCommentCount(j, k) > 0) {
                            // cell.setBackgroundColor(getHighlightColor(linenum));
                            linenum++;
                            cell.setPaddingLeft(100);
                            cell.setColspan(7);
                            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
                            for (int l = 0; l < handler.getOBXCommentCount(j, k); l++) {

                                cell.setPhrase(new Phrase(
                                        handler.getOBXComment(j, k, l).replaceAll("<br\\s*/*>", "\n"), font));
                                table.addCell(cell);

                            }
                            cell.setPadding(3);
                            cell.setColspan(1);
                        }
                    }
                } else {
                    if (handler.getOBXCommentCount(j, k) > 0) {
                        // cell.setBackgroundColor(getHighlightColor(linenum));
                        linenum++;
                        cell.setPaddingLeft(100);
                        cell.setColspan(7);
                        cell.setHorizontalAlignment(Element.ALIGN_LEFT);
                        for (int l = 0; l < handler.getOBXCommentCount(j, k); l++) {

                            cell.setPhrase(new Phrase(
                                    handler.getOBXComment(j, k, l).replaceAll("<br\\s*/*>", "\n"), font));
                            table.addCell(cell);

                        }
                        cell.setPadding(3);
                        cell.setColspan(1);
                    }
                } // if (!handler.getOBXResultStatus(j, k).equals("TDIS"))

            }

            if (!handler.getMsgType().equals("PFHT")) {
                // add obr comments
                if (handler.getObservationHeader(j, 0).equals(header)) {
                    cell.setColspan(7);
                    cell.setHorizontalAlignment(Element.ALIGN_LEFT);
                    for (int k = 0; k < handler.getOBRCommentCount(j); k++) {
                        // the obrName should only be set if it has not been
                        // set already which will only have occured if the
                        // obx name is "" or if it is the same as the obr name
                        if (!obrFlag && handler.getOBXName(j, 0).equals("")) {
                            // cell.setBackgroundColor(getHighlightColor(linenum));
                            linenum++;

                            cell.setPhrase(new Phrase(handler.getOBRName(j), boldFont));
                            table.addCell(cell);
                            obrFlag = true;
                        }

                        // cell.setBackgroundColor(getHighlightColor(linenum));
                        linenum++;
                        cell.setPaddingLeft(100);
                        cell.setPhrase(
                                new Phrase(handler.getOBRComment(j, k).replaceAll("<br\\s*/*>", "\n"), font));
                        table.addCell(cell);
                        cell.setPadding(3);
                    }
                    cell.setColspan(1);
                }
            }
        } // for (j)

    } // if (isMEDVUE)

    document.add(table);

}

From source file:permit.PermitPdf.java

License:Open Source License

void writePage(HttpServletResponse res, Permit permit) {
    ////w  w w.  j  av a2s.  c o m
    // paper size legal (A4) 8.5 x 11
    // page 1-inch = 72 points
    //
    String fileName = "row_permit_" + permit.getId() + ".pdf";
    Rectangle pageSize = new Rectangle(612, 792); // 8.5" X 11"
    Document document = new Document(pageSize, 36, 36, 18, 18);
    ServletOutputStream out = null;
    Font fnt = new Font(Font.TIMES_ROMAN, 10, Font.NORMAL);
    Font fntb = new Font(Font.TIMES_ROMAN, 10, Font.BOLD);
    Font fnts = new Font(Font.TIMES_ROMAN, 8, Font.NORMAL);
    Font fntbs = new Font(Font.TIMES_ROMAN, 8, Font.BOLD);
    String spacer = "   ";
    PdfPTable header = getHeader();
    Bond bond = permit.getBond();
    Invoice invoice = permit.getInvoice();
    if (bond == null)
        bond = new Bond();
    if (invoice == null)
        invoice = new Invoice();
    try {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        PdfWriter writer = PdfWriter.getInstance(document, baos);
        String str = "";
        document.open();
        document.add(header);
        //
        // title
        float[] width = { 100f }; // one cell
        PdfPTable table = new PdfPTable(width);
        table.setWidthPercentage(100.0f);
        PdfPCell cell = new PdfPCell(new Phrase("Right Of Way Excavation Permit", fntb));
        //         
        cell.setBorder(Rectangle.BOTTOM);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(cell);
        document.add(table);
        //
        // we need these later
        Paragraph pp = new Paragraph();
        Chunk ch = new Chunk(" ", fntb);
        Phrase phrase = new Phrase();
        //
        float[] widths = { 14f, 20f, 17f, 18f, 13f, 20f }; // percentages
        table = new PdfPTable(widths);
        table.setWidthPercentage(100.0f);
        table.getDefaultCell().setBorder(Rectangle.NO_BORDER);
        //
        // first row
        cell = new PdfPCell(new Phrase("Company", fntb));
        cell.setBorder(Rectangle.NO_BORDER);
        table.addCell(cell);
        cell = new PdfPCell(new Phrase(permit.getCompany().getName(), fnt));
        cell.setBorder(Rectangle.NO_BORDER);
        table.addCell(cell);
        cell = new PdfPCell(new Phrase("Status", fntb));
        cell.setBorder(Rectangle.NO_BORDER);
        table.addCell(cell);
        cell = new PdfPCell(new Phrase(permit.getStatus(), fnt));
        cell.setBorder(Rectangle.NO_BORDER);
        table.addCell(cell);
        cell = new PdfPCell(new Phrase("Permit", fntb));
        cell.setBorder(Rectangle.NO_BORDER);
        table.addCell(cell);
        cell = new PdfPCell(new Phrase(permit.getPermit_num(), fnt));
        cell.setBorder(Rectangle.NO_BORDER);
        table.addCell(cell);
        //
        // 2nd row
        //
        cell = new PdfPCell(new Phrase("Responsible", fntb));
        cell.setBorder(Rectangle.NO_BORDER);
        table.addCell(cell);
        cell = new PdfPCell(new Phrase(permit.getContact().getFullName(), fnt));
        cell.setBorder(Rectangle.NO_BORDER);
        table.addCell(cell);
        cell = new PdfPCell(new Phrase("Inspector", fntb));
        cell.setBorder(Rectangle.NO_BORDER);
        table.addCell(cell);
        cell = new PdfPCell(new Phrase(permit.getReviewer().getFullName(), fnt));
        cell.setBorder(Rectangle.NO_BORDER);
        table.addCell(cell);
        cell = new PdfPCell(new Phrase("Date Issued", fntb));
        cell.setBorder(Rectangle.NO_BORDER);
        table.addCell(cell);
        cell = new PdfPCell(new Phrase(permit.getDate(), fnt));
        cell.setBorder(Rectangle.NO_BORDER);
        table.addCell(cell);
        //
        // 3rd row
        cell = new PdfPCell(new Phrase("Project", fntb));
        cell.setBorder(Rectangle.NO_BORDER);
        table.addCell(cell);
        cell = new PdfPCell(new Phrase(permit.getProject(), fnt));
        cell.setBorder(Rectangle.NO_BORDER);
        table.addCell(cell);
        cell = new PdfPCell(new Phrase("Permit Fee", fntb));
        cell.setBorder(Rectangle.NO_BORDER);
        table.addCell(cell);
        cell = new PdfPCell(new Phrase("$" + permit.getFee(), fnt));
        cell.setBorder(Rectangle.NO_BORDER);
        table.addCell(cell);
        cell = new PdfPCell(new Phrase("Start Date", fntb));
        cell.setBorder(Rectangle.NO_BORDER);
        table.addCell(cell);
        cell = new PdfPCell(new Phrase(permit.getStart_date(), fnt));
        cell.setBorder(Rectangle.NO_BORDER);
        table.addCell(cell);
        //
        // 4th row
        cell = new PdfPCell(new Phrase("Bond Amount", fntb));
        cell.setBorder(Rectangle.NO_BORDER);
        table.addCell(cell);
        cell = new PdfPCell(new Phrase("$" + bond.getAmount(), fnt));
        cell.setBorder(Rectangle.NO_BORDER);
        table.addCell(cell);
        cell = new PdfPCell(new Phrase("Expiration Date", fntb));
        cell.setBorder(Rectangle.NO_BORDER);
        table.addCell(cell);
        cell = new PdfPCell(new Phrase(bond.getExpire_date(), fnt));
        cell.setBorder(Rectangle.NO_BORDER);
        table.addCell(cell);
        cell = new PdfPCell(new Phrase("Invoice", fntb));
        cell.setBorder(Rectangle.NO_BORDER);
        table.addCell(cell);
        cell = new PdfPCell(new Phrase(invoice.getStatus(), fnt));
        cell.setBorder(Rectangle.NO_BORDER);
        table.addCell(cell);
        document.add(table);
        //
        phrase = new Phrase(new Chunk(spacer, fnt));
        document.add(phrase);
        //
        float[] widths2 = { 25f, 15f, 15f, 25f, 10f, 10f };
        table = new PdfPTable(widths2);
        table.setWidthPercentage(100.0f);
        cell = new PdfPCell(new Phrase("Address", fntb));
        table.addCell(cell);
        cell = new PdfPCell(new Phrase("Cut Type", fntb));
        table.addCell(cell);
        cell = new PdfPCell(new Phrase("Utility", fntb));
        table.addCell(cell);
        cell = new PdfPCell(new Phrase("Description", fntb));
        table.addCell(cell);
        cell = new PdfPCell(new Phrase("Width", fntb));
        table.addCell(cell);
        cell = new PdfPCell(new Phrase("Length", fntb));
        table.addCell(cell);
        List<Excavation> list = permit.getExcavations();
        if (list != null && list.size() > 0) {
            for (Excavation one : list) {
                cell = new PdfPCell(new Phrase(one.getAddress().getAddress(), fnt));
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(one.getCut_type(), fnt));
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(one.getUtility_type().getName(), fnt));
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(one.getCut_description(), fnt));
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(one.getWidth(), fnt));
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(one.getLength(), fnt));
                table.addCell(cell);
            }
        }
        document.add(table);
        //
        pp = new Paragraph();
        pp.setIndentationLeft(12);
        pp.setAlignment(Element.ALIGN_LEFT);
        pp.setLeading(0f, 1f);
        ch = new Chunk("\nSpecial Provisions\n", fntb);
        phrase = new Phrase();
        phrase.add(ch);
        ch = new Chunk(permit.getNotes() + "\n", fnt);
        phrase.add(ch);
        pp.add(phrase);
        document.add(pp);
        //
        pp = new Paragraph();
        pp.setIndentationLeft(12);
        pp.setAlignment(Element.ALIGN_LEFT);
        ch = new Chunk("Standards Conditions of Approval\n", fntb);
        phrase = new Phrase();
        phrase.add(ch);
        pp.add(phrase);
        document.add(pp);
        //
        pp = new Paragraph();
        pp.setIndentationLeft(12);
        pp.setAlignment(Element.ALIGN_LEFT);
        pp.setLeading(0f, 1f);
        ch = new Chunk("1 - " + conditions[0] + "\n", fntbs);
        phrase = new Phrase();
        phrase.add(ch);
        pp.add(phrase);
        document.add(pp);
        //
        int jj = 1;
        for (int j = 1; j < conditions.length; j++) {
            jj = j + 1;
            pp = new Paragraph();
            pp.setLeading(0f, 1f);
            pp.setIndentationLeft(12);
            pp.setAlignment(Element.ALIGN_LEFT);
            ch = new Chunk(jj + " - " + conditions[j] + "\n", fnts);
            phrase = new Phrase();
            phrase.add(ch);
            pp.add(phrase);
            document.add(pp);
        }

        pp = new Paragraph();
        pp.setIndentationLeft(20);
        pp.setAlignment(Element.ALIGN_RIGHT);
        ch = new Chunk("\n\n___________________\n", fnt);
        phrase = new Phrase();
        phrase.add(ch);
        pp.add(phrase);
        ch = new Chunk(permit.getReviewer().getFullName(), fnt);
        phrase = new Phrase();
        phrase.add(ch);
        pp.add(phrase);
        document.add(pp);
        document.close();
        writer.close();
        res.setHeader("Expires", "0");
        res.setHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0");
        res.setHeader("Content-Disposition", "attachment; filename=" + fileName);
        res.setHeader("Pragma", "public");
        //
        // setting the content type
        res.setContentType("application/pdf");
        //
        // the contentlength is needed for MSIE!!!
        res.setContentLength(baos.size());
        //
        out = res.getOutputStream();
        if (out != null) {
            baos.writeTo(out);
        }
    } catch (Exception ex) {
        logger.error(ex);
    }

}

From source file:pl.exsio.ca.app.report.terraincard.view.TerrainCardsView.java

License:Open Source License

private Element getPageCounter(int pagesCount, int currentPage) throws Exception {
    Paragraph p = new Paragraph(currentPage + " / " + pagesCount, this.getFont());
    p.setAlignment(Element.ALIGN_RIGHT);
    p.getFont().setSize(8);/*from  w w  w .j a va  2 s  . c o  m*/
    return p;
}

From source file:questions.separators.LineSeparator2.java

public static void main(String[] args) {
    Document document = new Document();
    try {//from w ww  .  j ava  2  s .  com
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(RESULT));
        document.open();

        VerticalPositionMark separator = new LineSeparator(1, 80, Color.RED, Element.ALIGN_RIGHT, -2);

        ColumnText column = new ColumnText(writer.getDirectContent());
        for (int i = 0; i < 5; i++) {
            column.addElement(StarSeparators.TEXT);
            column.addElement(separator);
        }
        column.setSimpleColumn(36, 36, 295, 806);
        column.go();
        column.setSimpleColumn(300, 36, 559, 806);
        column.go();
        document.newPage();

        for (int i = 0; i < 10; i++) {
            document.add(StarSeparators.TEXT);
            document.add(separator);
        }
        document.close();
    } catch (Exception de) {
        de.printStackTrace();
    }
}

From source file:questions.separators.LineSeparator3.java

public static void main(String[] args) {
    Document document = new Document();
    try {//from  ww  w.  ja  v a2  s  . c  om
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(RESULT));
        document.open();

        Paragraph p = new Paragraph(StarSeparators.TEXT);
        VerticalPositionMark separator = new LineSeparator(1, 100, Color.RED, Element.ALIGN_RIGHT, -2);
        p.add(separator);

        ColumnText column = new ColumnText(writer.getDirectContent());
        for (int i = 0; i < 5; i++) {
            column.addElement(p);
        }
        column.setSimpleColumn(36, 36, 295, 806);
        column.go();
        column.setSimpleColumn(300, 36, 559, 806);
        column.go();
        document.newPage();

        for (int i = 0; i < 10; i++) {
            document.add(p);
        }
        document.close();
    } catch (Exception de) {
        de.printStackTrace();
    }
}

From source file:questions.stamppages.PageXofYRightAligned.java

public static void main(String[] args) {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    try {//from   w  w w  .j av a  2s .  c o m
        Document document = new Document();
        PdfWriter.getInstance(document, baos);
        document.open();
        BufferedReader reader = new BufferedReader(new FileReader(RESOURCE));
        String line;
        Paragraph p;
        while ((line = reader.readLine()) != null) {
            p = new Paragraph(line);
            p.setAlignment(Element.ALIGN_JUSTIFIED);
            document.add(p);
            document.newPage();
        }
        reader.close();
        document.close();
    } catch (IOException e) {
        e.printStackTrace();
    } catch (DocumentException e) {
        e.printStackTrace();
    }

    try {
        PdfReader reader = new PdfReader(baos.toByteArray());
        int n = reader.getNumberOfPages();
        PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(RESULT));
        PdfContentByte page;
        Rectangle rect;
        BaseFont bf = BaseFont.createFont();
        for (int i = 1; i < n + 1; i++) {
            page = stamper.getOverContent(i);
            rect = reader.getPageSizeWithRotation(i);
            page.beginText();
            page.setFontAndSize(bf, 12);
            page.showTextAligned(Element.ALIGN_RIGHT, "page " + i + " of " + n, rect.getRight(36),
                    rect.getTop(32), 0);
            page.endText();
        }
        stamper.close();
    } catch (IOException e) {
        e.printStackTrace();
    } catch (DocumentException e) {
        e.printStackTrace();
    }

}

From source file:ro.nextreports.engine.exporter.RtfExporter.java

License:Apache License

private void setCellStyle(Font fnt, Map<String, Object> style, RtfCell cell) {
    if (style != null) {
        updateFont(fnt, style);/*from w  w w  .  j ava 2  s .c o  m*/
        if (style.containsKey(StyleFormatConstants.BACKGROUND_COLOR)) {
            Color val = (Color) style.get(StyleFormatConstants.BACKGROUND_COLOR);
            cell.setBackgroundColor(val);
        }
        if (style.containsKey(StyleFormatConstants.HORIZONTAL_ALIGN_KEY)) {
            if (StyleFormatConstants.HORIZONTAL_ALIGN_LEFT
                    .equals(style.get(StyleFormatConstants.HORIZONTAL_ALIGN_KEY))) {
                cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            }
            if (StyleFormatConstants.HORIZONTAL_ALIGN_RIGHT
                    .equals(style.get(StyleFormatConstants.HORIZONTAL_ALIGN_KEY))) {
                cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
            }
            if (StyleFormatConstants.HORIZONTAL_ALIGN_CENTER
                    .equals(style.get(StyleFormatConstants.HORIZONTAL_ALIGN_KEY))) {
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            }
        }

        if (style.containsKey(StyleFormatConstants.VERTICAL_ALIGN_KEY)) {
            if (StyleFormatConstants.VERTICAL_ALIGN_TOP
                    .equals(style.get(StyleFormatConstants.VERTICAL_ALIGN_KEY))) {
                cell.setVerticalAlignment(Element.ALIGN_TOP);
            }
            if (StyleFormatConstants.VERTICAL_ALIGN_MIDDLE
                    .equals(style.get(StyleFormatConstants.VERTICAL_ALIGN_KEY))) {
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            }
            if (StyleFormatConstants.VERTICAL_ALIGN_BOTTOM
                    .equals(style.get(StyleFormatConstants.VERTICAL_ALIGN_KEY))) {
                cell.setVerticalAlignment(Element.ALIGN_BOTTOM);
            }
        }
        // if (style.containsKey(StyleFormatConstants.PADDING_LEFT)) {
        // Float val = (Float) style.get(StyleFormatConstants.PADDING_LEFT);
        // cell.setPaddingLeft(val);
        // }
        // if (style.containsKey(StyleFormatConstants.PADDING_RIGHT)) {
        // Float val = (Float)
        // style.get(StyleFormatConstants.PADDING_RIGHT);
        // cell.setPaddingRight(val);
        // }
        // if (style.containsKey(StyleFormatConstants.PADDING_TOP)) {
        // Float val = (Float) style.get(StyleFormatConstants.PADDING_TOP);
        // cell.setPaddingTop(val);
        // }
        // if (style.containsKey(StyleFormatConstants.PADDING_BOTTOM)) {
        // Float val = (Float)
        // style.get(StyleFormatConstants.PADDING_BOTTOM);
        // cell.setPaddingBottom(val);
        // }
        cell.setBorderWidth(0);

        Float val = Float.valueOf(1);
        RtfBorderGroup bg = new RtfBorderGroup();
        if (style.containsKey(StyleFormatConstants.BORDER_LEFT)) {
            val = (Float) style.get(StyleFormatConstants.BORDER_LEFT);
            Color color = (Color) style.get(StyleFormatConstants.BORDER_LEFT_COLOR);
            bg.addBorder(Rectangle.LEFT, RtfBorder.BORDER_SINGLE, val, color);
        }
        if (style.containsKey(StyleFormatConstants.BORDER_RIGHT)) {
            val = (Float) style.get(StyleFormatConstants.BORDER_RIGHT);
            Color color = (Color) style.get(StyleFormatConstants.BORDER_RIGHT_COLOR);
            bg.addBorder(Rectangle.RIGHT, RtfBorder.BORDER_SINGLE, val, color);
        }
        if (style.containsKey(StyleFormatConstants.BORDER_TOP)) {
            val = (Float) style.get(StyleFormatConstants.BORDER_TOP);
            Color color = (Color) style.get(StyleFormatConstants.BORDER_TOP_COLOR);
            bg.addBorder(Rectangle.TOP, RtfBorder.BORDER_SINGLE, val, color);
        }
        if (style.containsKey(StyleFormatConstants.BORDER_BOTTOM)) {
            val = (Float) style.get(StyleFormatConstants.BORDER_BOTTOM);
            Color color = (Color) style.get(StyleFormatConstants.BORDER_BOTTOM_COLOR);
            bg.addBorder(Rectangle.BOTTOM, RtfBorder.BORDER_SINGLE, val, color);
        }
        cell.setBorders(bg);

        // cell.setNoWrap(true);
        // if (bandElement != null) {
        // if (bandElement.isWrapText()) {
        // cell.setNoWrap(false);
        // }
        // }
    }
}

From source file:s2s.luna.reports.Report_REP_SOP.java

License:GNU General Public License

@Override
public void doReport() throws DocumentException, IOException, BadElementException, Exception {

    SecurityWrapper Security = SecurityWrapper.getInstance();
    ISopraluogoHome home1 = (ISopraluogoHome) PseudoContext.lookup("SopraluogoBean");
    ISopraluogo bean = home1.findByPrimaryKey(new Long(new Long(request.getParameter("ID"))));
    IAnagrProcedimentoHome home_pro = (IAnagrProcedimentoHome) PseudoContext.lookup("AnagrProcedimentoBean");
    IAnagrProcedimento bean_pro = home_pro.findByPrimaryKey(new Long(bean.getCOD_PRO()));
    IDipendenteHome home_dpd = (IDipendenteHome) PseudoContext.lookup("DipendenteBean");

    ICantiereHome home_can = (ICantiereHome) PseudoContext.lookup("CantiereBean");
    ICantiere bean_can = home_can.findByPrimaryKey(new Long(bean.getCOD_CAN()));

    IAnagrOpereHome home_ope = (IAnagrOpereHome) PseudoContext.lookup("AnagrOpereBean");
    IAnagrOpere bean_ope = null;/*from www .  ja  va 2s  . c om*/
    long COD_OPE = bean.getCOD_OPE();
    if (COD_OPE != 0) {
        bean_ope = home_ope.findByPrimaryKey(COD_OPE);
    }

    lCOD_AZL = Security.getAziendaR();
    IAziendaHome home_az = (IAziendaHome) PseudoContext.lookup("AziendaBean");
    IAzienda bean_az = home_az.findByPrimaryKey(new Long(lCOD_AZL));

    initDocument("the doc",
            // Intestazione - Cella a sinistra
            bean_pro.getstrDES(),
            // Intestazione - Cella centrale
            bean_can.getNOM_CAN() + " - " + bean.getNUM_SOP(),
            // Pi di pagina Cella a sinistra
            bean_az.getRAG_SCL_AZL(),
            // Pi di pagina Cella a destra
            formatPlain(bean.getDAT_SOP()));

    m_handler.bShowDate = false;

    // LOGO E TITOLO
    {
        CenterMiddleTable tbl = new CenterMiddleTable(2);
        tbl.setDefaultCellBorder(0);
        int width[] = { 15, 75 };
        tbl.setWidths(width);
        if (IncludeLogo) {
            Image png = loadImage("LOGO");
            png.scalePercent(50);
            png.setAlignment(Image.ALIGN_LEFT);
            Cell cImage = new Cell(png);
            tbl.addCell(cImage);
        } else {
            tbl.addCell("");
        }
        CenterMiddleTable tbl2 = new CenterMiddleTable(1);
        tbl2.setDefaultCellBorder(0);
        tbl2.addCellBU(ApplicationConfigurator.CUSTOMER_NAME.toUpperCase(), 15);
        tbl2.addCellBU(ApplicationConfigurator.LanguageManager.getString("Coordinamento.sicurezza.cantieri")
                .toUpperCase(), 15);

        Cell cText = new Cell(tbl2);
        tbl.addCell(cText);
        m_document.add(tbl);
    }

    writeIndent();
    {
        CenterMiddleTable tbl = new CenterMiddleTable(1);
        if (bStandAlone) {
        }
        m_document.add(tbl);
    }

    // DATI DEL SOPRALLUOGO
    {
        CenterMiddleTable tbl = new CenterMiddleTable(4);
        tbl.toLeft();
        int width[] = { 30, 20, 25, 25 };
        tbl.setWidths(width);
        tbl.addCell(
                ApplicationConfigurator.LanguageManager.getString("Sopralluogo.N") + "  " + bean.getNUM_SOP(),
                defaultFontSize);
        tbl.addCell(ApplicationConfigurator.LanguageManager.getString("del") + "  "
                + formatPlain(bean.getDAT_SOP()), defaultFontSize);
        tbl.addCell(
                ApplicationConfigurator.LanguageManager.getString("Inizio.h")
                        + (bean.getORA_INI() != null ? bean.getORA_INI().toString().substring(0, 5) : ""),
                defaultFontSize);
        tbl.addCell(
                ApplicationConfigurator.LanguageManager.getString("Fine.h")
                        + (bean.getORA_FIN() != null ? bean.getORA_FIN().toString().substring(0, 5) : ""),
                defaultFontSize);
        m_document.add(tbl);
    }
    {
        CenterMiddleTable tbl = new CenterMiddleTable(3);
        tbl.toLeft();
        int width[] = { 34, 33, 33 };
        tbl.setWidths(width);
        tbl.addCell(ApplicationConfigurator.LanguageManager.getString("Linea") + ":  " + bean_pro.getstrDES(),
                defaultFontSize);
        tbl.addCell(
                ApplicationConfigurator.LanguageManager.getString("Stazione") + ":  " + bean_can.getNOM_CAN(),
                defaultFontSize);
        tbl.addCell(ApplicationConfigurator.LanguageManager.getString("Opera") + ":  "
                + (bean_ope != null ? bean_ope.getstrNOM_OPE() : ""), defaultFontSize);
        m_document.add(tbl);
    }

    // PRESENTI AZIENDA
    {
        CenterMiddleTable tbl = new CenterMiddleTable(2);
        tbl.toLeft();
        int width[] = { 25, 70 };
        tbl.setWidths(width);
        tbl.border();
        java.util.Collection col = home_dpd.getDipendentiBySOP_View(lCOD_SOP);
        tbl.addCell(ApplicationConfigurator.LanguageManager.getString("Presenti.RM"), defaultFontSize);
        java.util.Iterator it = col.iterator();
        String presentiRM = "";
        while (it.hasNext()) {
            DipendentiBySOP_View obj = (DipendentiBySOP_View) it.next();
            presentiRM += (StringManager.isEmpty(presentiRM) ? "" : ", ") + obj.COG_DPD + " " + obj.NOM_DPD;
        }
        tbl.addCell(presentiRM, defaultFontSize);
        m_document.add(tbl);
    }

    // PRESENTI IMPRESA
    {
        CenterMiddleTable tbl = new CenterMiddleTable(2);
        tbl.toLeft();
        tbl.setPadding(1 / 2);
        int width[] = { 25, 70 };
        tbl.setWidths(width);
        tbl.border();
        java.util.Collection col = home_dpd.getDipendentiEstBySOP_View(lCOD_SOP);
        java.util.Iterator it = col.iterator();
        tbl.addCell(ApplicationConfigurator.LanguageManager.getString("Presenti.impresa"), defaultFontSize);
        String presentiIMP = "";
        while (it.hasNext()) {
            DipendentiBySOP_View obj = (DipendentiBySOP_View) it.next();
            presentiIMP += (StringManager.isEmpty(presentiIMP) ? "" : ", ") + obj.COG_DPD + " " + obj.NOM_DPD
                    + " (" + obj.IMPRESA + ")";
        }
        tbl.addCell(presentiIMP, defaultFontSize);
        m_document.add(tbl);
    }
    writeLine();

    // CONSTATAZIONI
    {
        CenterMiddleTable tbl = new CenterMiddleTable(1);
        tbl.toLeft();
        int width[] = { 100 };
        tbl.setWidths(width);
        tbl.addHeaderCellB2(ApplicationConfigurator.LanguageManager.getString("CONSTATAZIONI"), 1, false, 11);
        m_document.add(tbl);
    }
    {
        CenterMiddleTable tbl = new CenterMiddleTable(2);
        tbl.toLeft();
        int width[] = { 5, 85 };
        tbl.setWidths(width);
        java.util.Collection col = home1.getConstatazioniSop(lCOD_SOP);
        java.util.Iterator it = col.iterator();
        tbl.setWidths(width);
        String constElementSeparator = " - ";
        Alphabet c = new Alphabet();
        String REV1 = c.getNextElement("1");
        while (it.hasNext()) {
            jbConstatazione obj = (jbConstatazione) it.next();

            // Numerazione alfabetica
            Cell cell = new Cell(new Phrase(Formatter.format(REV1), REPORT_SETTINGS.ftText9B));
            cell.setVerticalAlignment(Element.ALIGN_TOP);
            tbl.addCell(cell);

            // Constatazione
            tbl.addCell(Formatter.format(
                    (StringManager.isNotEmpty(obj.sRAG_SCL_DTE) ? obj.sRAG_SCL_DTE + constElementSeparator : "")
                            + (StringManager.isNotEmpty(obj.sNOM_ATT)
                                    ? obj.sNOM_ATT + constElementSeparator
                                    : "")
                            + (StringManager.isNotEmpty(obj.sDES_LIB) ? obj.sDES_LIB + constElementSeparator
                                    : "")
                            + obj.sDESC),
                    defaultFontSize);
            REV1 = c.getNextElement(REV1);
        }
        m_document.add(tbl);
    }
    writeLine();

    // DISPOSIZIONI
    {
        CenterMiddleTable tbl = new CenterMiddleTable(1);
        tbl.toLeft();
        int width[] = { 85 };
        tbl.setWidths(width);
        tbl.addHeaderCellB2(ApplicationConfigurator.LanguageManager.getString("DISPOSIZIONI"), 1, false, 11);
        m_document.add(tbl);
    }
    {
        CenterMiddleTable tbl = new CenterMiddleTable(2);
        tbl.toLeft();
        int width[] = { 5, 85 };
        java.util.Collection col = home1.getConstatazioniSop(lCOD_SOP);
        java.util.Iterator it = col.iterator();
        tbl.setWidths(width);
        Alphabet c = new Alphabet();
        String REV2 = c.getNextElement("1");
        while (it.hasNext()) {
            jbConstatazione obj = (jbConstatazione) it.next();

            // Numerazione alfabetica
            Cell cell = new Cell(new Phrase(Formatter.format(REV2), REPORT_SETTINGS.ftText9B));
            cell.setVerticalAlignment(Element.ALIGN_TOP);
            tbl.addCell(cell);

            // Disposizione generata
            tbl.addCell(Formatter.format(obj.sDIS_GEN), defaultFontSize);
            REV2 = c.getNextElement(REV2);
        }
        m_document.add(tbl);
    }

    // FIRME
    // Spazio per le firme
    for (int i = 1; i <= 5; i++) {
        writeLine();
    }
    {
        CenterMiddleTable tbl = new CenterMiddleTable(2);
        int width[] = { 50, 50 };
        tbl.setWidths(width);
        tbl.setDefaultCellBorder(0);

        // Firme del personale dell'azienda
        Cell cell = new Cell(
                new Phrase(ApplicationConfigurator.CUSTOMER_NAME.toUpperCase(), REPORT_SETTINGS.ftText9));
        cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        tbl.addCell(cell);

        // Firme del personale delle imprese
        Cell cell2 = new Cell(
                new Phrase(ApplicationConfigurator.LanguageManager.getString("Impresa").toUpperCase(),
                        REPORT_SETTINGS.ftText9));
        cell2.setHorizontalAlignment(Element.ALIGN_RIGHT);
        tbl.addCell(cell2);

        m_document.add(tbl);
    }

    // FOTO
    {
        Collection<jbMedia> listaFoto = home1.getMediaSOP(lCOD_SOP);
        if (listaFoto != null && listaFoto.size() > 0) {

            // STAMPA L'INDICE DELLE FOTO.
            boolean firstFoto = true;
            int fotoIndex = 0;
            for (jbMedia foto : listaFoto) {
                try {
                    // Verifica che l'immagine sia in un formato supportato.
                    Image.getInstance(foto.mediaData);
                    fotoIndex++;
                    if (firstFoto) {
                        writePage();
                        writeTitle(ApplicationConfigurator.LanguageManager.getString("Indice.foto.allegate"));
                        firstFoto = false;
                    }
                    writeLine();
                    // Stampo il progessivo della foto, nel formato "Foto n".
                    writeText2Bold(ApplicationConfigurator.LanguageManager.getString("Foto") + " " + fotoIndex);
                    // Stampo il "nome" o se questo  assente, "il nome file".
                    writeText2(StringManager.isNotEmpty(foto.sNOM_MED) ? Formatter.format(foto.sNOM_MED)
                            : Formatter.format(foto.sFile));
                    // Stampo, se presente, la "descrizione".
                    writeText2(StringManager.isNotEmpty(foto.sDES_MED) ? Formatter.format(foto.sDES_MED) : "");
                } catch (Exception ex) {
                    // Eccezione silenziosa.
                    // Gestisce il caso in cui l'allegato non sia un immagine
                }
            }
            // STAMPA LE FOTO.
            firstFoto = true;
            fotoIndex = 0;
            byte SPACE_FOR_TITLE = 20;
            byte SPACE_FOR_BOTTOM_MARGIN = 20;
            boolean strictImageSequence = m_writer.isStrictImageSequence();
            m_writer.setStrictImageSequence(true);
            for (jbMedia foto : listaFoto) {
                Element image = prepareImage(m_document, foto.mediaData);
                if (image != null) {
                    fotoIndex++;
                    if (firstFoto) {
                        writePage();
                        firstFoto = false;
                    }
                    if (m_document.getPageSize().getHeight() - m_document.topMargin()
                            + 20 < getAvailablePageSpace(m_document, m_writer)) {
                        writeLine();
                    }
                    if (getAvailablePageSpace(m_document, m_writer)
                            - (SPACE_FOR_TITLE + SPACE_FOR_BOTTOM_MARGIN) < ((Image) image).getScaledHeight()) {
                        writePage();
                    }
                    // Stampo il progessivo della foto, nel formato "Foto n".
                    writeText2(ApplicationConfigurator.LanguageManager.getString("Foto") + " " + fotoIndex);
                    // Stampo l'immagine.
                    m_document.add(image);
                }
            }
            m_writer.setStrictImageSequence(strictImageSequence);
        }
    }
    // DOCUMENTI ALLEGATI
    Collection<DocumentiAssociati_Sopralluogo_View> listadocumenti = home1
            .getDocumentiCantiereSOP_STAMPA(lCOD_SOP);
    if (listadocumenti != null && listadocumenti.size() > 0) {

        // STAMPA L'INDICE DEI DOCUMENTI ALLEGATI
        // i documenti allegati sono quei documenti la cui tipologia risulta avere attivo
        //il flag di stampa in sopralluogo.
        boolean firstdocument = true;
        int documentIndex = 0;
        for (DocumentiAssociati_Sopralluogo_View documento : listadocumenti) {
            try {
                // Verifica che l'immagine sia in un formato supportato.
                documentIndex++;
                if (firstdocument) {
                    writePage();
                    writeTitle(ApplicationConfigurator.LanguageManager.getString("Indice.documenti.allegati"));
                    firstdocument = false;
                }
                writeLine();
                // Stampo il "titolo" del documento.
                writeText3Bold(documentIndex + ")"
                        + (StringManager.isNotEmpty(documento.TIT_DOC) ? Formatter.format(documento.TIT_DOC)
                                : Formatter.format(documento.NOM_TPL_DOC)));
                // Stampo, se presente, la "descrizione".
                if (!(documento.DES).equals("")) {
                    writeLine();
                }
                writeText3_3(StringManager.isNotEmpty(documento.DES) ? Formatter.format(documento.DES) : "");

                IAnagrDocumentoHome doc_home = (IAnagrDocumentoHome) PseudoContext.lookup("AnagrDocumentoBean");
                AnagDocumentoFileInfo fileInfo = null;
                AnagDocumentoFileInfo fileInfoLink = null;
                fileInfo = doc_home.getFileInfoU("", documento.lCOD_DOC);
                fileInfoLink = doc_home.getFileInfoULink("", documento.lCOD_DOC);

                // se esiste stampo il file allegato
                if (fileInfo != null) {
                    writeLine();
                    writeText3_3(Formatter.format("   " + "File Allegato:  " + fileInfo.strName));
                } else {
                    writeLine();
                    writeText3_3(Formatter.format("   " + "File Allegato:  "));
                }

                // se esiste stampo il file link allegato
                if (fileInfoLink != null) {
                    writeText3_3(Formatter.format("   " + "File Link Allegato:  " + fileInfoLink.strName));
                } else {
                    writeText3_3(Formatter.format("   " + "File Link Allegato:  "));
                }
                writeLine();
            } catch (Exception ex) {
                // Eccezione silenziosa.
                // Gestisce il caso in cui l'allegato non sia un immagine
            }

        }
        writePage();
        // Stampa documenti allegati
        boolean endWithNewPage = false;
        endWithNewPage = StampaDocumenti(home1, bean.getCOD_SOP(), m_document, m_writer);

    }
    closeDocument();
}

From source file:s2s.report.MiddleTable.java

License:GNU General Public License

public void toRight() {
    this.setDefaultHorizontalAlignment(Element.ALIGN_RIGHT);
}

From source file:s2s.report.MyPageEvents.java

License:GNU General Public License

@Override
public void onEndPage(PdfWriter writer, Document m_document) {
    if ((strBottomLeft.length() == 0) && (strBottomRight.length() == 0) && (bShowDate == false)
            && strFirstBottomLeft.length() == 0 && strFirstBottomRight.length() == 0) {
        return;/*from  ww  w . j av a  2s.c om*/
    }
    int iColumns = 0;
    PdfPTable tbl1 = null;
    PdfPTable tbl2 = null;

    // Stampa gli eventuali valori delle celle (sinistra e destra) di un 
    // ulteriore pi di pagina, precedente a quello standard, senza bordi di 
    // tabella.
    if (strFirstBottomLeft.length() != 0 || strFirstBottomRight.length() != 0) {
        if (strFirstBottomLeft.length() != 0) {
            iColumns++;
        }
        if (strFirstBottomRight.length() != 0) {
            iColumns++;
        }
        tbl1 = new PdfPTable(iColumns);
        tbl1.setTotalWidth(m_rect.getWidth() - 60);
        if (strFirstBottomLeft.length() != 0) {
            PdfPCell cell = new PdfPCell(new Phrase(strFirstBottomLeft, REPORT_SETTINGS.ftText10));
            cell.setBorder(Rectangle.NO_BORDER);
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            tbl1.addCell(cell);
        }
        if (strFirstBottomRight.length() != 0) {
            PdfPCell cell = new PdfPCell(new Phrase(strFirstBottomRight, REPORT_SETTINGS.ftText10));
            cell.setBorder(Rectangle.NO_BORDER);
            cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
            tbl1.addCell(cell);
        }
    }

    // Stampa gli eventuali valori delle celle (sinistra e destra) 
    // del pi di pagina standard.
    if ((strBottomLeft.length() != 0) || (strBottomRight.length() != 0) || (bShowDate == true)) {
        iColumns = 0;
        if (strBottomLeft.length() != 0) {
            iColumns++;
        }
        if (strBottomRight.length() != 0) {
            iColumns++;
        }
        if (bShowDate) {
            iColumns++;
        }

        tbl2 = new PdfPTable(iColumns);
        tbl2.setTotalWidth(m_rect.getWidth() - 60);
        if (strBottomLeft.length() != 0) {
            tbl2.addCell(new Phrase(strBottomLeft, REPORT_SETTINGS.ftText10));
        }
        if (strBottomRight.length() != 0) {
            tbl2.addCell(new Phrase(strBottomRight, REPORT_SETTINGS.ftText10));
        }
        if (bShowDate) {
            PdfPCell pc = new PdfPCell(new Phrase(
                    Formatter.format(new java.sql.Date(System.currentTimeMillis())), REPORT_SETTINGS.ftText11));
            pc.setHorizontalAlignment(Element.ALIGN_CENTER);
            tbl2.addCell(pc);
        }
    }

    // Scrive il pi di pagina precedente a quello standard
    if (tbl1 != null) {
        tbl1.writeSelectedRows(0, -1, 30, (tbl2 != null ? 150 : 100), cb);
    }
    // Scrive il pi di pagina standard
    if (tbl2 != null) {
        tbl2.writeSelectedRows(0, -1, 30, 50, cb);
    }
}