Example usage for com.lowagie.text Cell setHorizontalAlignment

List of usage examples for com.lowagie.text Cell setHorizontalAlignment

Introduction

In this page you can find the example usage for com.lowagie.text Cell setHorizontalAlignment.

Prototype

public void setHorizontalAlignment(String alignment) 

Source Link

Document

Sets the alignment of this cell.

Usage

From source file:org.kuali.kfs.module.cam.report.DepreciationReport.java

License:Open Source License

/**
 * This method adds the log lines into the report
 * // w w  w.  j a  v a  2 s . co m
 * @param reportLog
 */
private void generateReportLogBody(List<String[]> reportLog) {
    try {
        Font font = FontFactory.getFont(FontFactory.HELVETICA, 9, Font.NORMAL);
        int columnwidths[];
        columnwidths = new int[] { 40, 15 };

        Table aTable = new Table(2, linesPerPage);
        int rowsWritten = 0;
        for (String[] columns : reportLog) {
            if (pageNumber == 0 || line >= linesPerPage) {
                if (pageNumber > 0) {
                    this.document.add(aTable);
                }
                int elementsLeft = reportLog.size() - rowsWritten;
                int rowsNeeded = (elementsLeft >= linesPerPage ? linesPerPage : elementsLeft);
                this.document.newPage();

                this.generateColumnHeaders();

                aTable = new Table(2, rowsNeeded); // 12 columns, 11 rows.

                aTable.setAutoFillEmptyCells(true);
                aTable.setPadding(3);
                aTable.setWidths(columnwidths);
                aTable.setWidth(100);
                aTable.setBorder(Rectangle.NO_BORDER);

                line = 0;
                pageNumber++;
            }
            rowsWritten++;

            Cell cell;
            cell = new Cell(new Phrase(columns[0], font));
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            aTable.addCell(cell);

            cell = new Cell(new Phrase(columns[1], font));
            cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            aTable.addCell(cell);
            line++;
        }
        this.document.add(aTable);
    } catch (DocumentException de) {
        throw new RuntimeException(
                "DepreciationReport.generateReportLogBody(List<String[]> reportLog) - error: "
                        + de.getMessage());
    }
}

From source file:org.kuali.kfs.module.cam.report.DepreciationReport.java

License:Open Source License

/**
 * This method creates a report group for the error message on the report
 * // w  w  w  . j  ava2  s. com
 * @throws DocumentException
 */
private void generateErrorColumnHeaders() throws DocumentException {
    try {
        int headerwidths[] = { 60 };

        Table aTable = new Table(1, 1); // 2 columns, 1 rows.

        aTable.setAutoFillEmptyCells(true);
        aTable.setPadding(3);
        aTable.setWidths(headerwidths);
        aTable.setWidth(100);

        Cell cell;

        Font font = FontFactory.getFont(FontFactory.HELVETICA, 9, Font.NORMAL);

        cell = new Cell(new Phrase("Error(s)", font));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell.setGrayFill(0.9f);
        aTable.addCell(cell);

        this.document.add(aTable);

    } catch (Exception e) {
        throw new RuntimeException(
                "DepreciationReport.generateErrorColumnHeaders() - Error: " + e.getMessage());
    }
}

From source file:org.kuali.kfs.module.cam.report.DepreciationReport.java

License:Open Source License

/**
 * This method creates the headers for the report statistics
 *//*from w  ww.  jav  a 2 s. c o  m*/
private void generateColumnHeaders() {
    try {
        int headerwidths[] = { 40, 15 };

        Table aTable = new Table(2, 1); // 2 columns, 1 rows.

        aTable.setAutoFillEmptyCells(true);
        aTable.setPadding(3);
        aTable.setWidths(headerwidths);
        aTable.setWidth(100);

        Cell cell;

        Font font = FontFactory.getFont(FontFactory.HELVETICA, 9, Font.NORMAL);

        cell = new Cell(new Phrase(SpringContext.getBean(ConfigurationService.class).getPropertyValueAsString(
                CamsKeyConstants.Depreciation.MSG_REPORT_DEPRECIATION_HEADING1), font));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell.setGrayFill(0.9f);
        aTable.addCell(cell);

        cell = new Cell(new Phrase(SpringContext.getBean(ConfigurationService.class).getPropertyValueAsString(
                CamsKeyConstants.Depreciation.MSG_REPORT_DEPRECIATION_HEADING2), font));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell.setGrayFill(0.9f);
        aTable.addCell(cell);
        this.document.add(aTable);

    } catch (Exception e) {
        throw new RuntimeException("DepreciationReport.generateColumnHeaders() - Error: " + e.getMessage());
    }
}

From source file:org.netxilia.server.rest.pdf.SheetPdfProvider.java

License:Open Source License

/**
 * Returns a formatted cell for the given value.
 * //  www.  j a va 2  s  .co  m
 * @param value
 *            cell value
 * @return Cell
 * @throws BadElementException
 *             errors while generating content
 */
private Cell getCell(String value, Font font, int horizAlign, int width) throws BadElementException {
    Cell cell = new Cell(new Chunk(StringUtils.trimToEmpty(value), font));
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell.setHorizontalAlignment(horizAlign);
    cell.setLeading(8);
    if (width > 0) {
        cell.setWidth(width);
    }
    return cell;
}

From source file:org.pentaho.reporting.engine.classic.core.modules.output.table.rtf.helper.RTFPrinter.java

License:Open Source License

private void computeCellStyle(final RenderBox content, final Cell cell) {
    final ElementAlignment verticalAlign = content.getNodeLayoutProperties().getVerticalAlignment();
    if (ElementAlignment.BOTTOM.equals(verticalAlign)) {
        cell.setVerticalAlignment(Element.ALIGN_BOTTOM);
    } else if (ElementAlignment.MIDDLE.equals(verticalAlign)) {
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    } else {/*  w ww.ja  v  a  2  s .  co m*/
        cell.setVerticalAlignment(Element.ALIGN_TOP);
    }

    final ElementAlignment textAlign = (ElementAlignment) content.getStyleSheet()
            .getStyleProperty(ElementStyleKeys.ALIGNMENT);
    if (ElementAlignment.RIGHT.equals(textAlign)) {
        cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
    } else if (ElementAlignment.JUSTIFY.equals(textAlign)) {
        cell.setHorizontalAlignment(Element.ALIGN_JUSTIFIED);
    } else if (ElementAlignment.CENTER.equals(textAlign)) {
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    } else {
        cell.setHorizontalAlignment(Element.ALIGN_LEFT);
    }
}

From source file:org.sigmah.server.report.renderer.itext.ThemeHelper.java

License:Open Source License

public static Cell columnHeaderCell(String label, boolean leaf, int hAlign) throws BadElementException {
    Paragraph para = new Paragraph(label);
    para.setFont(new Font(Font.HELVETICA, 10, Font.NORMAL, Color.WHITE));

    Cell cell = new Cell();
    cell.addElement(para);/*from www  .j  a v a  2  s  .  co  m*/
    cell.setHorizontalAlignment(hAlign);
    cell.setHeader(true);
    cell.setVerticalAlignment(Cell.ALIGN_BOTTOM);
    cell.setBackgroundColor(new Color(55, 96, 145));

    cell.setBorderWidth(0);

    return cell;
}

From source file:org.sigmah.server.report.renderer.itext.ThemeHelper.java

License:Open Source License

/**
 * Renders a Cell for/* w w  w  .  java 2  s .c o m*/
 *
 * @param label
 * @param header
 * @param depth
 * @param leaf
 * @param horizantalAlignment
 * @return
 * @throws BadElementException
 */
public static Cell bodyCell(String label, boolean header, int depth, boolean leaf, int horizantalAlignment)
        throws BadElementException {

    Cell cell = new Cell();
    cell.setHorizontalAlignment(horizantalAlignment);

    if (label != null) {
        Paragraph para = new Paragraph(label);
        Font font = new Font(Font.HELVETICA, 10, Font.NORMAL, Color.BLACK);
        if (depth == 0 && !leaf) {
            font.setColor(Color.WHITE);
        }
        para.setFont(font);
        para.setIndentationLeft(5.4f + (header ? 12 * depth : 0));
        cell.addElement(para);
    }

    cell.setBorderWidthLeft(0f);
    cell.setBorderWidthRight(0);
    cell.setBorderWidthTop(0);

    if (!leaf && depth == 0) {
        cell.setBackgroundColor(new Color(149, 179, 215)); // #95B3D7
        cell.setBorderWidthBottom(0.5f);
        cell.setBorderColorBottom(new Color(219, 229, 241)); // #DBE5F1
    } else if (!leaf && depth == 1) {
        cell.setBackgroundColor(new Color(219, 229, 241));
        cell.setBorderWidthBottom(0.5f);
        cell.setBorderColorBottom(new Color(79, 129, 189));
    } else {
        cell.setBorderWidthBottom(0.5f);
        cell.setBorderColorBottom(new Color(219, 229, 241));
        cell.setBorderWidthTop(0.5f);
        cell.setBorderColorTop(new Color(219, 229, 241));
    }

    return cell;
}

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;/*ww w  .j av a2  s  . 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.luna.reports.Report_REP_VAL_RSO_DVR.java

License:GNU General Public License

@Override
public void doReport() throws DocumentException, IOException, BadElementException, Exception {
    SecurityWrapper Security = SecurityWrapper.getInstance();
    IAziendaHome home = (IAziendaHome) PseudoContext.lookup("AziendaBean");
    IAzienda bean = home.findByPrimaryKey(new Long(lCOD_AZL));

    initDocument("the doc", null,
            ApplicationConfigurator.LanguageManager.getString("Tabella.valutazione.rischio"),
            bean.getRAG_SCL_AZL(), null);

    writeIndent();//from w w  w.ja va  2  s  .  c  o m
    {
        ZREPORT_SETTINGS repSetting = new ZREPORT_SETTINGS();
        int tableFontSize = 10;
        int numberOfColumns = 4;
        short sMOD_CLC_RSO = Security.getAziendaModalitaCalcoloRischio();
        numberOfColumns = (sMOD_CLC_RSO == Azienda_MOD_CLC_RSO.MOD_EXTENDED) ? numberOfColumns + 2
                : numberOfColumns;

        // Intestazione generale
        CenterMiddleTable tblTopHeader = new CenterMiddleTable(1);
        tblTopHeader.toCenter();
        tblTopHeader.addHeaderCellB(
                ApplicationConfigurator.LanguageManager.getString("Tabella.valutazione.rischio"));
        m_document.add(tblTopHeader);

        writeLine();

        // Intestazione di dettaglio
        CenterMiddleTable tblData = new CenterMiddleTable(numberOfColumns);
        if (sMOD_CLC_RSO == Azienda_MOD_CLC_RSO.MOD_BASE) {
            int width[] = { 55, 15, 15, 15 };
            tblData.setWidths(width);
        } else if (sMOD_CLC_RSO == Azienda_MOD_CLC_RSO.MOD_EXTENDED) {
            int width[] = { 40, 12, 12, 12, 12, 12 };
            tblData.setWidths(width);
        }
        tblData.toCenter();
        tblData.toMiddle();

        tblData.addHeaderCellB(ApplicationConfigurator.LanguageManager.getString("Rischio"), 1, true, 12);
        tblData.addHeaderCellFirstBold(
                ApplicationConfigurator.LanguageManager.getString("P") + "\n"
                        + StringManager
                                .bracket(ApplicationConfigurator.LanguageManager.getString("Probabilit")),
                1, true, 12, 10);
        tblData.addHeaderCellFirstBold(
                ApplicationConfigurator.LanguageManager.getString("D") + "\n"
                        + StringManager
                                .bracket(ApplicationConfigurator.LanguageManager.getString("Entit.del.danno")),
                1, true, 12, 10);
        if (sMOD_CLC_RSO == Azienda_MOD_CLC_RSO.MOD_EXTENDED) {
            tblData.addHeaderCellFirstBold(ApplicationConfigurator.LanguageManager.getString("F") + "\n"
                    + StringManager.bracket(ApplicationConfigurator.LanguageManager
                            .getString("Frequenza.dell'attivit.a.rischio")),
                    1, true, 12, 10);
            tblData.addHeaderCellFirstBold(
                    ApplicationConfigurator.LanguageManager.getString("N") + "\n"
                            + StringManager.bracket(ApplicationConfigurator.LanguageManager
                                    .getString("Numero.di.incidenti/infortuni.(negli.ultimi.3.anni)")),
                    1, true, 12, 10);
        }
        tblData.addHeaderCellFirstBold(
                ApplicationConfigurator.LanguageManager.getString("R") + "\n" + StringManager.bracket(
                        ApplicationConfigurator.LanguageManager.getString("Stima.numerica.del.rischio")),
                1, true, 12, 10);

        // Dati
        IRischioHome home_rso = (IRischioHome) PseudoContext.lookup("RischioBean");
        Collection<Rischio_Nome_Fattore_View> listaRischi = home_rso.findEx(lCOD_AZL, null, null, null, null,
                null, null, null, null, null, null, null, null, 0);
        for (Rischio_Nome_Fattore_View rischio : listaRischi) {
            Cell rischioCell = new Cell(new Phrase(rischio.strNOM_RSO, repSetting.ftText10));
            rischioCell.setHorizontalAlignment(Element.ALIGN_LEFT);
            tblData.addCell(rischioCell);
            tblData.addCell(Long.toString(rischio.PRB_EVE_LES), tableFontSize);
            tblData.addCell(Long.toString(rischio.ENT_DAN), tableFontSize);
            if (sMOD_CLC_RSO == Azienda_MOD_CLC_RSO.MOD_EXTENDED) {
                tblData.addCell(Long.toString(rischio.FRQ_RIP_ATT_DAN), tableFontSize);
                tblData.addCell(Long.toString(rischio.NUM_INC_INF), tableFontSize);
            }
            tblData.addCellB(Long.toString(rischio.STM_NUM_RSO), tableFontSize, 1);
        }
        m_document.add(tblData);
    }
    closeDocument();
}

From source file:se.idega.idegaweb.commune.school.report.business.ReportPDFWriter.java

License:Open Source License

/**
 * Builds the report column headers./*from   w  w  w  .jav  a2  s .c  om*/
 */
protected void buildColumnHeaders(Table table) throws BadElementException {
    Header[] headers = this._reportModel.getColumnHeaders();
    com.lowagie.text.Cell cell = new com.lowagie.text.Cell();
    cell.setRowspan(2);
    table.addCell(cell, new Point(0, 0));
    int column = 1;
    for (int i = 0; i < headers.length; i++) {
        Header header = headers[i];
        Header[] children = header.getChildren();
        if (children == null) {
            String s = null;
            if (header.getHeaderType() == Header.HEADERTYPE_COLUMN_NONLOCALIZED_HEADER) {
                s = header.getLocalizationKey();
            } else {
                s = localize(header.getLocalizationKey(), header.getLocalizationKey());
            }
            cell = new com.lowagie.text.Cell(new Phrase(s, this._normalFont));
            cell.setRowspan(2);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setVerticalAlignment(Element.ALIGN_BOTTOM);
            table.addCell(cell, new Point(0, column));
            setColSize(s, column, true);
            column++;
        } else {
            String s = null;
            if (header.getHeaderType() == Header.HEADERTYPE_COLUMN_NONLOCALIZED_HEADER) {
                s = header.getLocalizationKey();
            } else {
                s = localize(header.getLocalizationKey(), header.getLocalizationKey());
            }
            cell = new com.lowagie.text.Cell(new Phrase(s, this._normalFont));
            cell.setColspan(children.length);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(cell, new Point(0, column));
            if (children.length == 1) {
                setColSize(s, column, false);
            }
            for (int j = 0; j < children.length; j++) {
                Header child = children[j];
                s = null;
                if (child.getHeaderType() == Header.HEADERTYPE_COLUMN_NONLOCALIZED_HEADER) {
                    s = child.getLocalizationKey();
                } else {
                    s = localize(child.getLocalizationKey(), child.getLocalizationKey());
                }
                cell = new com.lowagie.text.Cell(new Phrase(s, this._normalFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setVerticalAlignment(Element.ALIGN_BOTTOM);
                cell.setNoWrap(true);
                table.addCell(cell, new Point(1, column + j));
                setColSize(s, column + j, false);
            }
            column += children.length;
        }
    }
}