Example usage for com.lowagie.text Phrase Phrase

List of usage examples for com.lowagie.text Phrase Phrase

Introduction

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

Prototype

private Phrase(boolean dummy) 

Source Link

Document

Constructs a Phrase that can be used in the static getInstance() method.

Usage

From source file:it.eng.spagobi.engines.worksheet.exporter.DataSourceTablePDFExporter.java

License:Mozilla Public License

/**
 * Build the content of the table/*from   www  . java2  s .co  m*/
 * @param dataStore
 * @param table the table with the headers
 * @throws BadElementException
 */
public void buildTableContent(IDataStore dataStore, PdfPTable table) throws BadElementException {
    logger.debug("IN: building the conetent of the table");
    boolean oddRows = true;
    PdfPCell cell;

    Iterator it = dataStore.iterator();

    IMetaData d = dataStore.getMetaData();

    while (it.hasNext()) {//for each record
        IRecord record = (IRecord) it.next();
        List fields = record.getFields();
        int length = fields.size();
        //build the row
        for (int fieldIndex = 0; fieldIndex < length; fieldIndex++) {
            IField f = (IField) fields.get(fieldIndex);
            IFieldMetaData fieldMetaData = d.getFieldMeta(fieldIndex);
            String decimalPrecision = (String) fieldMetaData.getProperty(IFieldMetaData.DECIMALPRECISION);
            if (f == null || f.getValue() == null) {
                cell = new PdfPCell(new Phrase(""));
            } else {
                Class c = d.getFieldType(fieldIndex);
                cell = new PdfPCell(new Phrase(formatPDFCell(c, f, decimalPrecision)));
                if (oddRows) {
                    cell.setBackgroundColor(oddrowsBackgroundColor);
                } else {
                    cell.setBackgroundColor(evenrowsBackgroundColor);
                }
            }
            cell.setBorderColor(cellsBorderColor);
            table.addCell(cell);

        }
        oddRows = !oddRows;
    }
    logger.debug("Out: built the conetent of the table");
}

From source file:it.eng.spagobi.engines.worksheet.exporter.WorkSheetPDFExporter.java

License:Mozilla Public License

public void addSheet(JSONObject sheetJSON) {
    try {/*  ww  w. j av  a2 s  . c o  m*/
        float[] margins = getContentMargins(sheetJSON);

        setCurrentSheetConf(sheetJSON);

        // new margins will be applied on next page
        pdfDocument.setMargins(MARGIN_LEFT, MARGIN_RIGHT, margins[0], margins[1]);

        pdfDocument.newPage();

        JSONObject content = sheetJSON.getJSONObject(WorkSheetPDFExporter.CONTENT);
        String sheetType = content.getString(WorkSheetPDFExporter.SHEET_TYPE);

        if (WorkSheetPDFExporter.CHART.equalsIgnoreCase(sheetType)) {
            addChart(content, margins);
        } else if (WorkSheetPDFExporter.TABLE.equalsIgnoreCase(sheetType)) {
            addTable(content);
        } else if (WorkSheetPDFExporter.CROSSTAB.equalsIgnoreCase(sheetType)) {
            addCrosstab(content);
        } //if the content is hidden
        else if (WorkSheetPDFExporter.EMPTY.equalsIgnoreCase(sheetType)) {
            Phrase emptyString = new Phrase("     ");
            pdfDocument.add(emptyString);
        } else {
            logger.error("Sheet type " + sheetType + " not recognized");
        }

        pdfDocument.newPage(); // finalize page (necessary for MyHeaderFooter onEndPage trigger)

    } catch (Exception e) {
        throw new RuntimeException("Error while adding sheet", e);
    }

}

From source file:it.govpay.web.console.pagamenti.gde.exporter.PdfExporter.java

License:Open Source License

private static void createInfospcoopTable(Section subCatPart, Infospcoop infospcoop)
        throws BadElementException {

    PdfPTable table = new PdfPTable(2);

    PdfPCell c1 = new PdfPCell(new Phrase("Infospcoop"));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    c1.setColspan(2);/* w  ww  .  j av  a  2  s.  co m*/
    table.addCell(c1);
    table.setHeaderRows(1);

    //riga 1
    table.addCell(new Phrase("IdEgov"));
    table.addCell(new Phrase(infospcoop.getIdEgov()));
    // riga 2
    table.addCell(new Phrase("Soggetto Erogatore"));
    table.addCell(new Phrase(infospcoop.getTipoSoggettoErogatore() + "/" + infospcoop.getSoggettoErogatore()));
    // riga 3
    table.addCell(new Phrase("Soggetto Fruitore"));
    table.addCell(new Phrase(infospcoop.getTipoSoggettoFruitore() + "/" + infospcoop.getSoggettoFruitore()));
    // riga 4
    table.addCell(new Phrase("Servizio"));
    table.addCell(new Phrase(infospcoop.getTipoServizio() + "/" + infospcoop.getServizio()));
    // riga 5
    table.addCell(new Phrase("Azione"));
    table.addCell(new Phrase(infospcoop.getAzione()));

    subCatPart.add(table);

}

From source file:it.govpay.web.console.pagamenti.gde.exporter.PdfExporter.java

License:Open Source License

private static void createEventoTable(Section subCatPart, Evento evento) throws BadElementException {

    PdfPTable table = new PdfPTable(2);

    PdfPCell c1 = new PdfPCell(new Phrase("Evento Id[" + evento.getId() + "]"));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    c1.setColspan(2);/*from  w  ww .  java 2  s .c o m*/
    table.addCell(c1);
    table.setHeaderRows(1);

    //riga 1
    if (evento.getData() != null) {
        table.addCell(new Phrase("Data registrazione"));
        table.addCell(new Phrase("" + evento.getData()));
    }
    //riga 1
    if (evento.getDominio() != null) {
        table.addCell(new Phrase("Id Dominio"));
        table.addCell(new Phrase(evento.getDominio()));
    }
    //riga 1
    if (evento.getIuv() != null) {
        table.addCell(new Phrase("IUV"));
        table.addCell(new Phrase(evento.getIuv()));
    }
    //riga 1
    if (evento.getCcp() != null) {
        table.addCell(new Phrase("CCP"));
        table.addCell(new Phrase(evento.getCcp()));
    }
    //riga 1
    if (evento.getPsp() != null) {
        table.addCell(new Phrase("Id PSP"));
        table.addCell(new Phrase(evento.getPsp()));
    }
    //riga 1
    if (evento.getTipoVersamento() != null) {
        table.addCell(new Phrase("Tipo Versamento"));
        table.addCell(new Phrase(evento.getTipoVersamento()));
    }
    //riga 1
    if (evento.getComponente() != null) {
        table.addCell(new Phrase("Componente"));
        table.addCell(new Phrase(evento.getComponente().toString()));
    }
    //riga 1
    if (evento.getCategoria() != null) {
        table.addCell(new Phrase("Categoria Evento"));
        table.addCell(new Phrase(evento.getCategoria().toString()));
    }
    //riga 1
    if (evento.getTipo() != null) {
        table.addCell(new Phrase("Tipo Evento"));
        table.addCell(new Phrase(evento.getTipo()));
    }
    //riga 1
    if (evento.getSottoTipo() != null) {
        table.addCell(new Phrase("Sottotipo Evento"));
        table.addCell(new Phrase(evento.getSottoTipo().toString()));
    }
    //riga 1
    if (evento.getFruitore() != null) {
        table.addCell(new Phrase("Id Fruitore"));
        table.addCell(new Phrase(evento.getFruitore()));
    }
    //riga 1
    if (evento.getErogatore() != null) {
        table.addCell(new Phrase("Id Erogatore"));
        table.addCell(new Phrase(evento.getErogatore()));
    }
    //riga 1
    if (evento.getStazioneIntermediarioPA() != null) {
        table.addCell(new Phrase("Id Stazione Intermediario PA"));
        table.addCell(new Phrase(evento.getStazioneIntermediarioPA()));
    }
    //riga 1
    if (evento.getCanalePagamento() != null) {
        table.addCell(new Phrase("Canale Pagamento"));
        table.addCell(new Phrase(evento.getCanalePagamento()));
    }
    //riga 1
    if (evento.getParametri() != null) {
        table.addCell(new Phrase("Parametri Specifici Interfaccia"));
        table.addCell(new Phrase(evento.getParametri()));
    }

    if (evento.getEsito() != null) {
        table.addCell(new Phrase("Esito"));
        table.addCell(new Phrase(evento.getEsito()));
    }

    subCatPart.add(table);

}

From source file:it.govpay.web.console.pagamenti.gde.exporter.SingleFileExporter.java

License:Open Source License

private void export(String rootDir, List<EventoBean> eventi) throws ExportException {

    byte[] buf = new byte[1024];

    InputStream in = null;// ww  w .  ja v a2s . c  om

    if (this.formatoExport.equalsIgnoreCase("csv")) {

        for (EventoBean evtBean : eventi) {

            try {

                StringBuffer sb = new StringBuffer();
                String newLine = "\n";

                Evento evento = evtBean.getDTO();
                sb.append("Evento Id[" + evento.getId() + "]:").append(newLine);

                if (evento.getData() != null) {
                    sb.append(newLine).append("Data registrazione").append(",").append("" + evento.getData());
                }
                //riga 1
                if (evento.getDominio() != null) {
                    sb.append(newLine).append("Id Dominio").append(",").append(evento.getDominio());
                }
                //riga 1
                if (evento.getIuv() != null) {
                    sb.append(newLine).append("IUV").append(",").append(evento.getIuv());
                }
                //riga 1
                if (evento.getCcp() != null) {
                    sb.append(newLine).append("CCP").append(",").append(evento.getCcp());
                }
                //riga 1
                if (evento.getPsp() != null) {
                    sb.append(newLine).append("Id PSP").append(",").append(evento.getPsp());
                }
                //riga 1
                if (evento.getTipoVersamento() != null) {
                    sb.append(newLine).append("Tipo Versamento").append(",").append(evento.getTipoVersamento());
                }
                //riga 1
                if (evento.getComponente() != null) {
                    sb.append(newLine).append("Componente").append(",").append(evento.getComponente());
                }
                //riga 1
                if (evento.getCategoria() != null) {
                    sb.append(newLine).append("Categoria Evento").append(",")
                            .append(evento.getCategoria().toString());
                }
                //riga 1
                if (evento.getTipo() != null) {
                    sb.append(newLine).append("Tipo Evento").append(",").append(evento.getTipo());
                }
                //riga 1
                if (evento.getSottoTipo() != null) {
                    sb.append(newLine).append("Sottotipo Evento").append(",").append(evento.getSottoTipo());
                }
                //riga 1
                if (evento.getFruitore() != null) {
                    sb.append(newLine).append("Id Fruitore").append(",").append(evento.getFruitore());
                }
                //riga 1
                if (evento.getErogatore() != null) {
                    sb.append(newLine).append("Id Erogatore").append(",").append(evento.getErogatore());
                }
                //riga 1
                if (evento.getStazioneIntermediarioPA() != null) {
                    sb.append(newLine).append("Id Stazione Intermediario PA").append(",")
                            .append(evento.getStazioneIntermediarioPA());
                }
                //riga 1
                if (evento.getCanalePagamento() != null) {
                    sb.append(newLine).append("Canale Pagamento").append(",")
                            .append(evento.getCanalePagamento());
                }
                //riga 1
                if (evento.getParametri() != null) {
                    sb.append(newLine).append("Parametri Specifici Interfaccia").append(",")
                            .append(evento.getParametri());
                }

                if (evento.getEsito() != null) {
                    sb.append(newLine).append("Esito").append(",").append(evento.getEsito());
                }

                Infospcoop infospcoop = evtBean.getInfospcoop() != null ? evtBean.getInfospcoop().getDTO()
                        : null;
                if (infospcoop != null) {
                    //         if(evento.getCategoria().equals(Categoria.INTERFACCIA) && evento.getIdEgov()!= null){

                    //                  Infospcoop infospcoop = this.eventiService.getInfospcoopByIdEgov(evento.getIdEgov());

                    sb.append(newLine).append(newLine).append("Infospcoop: ");
                    sb.append(newLine).append("IdEgov").append(",").append(infospcoop.getIdEgov());
                    // riga 2
                    sb.append(newLine).append("Soggetto Erogatore").append(",").append(
                            infospcoop.getTipoSoggettoErogatore() + "/" + infospcoop.getSoggettoErogatore());
                    // riga 3
                    sb.append(newLine).append("Soggetto Fruitore").append(",").append(
                            infospcoop.getTipoSoggettoFruitore() + "/" + infospcoop.getSoggettoFruitore());
                    // riga 4
                    sb.append(newLine).append("Servizio").append(",")
                            .append(infospcoop.getTipoServizio() + "/" + infospcoop.getServizio());
                    // riga 5
                    sb.append(newLine).append("Azione").append(",").append(new Phrase(infospcoop.getAzione()));

                    sb.append(newLine).append(newLine);
                    //                  .append(newLine).append("Infospcoop: ").append(newLine).append(infospcoop.toJson());

                }
                //               }

                // aggiungo lo spazio tra le entry
                sb.append(newLine).append(newLine);

                in = new ByteArrayInputStream(sb.toString().getBytes());
                int len;
                while ((len = in.read(buf)) > 0) {
                    this.zip.write(buf, 0, len);
                }

                //            this.zip.flush();
                //            this.zip.closeEntry();
                if (in != null)
                    in.close();
            } catch (IOException ioe) {
                String msg = "Si e' verificato un errore durante l'esportazione dell'evento con id:"
                        + evtBean.getDTO().getId();
                msg += " Non sono riuscito a creare il file .csv (" + ioe.getMessage() + ")";
                throw new ExportException(msg, ioe);
            } catch (Exception e) {
                String msg = "Si e' verificato un errore durante l'esportazione dell'evento con id:"
                        + evtBean.getDTO().getId();
                msg += " Non sono riuscito a creare il file .csv (" + e.getMessage() + ")";
                throw new ExportException(msg, e);
            }

        }
    } else if (this.formatoExport.equalsIgnoreCase("pdf")) {
        try {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();

            PdfExporter.exportAsPdf(eventi, baos, this.eventiService);

            in = new ByteArrayInputStream(baos.toByteArray());
            int len;
            while ((len = in.read(buf)) > 0) {
                this.zip.write(buf, 0, len);
            }

            if (in != null)
                in.close();

        } catch (Exception e) {
            String msg = "Si e' verificato un errore durante l'esportazione degli eventi";
            msg += " Non sono riuscito a creare il file .pdf (" + e.getMessage() + ")";
            throw new ExportException(msg, e);
        }
    }
}

From source file:jmemorize.core.io.PdfRtfBuilder.java

License:Open Source License

private static void export(Lesson lesson, int mode, File file) throws IOException {
    logger = Main.getLogger();/*from  w  ww . j  a  v a  2  s .c  o m*/

    FontFactory.registerDirectories();
    // set up the fonts we will use to write the front and back of cards
    String frontFontName = Settings.loadFont(FontType.CARD_FRONT).getFont().getFamily();
    frontFont = FontFactory.getFont(frontFontName, BaseFont.IDENTITY_H, BaseFont.EMBEDDED);

    if (frontFont == null) {
        logger.warning("FontFactory returned null (front) font for: " + frontFontName);
    }

    String backFontName = Settings.loadFont(FontType.CARD_FLIP).getFont().getFamily();
    backFont = FontFactory.getFont(backFontName, BaseFont.IDENTITY_H, BaseFont.EMBEDDED);

    if (backFont == null) {
        logger.warning("FontFactory returned null (back) font for: " + backFontName);
    }

    try {
        Document doc = new Document();
        OutputStream out = new FileOutputStream(file);

        switch (mode) {
        case PDF_MODE:
            PdfWriter.getInstance(doc, out);
            break;

        case RTF_MODE:
            RtfWriter2.getInstance(doc, out);
            break;
        }

        doc.setHeader(new HeaderFooter(new Phrase(file.getName()), false));
        doc.open();

        // add cards in subtrees
        List<Category> subtree = lesson.getRootCategory().getSubtreeList();
        for (Category category : subtree) {
            writeCategory(doc, category);
        }

        doc.close();

    } catch (Throwable t) {
        throw (IOException) new IOException("Could not export to PDF").initCause(t);
    }
}

From source file:lt.bsprendimai.ddesk.pdf.PDFTicket.java

License:Apache License

public byte[] writePage() throws Exception {
    ByteArrayOutputStream bout = new ByteArrayOutputStream();

    try {/*from  w  w w  .j av  a  2  s.com*/
        logo = Image.getInstance(root.getAbsolutePath() + "/logo.gif");
        logo.setAlignment(Image.ALIGN_LEFT);
    } catch (Exception exc) {
        exc.printStackTrace();
    }

    baseArial = BaseFont.createFont(root.getAbsolutePath() + "/objects/arial.ttf", BaseFont.CP1257,
            BaseFont.EMBEDDED);

    Document doc = new Document(PageSize.A4, 56.5354331f, 22.6771654f, 28.3464567f, 25.0f);
    PdfWriter.getInstance(doc, bout);

    doc.open();

    logo.setAbsolutePosition(28.3464567f, doc.getPageSize().height() - logo.height() - 25.0f);
    doc.add(logo);
    Paragraph pg = new Paragraph(sdf.format(new Date()), new Font(baseArial, 10));
    pg.setAlignment(Element.ALIGN_RIGHT);
    doc.add(pg);
    doc.add(new Phrase("\n\n\n"));

    writeClientInfo(doc);
    writeTicketInfo(doc);
    writeJobInfo(doc);
    writeWorkerInfo(doc);

    doc.close();

    return bout.toByteArray();
}

From source file:mitm.common.pdf.MessagePDFBuilder.java

License:Open Source License

public void buildPDF(MimeMessage message, String replyURL, OutputStream pdfStream)
        throws DocumentException, MessagingException, IOException {
    Document document = createDocument();

    PdfWriter pdfWriter = createPdfWriter(document, pdfStream);

    document.open();//w w  w . ja va  2  s  .  c o  m

    String[] froms = null;

    try {
        froms = EmailAddressUtils.addressesToStrings(message.getFrom(), true /* mime decode */);
    } catch (MessagingException e) {
        logger.warn("From address is not a valid email address.");
    }

    if (froms != null) {
        for (String from : froms) {
            document.addAuthor(from);
        }
    }

    String subject = null;

    try {
        subject = message.getSubject();
    } catch (MessagingException e) {
        logger.error("Error getting subject.", e);
    }

    if (subject != null) {
        document.addSubject(subject);
        document.addTitle(subject);
    }

    String[] tos = null;

    try {
        tos = EmailAddressUtils.addressesToStrings(message.getRecipients(RecipientType.TO),
                true /* mime decode */);
    } catch (MessagingException e) {
        logger.warn("To is not a valid email address.");
    }

    String[] ccs = null;

    try {
        ccs = EmailAddressUtils.addressesToStrings(message.getRecipients(RecipientType.CC),
                true /* mime decode */);
    } catch (MessagingException e) {
        logger.warn("CC is not a valid email address.");
    }

    Date sentDate = null;

    try {
        sentDate = message.getSentDate();
    } catch (MessagingException e) {
        logger.error("Error getting sent date.", e);
    }

    Collection<Part> attachments = new LinkedList<Part>();

    String body = BodyPartUtils.getPlainBodyAndAttachments(message, attachments);

    attachments = preprocessAttachments(attachments);

    if (body == null) {
        body = MISSING_BODY;
    }

    /*
     * PDF does not have tab support so we convert tabs to spaces
     */
    body = StringReplaceUtils.replaceTabsWithSpaces(body, tabWidth);

    PdfPTable headerTable = new PdfPTable(2);

    headerTable.setHorizontalAlignment(Element.ALIGN_LEFT);
    headerTable.setWidthPercentage(100);
    headerTable.setWidths(new int[] { 1, 6 });
    headerTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);

    Font headerFont = createHeaderFont();

    FontSelector headerFontSelector = createHeaderFontSelector();

    PdfPCell cell = new PdfPCell(new Paragraph("From:", headerFont));
    cell.setBorder(Rectangle.NO_BORDER);
    cell.setHorizontalAlignment(Element.ALIGN_RIGHT);

    headerTable.addCell(cell);

    String decodedFroms = StringUtils.defaultString(StringUtils.join(froms, ", "));

    headerTable.addCell(headerFontSelector.process(decodedFroms));

    cell = new PdfPCell(new Paragraph("To:", headerFont));
    cell.setBorder(Rectangle.NO_BORDER);
    cell.setHorizontalAlignment(Element.ALIGN_RIGHT);

    headerTable.addCell(cell);
    headerTable.addCell(headerFontSelector.process(StringUtils.defaultString(StringUtils.join(tos, ", "))));

    cell = new PdfPCell(new Paragraph("CC:", headerFont));
    cell.setBorder(Rectangle.NO_BORDER);
    cell.setHorizontalAlignment(Element.ALIGN_RIGHT);

    headerTable.addCell(cell);
    headerTable.addCell(headerFontSelector.process(StringUtils.defaultString(StringUtils.join(ccs, ", "))));

    cell = new PdfPCell(new Paragraph("Subject:", headerFont));
    cell.setBorder(Rectangle.NO_BORDER);
    cell.setHorizontalAlignment(Element.ALIGN_RIGHT);

    headerTable.addCell(cell);
    headerTable.addCell(headerFontSelector.process(StringUtils.defaultString(subject)));

    cell = new PdfPCell(new Paragraph("Date:", headerFont));
    cell.setBorder(Rectangle.NO_BORDER);
    cell.setHorizontalAlignment(Element.ALIGN_RIGHT);

    headerTable.addCell(cell);
    headerTable.addCell(ObjectUtils.toString(sentDate));

    cell = new PdfPCell(new Paragraph("Attachments:", headerFont));
    cell.setBorder(Rectangle.NO_BORDER);
    cell.setHorizontalAlignment(Element.ALIGN_RIGHT);

    headerTable.addCell(cell);
    headerTable
            .addCell(headerFontSelector.process(StringUtils.defaultString(getAttachmentHeader(attachments))));

    document.add(headerTable);

    if (replyURL != null) {
        addReplyLink(document, replyURL);
    }

    /*
     * Body table will contain the body of the message
     */
    PdfPTable bodyTable = new PdfPTable(1);
    bodyTable.setWidthPercentage(100f);

    bodyTable.setSplitLate(false);

    bodyTable.setSpacingBefore(15f);
    bodyTable.setHorizontalAlignment(Element.ALIGN_LEFT);

    addBodyAndAttachments(pdfWriter, document, bodyTable, body, attachments);

    Phrase footer = new Phrase(FOOTER_TEXT);

    PdfContentByte cb = pdfWriter.getDirectContent();

    ColumnText.showTextAligned(cb, Element.ALIGN_RIGHT, footer, document.right(), document.bottom(), 0);

    document.close();
}

From source file:mx.avanti.siract.ui.RACTBeanUI.java

public void postProcessPDF(Object document) throws IOException, DocumentException {
    final Document pdf = (Document) document;
    TreeNode[] selectedNodesPDF = selectedNodes;

    if (selectedNodes != null) {
        for (TreeNode nodo : selectedNodes) {
            System.out.println("*********************" + ((NodoMultiClass) nodo.getData()).getNombre());
        }//from  w w w . j  a va2 s  . co m
    }
    pdf.setPageSize(PageSize.A4.rotate());
    pdf.open();
    String nombrep = profesor.getPronombre() + " " + profesor.getProapellidoPaterno() + " "
            + profesor.getProapellidoMaterno();
    String numEmpPro = Integer.toString(profesor.getPronumeroEmpleado());
    String porAv = Float.toString(porcentajeAvance);
    SimpleDateFormat formato = new SimpleDateFormat("dd/MM/yyyy");

    //Obtener el nombre del programa educativo seleccionado
    String nombreProgEdu = "";
    int programaEducativoSeleccionado2 = Integer.parseInt(programaEducativoSeleccionado);
    for (int x = 0; x < programasEducativos.size(); x++) {
        if (programasEducativos.get(x).getPedid() == programaEducativoSeleccionado2) {
            nombreProgEdu = programasEducativos.get(x).getPednombre();
        }
    }
    //----------------------------------------------------------------------------------

    //Obtener el nombre de la unidad de aprendizaje y clave seleccionada
    String nombreUniApr = "";
    String nombreclave = "";
    int uniAprselec2 = Integer.parseInt(unidadAprendizajeSeleccionada);
    for (int x = 0; x < unidadesaprendisaje.size(); x++) {
        if (unidadesaprendisaje.get(x).getUapclave() == uniAprselec2) {
            nombreUniApr = unidadesaprendisaje.get(x).getUapnombre();
            nombreclave = Integer.toString(unidadesaprendisaje.get(x).getUapclave());
        }
    }
    //----------------------------------------------------------------------

    // rutaImagen es la ruta para acceder a la imagen guardada en el folder resources del proyecto
    try {
        //            Image imagenLogo = Image.getInstance("C:\\Users\\Y\\Desktop\\RACT 22-01-2015\\RACT\\build\\web\\resources\\imagenes\\logo.jpg");
        Image imagenLogo = Image.getInstance(RACTBeanUI.class.getResource("imagenes/logo.jpg"));

        //Posicion de imagen (Horizontal, Vertiacal)
        imagenLogo.setAbsolutePosition(120f, 460f);

        //Tamao de imagen (Ancho, largo)
        imagenLogo.scaleAbsolute(90, 120);
        //imagenLogo.scaleAbsoluteWidth(100f);
        //imagenLogo.scaleAbsoluteHeight(150f);
        //imagenLogo.scaleToFit(100f, 120f); Esta es la buena
        //Image imagenLogo = Image.getInstance("http://ed.uabc.mx/sed/images/logo.jpg");
        //imagenLogo.scaleAbsolute(70f, 90f);
        pdf.add(imagenLogo);
    } catch (Exception exception) {
        System.out.println("****NO SE ENCONTRO LA RUTA DE IMAGEN ESPECIFICADA");
    }
    //Tabla con UABC y Nombre del profesor(a)
    PdfPTable pdfTabletitulo = new PdfPTable(2);
    pdfTabletitulo.getDefaultCell().setBorder(PdfPCell.NO_BORDER);
    PdfPTable pdfTabletitulo2 = new PdfPTable(2);
    pdfTabletitulo2.getDefaultCell().setBorder(PdfPCell.NO_BORDER);

    Paragraph UABC = new Paragraph("Universidad Autnoma de Baja California",
            FontFactory.getFont(FontFactory.TIMES, 22, Font.BOLD, new Color(0, 113, 65)));
    UABC.setAlignment(Element.ALIGN_CENTER);
    Paragraph esp = new Paragraph(" ");
    pdf.add(UABC);
    pdf.add(esp);
    pdf.add(esp);
    pdf.add(esp);
    pdf.add(esp);
    pdfTabletitulo.addCell(new Paragraph(""));
    pdfTabletitulo.addCell(new Paragraph(""));
    pdfTabletitulo.addCell(new Paragraph(""));
    pdfTabletitulo.addCell(new Paragraph(""));
    pdfTabletitulo.addCell(new Paragraph(""));
    pdfTabletitulo.addCell(new Paragraph(""));
    pdfTabletitulo.addCell(new Paragraph(""));
    pdfTabletitulo.addCell(new Paragraph(""));
    pdfTabletitulo.addCell(new Paragraph(""));
    pdfTabletitulo.addCell(new Paragraph(""));

    pdfTabletitulo.addCell(new Paragraph("Profesor(a): ",
            FontFactory.getFont(FontFactory.TIMES, 14, Font.BOLD, new Color(0, 0, 0))));
    pdfTabletitulo.addCell(new Paragraph(nombrep));

    pdfTabletitulo2.addCell(new Paragraph("Num. de Empleado: ",
            FontFactory.getFont(FontFactory.TIMES, 14, Font.BOLD, new Color(0, 0, 0))));
    pdfTabletitulo2.addCell(new Paragraph(numEmpPro));

    pdfTabletitulo.setHorizontalAlignment(25);
    //pdfTabletitulo.setHorizontalAlignment(Element.ALIGN_CENTER);
    //document.add(table);
    float[] columnWidthsss = new float[] { 4f, 28 };
    pdfTabletitulo.setWidths(columnWidthsss);
    pdf.add(pdfTabletitulo);

    float[] columnWidthss = new float[] { 10f, 38 };
    pdfTabletitulo2.setWidths(columnWidthss);
    pdf.add(pdfTabletitulo2);

    pdf.add(new Phrase(" "));

    //----------------------------------------------------------------------
    //Tabla Cabezera
    PdfPTable pdftablecabezera = new PdfPTable(4);
    pdftablecabezera.getDefaultCell().setBorder(PdfPCell.NO_BORDER);
    PdfPTable pdftablecabezera2 = new PdfPTable(5);
    pdftablecabezera2.getDefaultCell().setBorder(PdfPCell.NO_BORDER);

    pdftablecabezera.addCell(new Paragraph("Programa educativo: ",
            FontFactory.getFont(FontFactory.TIMES, 14, Font.BOLD, new Color(0, 0, 0))));
    pdftablecabezera.addCell(new Paragraph("Fecha: ",
            FontFactory.getFont(FontFactory.TIMES, 14, Font.BOLD, new Color(0, 0, 0))));
    pdftablecabezera.addCell(new Paragraph("Ciclo Escolar: ",
            FontFactory.getFont(FontFactory.TIMES, 14, Font.BOLD, new Color(0, 0, 0))));
    pdftablecabezera.addCell(new Paragraph("Avance Global: ",
            FontFactory.getFont(FontFactory.TIMES, 14, Font.BOLD, new Color(0, 0, 0))));
    pdftablecabezera.addCell(new Paragraph(nombreProgEdu));
    pdftablecabezera.addCell(new Paragraph(formato.format(new Date())));
    pdftablecabezera.addCell(new Paragraph("        " + cicloEscolar));
    pdftablecabezera.addCell(new Paragraph("        " + porAv));

    pdftablecabezera.addCell(new Paragraph(" "));
    pdftablecabezera.addCell(new Paragraph(" "));
    pdftablecabezera.addCell(new Paragraph(" "));
    pdftablecabezera.addCell(new Paragraph(" "));

    pdftablecabezera2.addCell(new Paragraph("Unidad de Aprendizaje: ",
            FontFactory.getFont(FontFactory.TIMES, 14, Font.BOLD, new Color(0, 0, 0))));
    pdftablecabezera2.addCell(new Paragraph("Clave: ",
            FontFactory.getFont(FontFactory.TIMES, 14, Font.BOLD, new Color(0, 0, 0))));
    pdftablecabezera2.addCell(new Paragraph("Grupo: ",
            FontFactory.getFont(FontFactory.TIMES, 14, Font.BOLD, new Color(0, 0, 0))));
    pdftablecabezera2.addCell(new Paragraph("Subgrupo: ",
            FontFactory.getFont(FontFactory.TIMES, 14, Font.BOLD, new Color(0, 0, 0))));
    pdftablecabezera2.addCell(new Paragraph("Tipo Grupo: ",
            FontFactory.getFont(FontFactory.TIMES, 14, Font.BOLD, new Color(0, 0, 0))));
    pdftablecabezera2.addCell(new Paragraph(nombreUnidadSeleccionado));
    pdftablecabezera2.addCell(new Paragraph(claveUnidadAprendizajeSeleccionada));
    pdftablecabezera2.addCell(new Paragraph("   " + grupo));
    pdftablecabezera2.addCell(new Paragraph("       " + subGrupo));
    String tipoGrupo = "";
    switch (this.tipoUnidadAprendizaje) {
    case "C":
        tipoGrupo = "Clase";
        break;
    case "L":
        tipoGrupo = "Laboratorio";
        break;
    case "T":
        tipoGrupo = "Taller";
        break;
    case "P":
        tipoGrupo = "Practica";
        break;
    case "CL":
        tipoGrupo = "Practicas Clinica";
        break;
    }
    pdftablecabezera2.addCell(new Paragraph("       " + tipoGrupo));
    pdftablecabezera2.addCell(new Paragraph(" "));

    pdftablecabezera.setHorizontalAlignment(25);
    float[] columnWidths = new float[] { 38f, 10f, 14f, 18f };
    pdftablecabezera.setWidths(columnWidths);
    pdf.add(pdftablecabezera);

    pdftablecabezera2.setHorizontalAlignment(25);
    float[] columnWidthss2 = new float[] { 38f, 10f, 8f, 11f, 14f };
    pdftablecabezera2.setWidths(columnWidthss2);
    pdf.add(pdftablecabezera2);

    pdf.add(new Phrase(" "));

    //----------------------------------------------------------------------
    Paragraph numrep = new Paragraph("Reporte # " + numeroReporte,
            FontFactory.getFont(FontFactory.TIMES, 16, Font.BOLD, new Color(0, 0, 0)));
    numrep.setAlignment(Element.ALIGN_CENTER);
    pdf.add(numrep);
    pdf.add(new Paragraph(" "));
    //Tabla con Datos 
    PdfPTable pdfTable = new PdfPTable(3);
    pdfTable.addCell(new Phrase("Nombre",
            FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, new Color(0, 0, 0))));
    pdfTable.addCell(new Phrase("Porcentaje",
            FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, new Color(0, 0, 0))));
    pdfTable.addCell(new Phrase("Observaciones",
            FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, new Color(0, 0, 0))));

    //Evitar Null pointer exception por no tener nodoes en selectedNodes
    //Se utiliza un auxiliar de selectedNodes por que hay posibilidad de que selectedNodes se modifique durante el proceso de generacion del PDF
    if (selectedNodesPDF != null && selectedNodesPDF.length > 0) {

        //Regresar a lo basicoString
        int nns = selectedNodesPDF.length;
        String[] ns = new String[nns];
        for (int x = 0; x < selectedNodesPDF.length; x++) {
            ns[x] = ((NodoMultiClass) selectedNodesPDF[x].getData()).getNumero() + "--"
                    + ((NodoMultiClass) selectedNodes[x].getData()).getNombre() + "--"
                    + ((NodoMultiClass) selectedNodes[x].getData()).getPorcentajeAvance() + "--"
                    + ((NodoMultiClass) selectedNodes[x].getData()).getObservaciones() + " -- ";
        }
        String[] filas = new String[4];
        String[] nstr = new String[3];

        String[] filas2 = new String[4];
        String[] nstr2 = new String[3];

        for (int x = 1; x < ns.length; x++) {
            for (int y = 0; y < ns.length - x; y++) {
                //Obtengo los valores para hacer las comparaciones
                int[] n = new int[3];
                int[] n2 = new int[3];
                filas = ns[y].split("--");
                nstr = filas[0].split("\\.");
                for (int z = 0; z < nstr.length; z++) {
                    if (nstr == null) {
                        n[z] = 0;
                    } else {
                        n[z] = Integer.parseInt(nstr[z]);
                    }
                }
                filas2 = ns[y + 1].split("--");
                nstr2 = filas2[0].split("\\.");
                for (int z = 0; z < nstr2.length; z++) {
                    if (nstr2 == null) {
                        n2[z] = 0;
                    } else {
                        n2[z] = Integer.parseInt(nstr2[z]);
                    }
                }
                //-------------------------------------------------comparacion
                if (n[0] == n2[0]) {
                    if (n[1] == n2[1]) {
                        if (n[2] > n2[2]) {
                            String aux = ns[y];
                            ns[y] = ns[y + 1];
                            ns[y + 1] = aux;
                        }
                    } else {
                        if (n[1] > n2[1]) {
                            String aux = ns[y];
                            ns[y] = ns[y + 1];
                            ns[y + 1] = aux;
                        }
                    }
                } else {
                    if (n[0] > n2[0]) {
                        String aux = ns[y];
                        ns[y] = ns[y + 1];
                        ns[y + 1] = aux;
                    }
                }
                //-------------------------------------------------------------
            }
        }

        String[] auxNum = new String[4];
        for (int x = 0; x < ns.length; x++) {

            filas = ns[x].split("--");
            num = filas[0].split("\\.");

            //Auxiliar para agregar padre de tema/subtema
            int auxMargen = 1;
            //Agregar unidad a la que pertenece el tema/subtema

            String[] auxNum2 = auxNum;
            int tamanoArbol = root.getChildCount();
            //AGREGAR A TEMA
            if (Integer.parseInt(num[0]) > tamanoArbol) {
                auxMargen = Integer.parseInt(num[0]) - tamanoArbol;
            }
            if (num.length >= 2 && auxNum2[0] != null && !auxNum2[0].equals(num[0])) {
                if (!num[1].equals("0")) {
                    while (!num[0].equals(auxNum2[0]) && auxMargen > 0) {
                        System.out.println("XXXXXXIteracion  para encontrar padre XXXXXXX 0" + auxMargen);
                        auxNum2 = (((NodoMultiClass) root.getChildren()
                                .get(Integer.parseInt(num[0]) - auxMargen).getData()).getNumero()).split("\\.");
                        //if(auxNum[0]!=null&&Integer.parseInt(num[0])>Integer.parseInt(auxNum[0])){
                        if (num[0].equals(auxNum2[0])) {

                        } else {
                            auxMargen--;
                        }

                    }
                    System.out.println("***Unidad Padre" + ((NodoMultiClass) root.getChildren()
                            .get(Integer.parseInt(num[0]) - auxMargen).getData()).getNombre());
                    NodoMultiClass auxNodo = ((NodoMultiClass) root.getChildren()
                            .get(Integer.parseInt(num[0]) - auxMargen).getData());
                    //UTIL PARA PONER TEXTO TACHADO
                    //                     Chunk strikethrough = new Chunk("Strikethrough.");
                    //                      strikethrough.setUnderline(0.1f, 3f); //0.1 thick, 2 y-location
                    //                     document.add(strikethrough);
                    pdfTable.addCell(new Phrase(auxNodo.getNumero() + ".- " + auxNodo.getNombre(), FontFactory
                            .getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, new Color(154, 151, 151))));
                    pdfTable.addCell(new Phrase(auxNodo.getPorcentajeAvance(), FontFactory
                            .getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, new Color(154, 151, 151))));
                    pdfTable.addCell(auxNodo.getObservaciones());

                }
            } else {
                if (auxNum2[0] == null && num.length >= 2) {
                    auxNum2 = (((NodoMultiClass) root.getChildren().get(Integer.parseInt(num[0]) - auxMargen)
                            .getData()).getNumero()).split("\\.");
                    while (!num[0].equals(auxNum2[0]) && auxMargen > 0) {
                        System.out.println("XXXXXXIteracion  para encontrar padre XXXXXXX 0" + auxMargen);
                        auxNum2 = (((NodoMultiClass) root.getChildren()
                                .get(Integer.parseInt(num[0]) - auxMargen).getData()).getNumero()).split("\\.");
                        //if(auxNum[0]!=null&&Integer.parseInt(num[0])>Integer.parseInt(auxNum[0])){
                        if (num[0].equals(auxNum2[0])) {

                        } else {
                            auxMargen--;
                        }
                    }
                    System.out.println("***Unidad Padre" + ((NodoMultiClass) root.getChildren()
                            .get(Integer.parseInt(num[0]) - auxMargen).getData()).getNombre());
                    NodoMultiClass auxNodo = ((NodoMultiClass) root.getChildren()
                            .get(Integer.parseInt(num[0]) - auxMargen).getData());
                    //UTIL PARA PONER TEXTO TACHADO
                    //                     Chunk strikethrough = new Chunk("Strikethrough.");
                    //                      strikethrough.setUnderline(0.1f, 3f); //0.1 thick, 2 y-location
                    //                     document.add(strikethrough);
                    pdfTable.addCell(new Phrase(auxNodo.getNumero() + ".- " + auxNodo.getNombre(), FontFactory
                            .getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, new Color(154, 151, 151))));
                    pdfTable.addCell(new Phrase(auxNodo.getPorcentajeAvance(), FontFactory
                            .getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, new Color(154, 151, 151))));
                    pdfTable.addCell(auxNodo.getObservaciones());

                }
            }

            //AGREGAR A SUBTEMA
            String[] auxNumeroUnidad = new String[4];
            int auxMargen2 = 1;
            if (num.length == 3 && auxNum[1] != null && !auxNum[1].equals(num[1])) {
                if (!num[2].equals("0")) {
                    while (!num[0].equals(auxNum[0]) && auxMargen >= 0) {
                        NodoMultiClass auxNodoUnidad = ((NodoMultiClass) root.getChildren()
                                .get(Integer.parseInt(num[0]) - auxMargen).getData());
                        auxNumeroUnidad = auxNodoUnidad.getNumero().split("\\.");
                        tamanoArbol = root.getChildren().get(Integer.parseInt(num[0])).getChildCount();
                        if (Integer.parseInt(num[1]) > tamanoArbol) {
                            auxMargen2 = Integer.parseInt(num[1]) - tamanoArbol;
                        }

                        while (auxNumeroUnidad[0].equals(num[0]) && !num[1].equals(auxNum[1])
                                && auxMargen > 0) {
                            System.out.println("XXXXXXIteracion  para encontrar padre XXXXXXX 0" + auxMargen);
                            auxNum = (((NodoMultiClass) root.getChildren()
                                    .get(Integer.parseInt(num[0]) - auxMargen).getChildren()
                                    .get(Integer.parseInt(num[1]) - auxMargen2).getData()).getNumero())
                                            .split("\\.");
                            //if(auxNum[0]!=null&&Integer.parseInt(num[0])>Integer.parseInt(auxNum[0])){
                            if (num[1].equals(auxNum[1])) {

                            } else {
                                auxMargen2--;
                            }

                        }
                        //                            auxNum = (((NodoMultiClass) root.getChildren().get(Integer.parseInt(num[1]) - auxMargen).getData()).getNumero()).split("\\.");
                        if (num[0].equals(auxNum[0])) {
                        } else {
                            auxMargen--;
                        }
                    }

                    System.out.println("*****Unidad Padre(SUBTEMA)"
                            + ((NodoMultiClass) root.getChildren().get(Integer.parseInt(num[0]) - auxMargen)
                                    .getChildren().get(Integer.parseInt(num[1]) - auxMargen2).getData())
                                            .getNombre());
                    NodoMultiClass auxNodo = ((NodoMultiClass) root.getChildren()
                            .get(Integer.parseInt(num[0]) - auxMargen).getChildren()
                            .get(Integer.parseInt(num[1]) - auxMargen2).getData());
                    //UTIL PARA PONER TEXTO TACHADO
                    //                     Chunk strikethrough = new Chunk("Strikethrough.");
                    //                      strikethrough.setUnderline(0.1f, 3f); //0.1 thick, 2 y-location
                    //                     document.add(strikethrough);
                    pdfTable.addCell(
                            new Phrase("   " + auxNodo.getNumero() + ".- " + auxNodo.getNombre(), FontFactory
                                    .getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, new Color(154, 151, 151))));
                    pdfTable.addCell(new Phrase(auxNodo.getPorcentajeAvance(), FontFactory
                            .getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, new Color(154, 151, 151))));
                    pdfTable.addCell(auxNodo.getObservaciones());

                }
            } else {
                if (auxNum[0] == null && num.length == 3) {
                    auxNum = (((NodoMultiClass) root.getChildren().get(Integer.parseInt(num[0]) - auxMargen)
                            .getData()).getNumero()).split("\\.");
                    while (!num[0].equals(auxNum[0]) && auxMargen > 0) {
                        NodoMultiClass auxNodoUnidad = ((NodoMultiClass) root.getChildren()
                                .get(Integer.parseInt(num[0]) - auxMargen).getData());
                        auxNumeroUnidad = auxNodoUnidad.getNumero().split("\\.");
                        tamanoArbol = root.getChildren().get(Integer.parseInt(num[0])).getChildCount();
                        if (Integer.parseInt(num[1]) > tamanoArbol) {
                            auxMargen2 = Integer.parseInt(num[1]) - tamanoArbol;
                        }
                        while (auxNumeroUnidad[0].equals(num[0]) && !num[1].equals(auxNum[1])
                                && auxMargen > 0) {
                            System.out.println("Iteracion  para encontrar padre XXXXXXX 0" + auxMargen);
                            auxNum = (((NodoMultiClass) root.getChildren()
                                    .get(Integer.parseInt(num[0]) - auxMargen).getChildren()
                                    .get(Integer.parseInt(num[1]) - auxMargen2).getData()).getNumero())
                                            .split("\\.");
                            //if(auxNum[0]!=null&&Integer.parseInt(num[0])>Integer.parseInt(auxNum[0])){
                            if (num[1].equals(auxNum[1])) {

                            } else {
                                auxMargen2--;
                            }
                        }
                        //                            auxNum = (((NodoMultiClass) root.getChildren().get(Integer.parseInt(num[1]) - auxMargen).getData()).getNumero()).split("\\.");
                        if (num[0].equals(auxNum[0])) {
                        } else {
                            auxMargen--;
                        }
                    }

                    System.out.println("***Unidad Padre(SUBTEMA)"
                            + ((NodoMultiClass) root.getChildren().get(Integer.parseInt(num[0]) - auxMargen)
                                    .getChildren().get(Integer.parseInt(num[1]) - auxMargen2).getData())
                                            .getNombre());
                    NodoMultiClass auxNodo = ((NodoMultiClass) root.getChildren()
                            .get(Integer.parseInt(num[0]) - auxMargen).getChildren()
                            .get(Integer.parseInt(num[1]) - auxMargen2).getData());
                    //UTIL PARA PONER TEXTO TACHADO
                    //                     Chunk strikethrough = new Chunk("Strikethrough.");
                    //                      strikethrough.setUnderline(0.1f, 3f); //0.1 thick, 2 y-location
                    //                     document.add(strikethrough);
                    pdfTable.addCell(
                            new Phrase("   " + auxNodo.getNumero() + ".- " + auxNodo.getNombre(), FontFactory
                                    .getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, new Color(154, 151, 151))));
                    pdfTable.addCell(new Phrase(auxNodo.getPorcentajeAvance(), FontFactory
                            .getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, new Color(154, 151, 151))));
                    pdfTable.addCell(auxNodo.getObservaciones());

                }
            }

            auxNum = num;
            //FIN AGREGAR PADRE DE TEMA/SUBTEMA 
            boolean banpor = true;
            if (num.length == 1) {
                pdfTable.addCell(new Phrase(filas[0] + ".- " + filas[1],
                        FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, new Color(0, 0, 0))));
                pdfTable.addCell(new Phrase(String.valueOf(dosDecimales(Float.parseFloat(filas[2]))),
                        FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, new Color(0, 0, 0))));
                banpor = false;
            }
            if (num.length == 2) {
                pdfTable.addCell(new Phrase("   " + filas[0] + ".- " + filas[1]));
            }
            if (num.length == 3) {
                pdfTable.addCell(new Phrase("       " + filas[0] + ".- " + filas[1],
                        FontFactory.getFont(FontFactory.TIMES_ITALIC, 12)));
                pdfTable.addCell(new Phrase(String.valueOf(dosDecimales(Float.parseFloat(filas[2]))),
                        FontFactory.getFont(FontFactory.TIMES_ITALIC, 12)));
                banpor = false;
            }
            if (banpor) {
                pdfTable.addCell(String.valueOf(dosDecimales(Float.parseFloat(filas[2]))));
                pdfTable.addCell(filas[3]);
            } else {
                pdfTable.addCell(filas[3]);
            }
        }

    } else {
        pdfTable.addCell("No hay nada seleccionado");
        pdfTable.addCell("");
        pdfTable.addCell("");
    }

    pdfTable.setHorizontalAlignment(15);
    float[] columnWidths2 = new float[] { 32f, 8f, 14f };
    pdfTable.setWidths(columnWidths2);
    pdf.add(pdfTable);
    //----------------------------------------------------------------------
}

From source file:net.bull.javamelody.internal.web.pdf.PdfCoreReport.java

License:Apache License

private void writeGraphs(Collection<JRobin> jrobins, Map<String, byte[]> mySmallGraphs)
        throws IOException, DocumentException {
    if (collector.isStopped()) {
        // pas de graphs, ils seraient en erreur sans timer
        // mais un message d'avertissement  la place
        final String message = getString("collect_server_misusage");
        final Paragraph jrobinParagraph = new Paragraph(message, PdfFonts.BOLD.getFont());
        jrobinParagraph.setAlignment(Element.ALIGN_CENTER);
        addToDocument(jrobinParagraph);//w  ww.  j a  va2s .c  o  m
        return;
    }
    if (collector.isStorageUsedByMultipleInstances()) {
        final String message = getString("storage_used_by_multiple_instances") + "\n\n";
        final Paragraph jrobinParagraph = new Paragraph(message, PdfFonts.BOLD.getFont());
        jrobinParagraph.setAlignment(Element.ALIGN_CENTER);
        addToDocument(jrobinParagraph);
    }
    final Paragraph jrobinParagraph = new Paragraph("",
            FontFactory.getFont(FontFactory.HELVETICA, 9f, Font.NORMAL));
    jrobinParagraph.setAlignment(Element.ALIGN_CENTER);
    jrobinParagraph.add(new Phrase("\n\n\n\n"));
    final Collection<byte[]> graphs;
    if (mySmallGraphs != null) {
        // si les graphiques ont t prinitialiss (en Swing) alors on les utilise
        graphs = mySmallGraphs.values();
    } else {
        if (jrobins.isEmpty()) {
            return;
        }
        graphs = new ArrayList<byte[]>(jrobins.size());
        for (final JRobin jrobin : jrobins) {
            graphs.add(jrobin.graph(range, SMALL_GRAPH_WIDTH, SMALL_GRAPH_HEIGHT));
        }
    }
    int i = 0;
    for (final byte[] graph : graphs) {
        if (i % 3 == 0 && i != 0) {
            // un retour aprs httpSessions et avant activeThreads pour l'alignement
            jrobinParagraph.add(new Phrase("\n\n\n\n\n"));
        }
        final Image image = Image.getInstance(graph);
        image.scalePercent(50);
        jrobinParagraph.add(new Phrase(new Chunk(image, 0, 0)));
        jrobinParagraph.add(new Phrase(" "));
        i++;
    }
    jrobinParagraph.add(new Phrase("\n"));
    addToDocument(jrobinParagraph);
}