Example usage for com.lowagie.text.pdf PdfPTable addCell

List of usage examples for com.lowagie.text.pdf PdfPTable addCell

Introduction

In this page you can find the example usage for com.lowagie.text.pdf PdfPTable addCell.

Prototype

public void addCell(Phrase phrase) 

Source Link

Document

Adds a cell element.

Usage

From source file:mx.dr.util.report.impl.PdfService.java

License:Open Source License

/**
* write a label in pdf document./*from  w  w  w  .ja  va  2  s  . co  m*/
* <br/>
* escribe una etiqueta en el documento pdf.
* @param doc pdf document / documento pdf.
* @param dto object that encompasses the values of the labels to be placed in the document / objeto que engloba los valores de las etiquetas que se colocaran en el documento.
* @param offset jump on the Y axis to be given before placing the tag in the document / salto en el eje Y que se dara antes de colocar la etiqueta en el documento.
* @param table container table if applicable / contenedor de tabla si es que aplica.
* @throws Exception If an error occurs / si ocurre algun error.
*/
public void estampaEtiqueta(Document doc, Object dto, Float offset, PdfPTable table) throws Exception {
    List<Field> fields = new ArrayList<Field>();

    for (Field m : dto.getClass().getDeclaredFields()) {
        m.setAccessible(true);
        if (m.getAnnotation(DRPdfLabel.class) != null) {
            fields.add(m);
        }
    }
    Collections.sort(fields, new Comparator<Field>() {

        public int compare(Field o1, Field o2) {
            DRPdfLabel etiqueta1 = o1.getAnnotation(DRPdfLabel.class);
            DRPdfLabel etiqueta2 = o2.getAnnotation(DRPdfLabel.class);
            String uno = int2String(etiqueta1.y()) + "." + int2String(etiqueta1.order());
            String dos = int2String(etiqueta2.y()) + "." + int2String(etiqueta2.order());
            return uno.compareTo(dos);

        }

        private String int2String(int num) {
            if (num < 10) {
                return "0" + num;
            } else {
                return String.valueOf(num);
            }
        }
    });
    DRPdfLabel etiqueta;
    DRPdfTable etiquetaTabla;
    int lineaActual = 0;
    Paragraph pantagram = null;
    StringBuffer sb = null;
    Font font;
    Object valor;
    String label;
    DRPdfImage img;
    int residuo;
    int adicional = 0;
    for (Field m : fields) {
        etiqueta = m.getAnnotation(DRPdfLabel.class);
        img = m.getAnnotation(DRPdfImage.class);
        valor = m.get(dto);
        if (valor != null && valor instanceof List) {
            etiquetaTabla = m.getAnnotation(DRPdfTable.class);
            PdfPTable tableDance = null;
            if (etiquetaTabla != null) {
                tableDance = new PdfPTable(etiquetaTabla.colsPercentage());
                tableDance.setSpacingBefore(etiqueta.offset());
                for (String c : etiquetaTabla.columnLabels()) {
                    tableDance.addCell(c);
                }
            }
            if (pantagram != null) {
                doc.add(pantagram);
                pantagram = null;
            }
            for (int i = 0; i < ((List) valor).size(); i++) {
                if (i == 0 && etiqueta.offset() > 0) {
                    estampaEtiqueta(doc, ((List) valor).get(i), etiqueta.offset(), tableDance);
                } else {
                    estampaEtiqueta(doc, ((List) valor).get(i), null, tableDance);
                }
            }
            if (etiquetaTabla != null) {
                doc.add(tableDance);
            }
        } else if (img != null) {
            /* File file = new File(IMGDIR + valor);
            FileInputStream inImg = new FileInputStream(file);
            byte[] b=new byte[(int)file.length()];
            inImg.read(b);*/

            Image ima = Image.getInstance(IMGDIR + valor);

            //System.out.println(ima.getPlainWidth());
            ima.scaleAbsoluteWidth(img.width());
            //System.out.println(ima.getScaledWidth());
            ima.scaleAbsoluteHeight(ima.getScaledWidth());
            ima.setAlignment(img.style());
            ima.setAbsolutePosition(img.x(), img.y());
            doc.add(ima);

        } else if (table != null) {

            PdfPCell cerda = null;

            label = value2String(valor);
            residuo = etiqueta.length() - label.length();
            label = etiqueta.length() > 0 && residuo < 0 ? label.substring(0, etiqueta.length()) : label;
            DRPdfColumn col = m.getAnnotation(DRPdfColumn.class);
            if (col != null) {
                cerda = new PdfPCell(new Paragraph(label));
                cerda.setColspan(col.colspan());
                table.addCell(cerda);
            } else {
                table.addCell(label);
            }

        } else {
            if (lineaActual < etiqueta.y()) {
                if (pantagram != null) {
                    doc.add(pantagram);
                }
                if (offset == null || etiqueta.y() > 1) {
                    if (etiqueta.offset() > 0) {
                        pantagram = new Paragraph(etiqueta.offset());
                    } else {
                        pantagram = new Paragraph();
                    }
                } else {
                    pantagram = new Paragraph(offset);
                }
                lineaActual = etiqueta.y();
            }

            if (etiqueta.wspacesBefore() > 0) {
                sb = new StringBuffer("");
                fillEmpty(etiqueta.wspacesBefore(), sb);
                font = new Font(Font.COURIER, 12);
                pantagram.add(new Chunk(sb.toString(), font));
            }
            sb = new StringBuffer("");
            label = value2String(valor);
            residuo = etiqueta.length() - label.length();
            label = etiqueta.length() > 0 && residuo < 0 ? label.substring(0, etiqueta.length()) : label;

            if (etiqueta.font().equals(BaseFont.COURIER)) {
                font = new Font(Font.COURIER, etiqueta.fontSize(), etiqueta.style(),
                        new Color(etiqueta.color()[0], etiqueta.color()[1], etiqueta.color()[2]));
                adicional = 0;
            } else {
                font = FontFactory.getFont(TTFDIR + etiqueta.font(), BaseFont.CP1252, BaseFont.EMBEDDED,
                        etiqueta.fontSize(), etiqueta.style(),
                        new Color(etiqueta.color()[0], etiqueta.color()[1], etiqueta.color()[2]));
                adicional = label.equals("") ? (residuo / 2) + 1 : 0;
            }

            if (etiqueta.length() > 0 && etiqueta.justified().equals(DRPdfLabel.JUSTIFIED.DER) && residuo > 0) {
                fillEmpty(residuo + adicional, sb);
            }
            sb.append(label);
            if (etiqueta.length() > 0 && etiqueta.justified().equals(DRPdfLabel.JUSTIFIED.IZQ) && residuo > 0) {
                fillEmpty(residuo + adicional, sb);
            }
            pantagram.add(new Chunk(sb.toString(), font));
        }
    }
    if (pantagram != null) {
        doc.add(pantagram);
    }

}

From source file:net.algem.contact.TeacherCtrl.java

License:Open Source License

private File getFollowUpAsPDF(String userId, String from, String to)
        throws IOException, BadElementException, DocumentException {
    String path = "/tmp/" + "suivi-" + userId + ".pdf";
    File f = new File(path);
    LOGGER.log(Level.INFO, f.getName());
    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
    Document document = new Document(PageSize.A4.rotate());
    PdfWriter.getInstance(document, byteArrayOutputStream); // Do this BEFORE document.open()
    document.open();/*from w ww.  jav a2s  .  c om*/

    PdfPTable table = new PdfPTable(10);
    table.setWidthPercentage(100);
    table.setWidths(new float[] { 1.1f, 1.2f, 0.6f, 1.5f, 1.5f, 2f, 0.5f, 0.5f, 1.9f, 1.9f });

    BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, false);
    BaseFont bfb = BaseFont.createFont(BaseFont.HELVETICA_BOLD, BaseFont.WINANSI, false);
    Font normalFont = new Font(bf, 10);
    Font boldFont = new Font(bfb, 10);

    String fromLabel = messageSource.getMessage("from.label", null, CTX_LOCALE);
    String toLabel = messageSource.getMessage("to.label", null, CTX_LOCALE);
    String prefix = messageSource.getMessage("follow-up.label", null, CTX_LOCALE) + " "
            + organization.get("name.label");
    String period = fromLabel.toLowerCase() + " " + from + " " + toLabel.toLowerCase() + " " + to;
    PdfPCell headerCell = new PdfPCell(new Phrase(prefix + " " + period, boldFont));

    headerCell.setBackgroundColor(Color.LIGHT_GRAY);
    headerCell.setColspan(10);
    table.addCell(headerCell);

    table.addCell(new PdfPCell(new Phrase(messageSource.getMessage("date.label", null, CTX_LOCALE), boldFont)));
    table.addCell(new PdfPCell(new Phrase(messageSource.getMessage("time.label", null, CTX_LOCALE), boldFont)));
    table.addCell(new PdfPCell(
            new Phrase(messageSource.getMessage("time.length.label", null, CTX_LOCALE), boldFont)));
    table.addCell(new PdfPCell(new Phrase(messageSource.getMessage("room.label", null, CTX_LOCALE), boldFont)));
    table.addCell(
            new PdfPCell(new Phrase(messageSource.getMessage("course.label", null, CTX_LOCALE), boldFont)));
    table.addCell(
            new PdfPCell(new Phrase(messageSource.getMessage("student.label", null, CTX_LOCALE), boldFont)));
    String abs = messageSource.getMessage("absence.label", null, CTX_LOCALE);
    table.addCell(new PdfPCell(new Phrase(abs != null ? abs.substring(0, 3) + "." : "", boldFont)));
    table.addCell(
            new PdfPCell(new Phrase(messageSource.getMessage("score.label", null, CTX_LOCALE), boldFont)));
    table.addCell(new PdfPCell(
            new Phrase(messageSource.getMessage("individual.logbook.label", null, CTX_LOCALE), boldFont)));
    table.addCell(new PdfPCell(
            new Phrase(messageSource.getMessage("collective.comment.label", null, CTX_LOCALE), boldFont)));

    List<ScheduleElement> items = getFollowUpSchedules(userId, from, to);
    //LOGGER.log(Level.INFO, items.toString());
    for (ScheduleElement e : items) {
        List<ScheduleRangeElement> ranges = new ArrayList<ScheduleRangeElement>(
                (Collection<? extends ScheduleRangeElement>) e.getRanges());

        for (ScheduleRangeElement r : ranges) {
            String status = CommonDao.getAbsenceFromNumberStatus(r.getFollowUp().getStatus());
            String note = r.getFollowUp().getNote();
            String content1 = r.getFollowUp().getContent();
            String content2 = e.getFollowUp().getContent();
            table.addCell(new Phrase(e.getDateFr().toString(), normalFont));
            table.addCell(new Phrase(r.getStart() + "-" + r.getEnd(), normalFont));
            table.addCell(new Phrase(new Hour(r.getLength()).toString(), normalFont));
            table.addCell(new Phrase(e.getDetail().get("room").getName(), normalFont));
            table.addCell(new Phrase(e.getDetail().get("course").getName(), normalFont));
            table.addCell(new Phrase(r.getPerson().getFirstName() + " " + r.getPerson().getName(), normalFont));
            table.addCell(new Phrase(status, normalFont));
            table.addCell(new Phrase(note == null ? "" : note, normalFont));
            table.addCell(new Phrase(content1 == null ? "" : content1.replaceAll("[\r\n]", " "), normalFont));
            table.addCell(new Phrase(content2 == null ? "" : content2.replaceAll("[\r\n]", " "), normalFont));
        }
    }

    document.add(table);
    document.close();
    byte[] pdfBytes = byteArrayOutputStream.toByteArray();
    Files.write(Paths.get(path), pdfBytes);
    return f;
}

From source file:net.algem.security.UserCtrl.java

License:Open Source License

private File getFollowUpAsPDF(String userId, String from, String to)
        throws IOException, BadElementException, DocumentException {
    String path = "/tmp/" + "suivi-" + userId + ".pdf";
    File f = new File(path);
    LOGGER.log(Level.INFO, f.getName());
    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
    Document document = new Document(PageSize.A4.rotate());
    PdfWriter.getInstance(document, byteArrayOutputStream); // Do this BEFORE document.open()
    document.open();/*from  w w  w . j a v  a 2s  .c  om*/

    PdfPTable table = new PdfPTable(10);
    table.setWidthPercentage(100);
    table.setWidths(new float[] { 1.1f, 1.2f, 0.6f, 1.5f, 1.5f, 2f, 0.5f, 0.5f, 1.9f, 1.9f });

    BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, false);
    BaseFont bfb = BaseFont.createFont(BaseFont.HELVETICA_BOLD, BaseFont.WINANSI, false);
    Font normalFont = new Font(bf, 10);
    Font boldFont = new Font(bfb, 10);

    String fromLabel = messageSource.getMessage("from.label", null, CTX_LOCALE);
    String toLabel = messageSource.getMessage("to.label", null, CTX_LOCALE);
    String prefix = messageSource.getMessage("follow-up.label", null, CTX_LOCALE) + " "
            + organization.get("name.label");
    String period = fromLabel.toLowerCase() + " " + from + " " + toLabel.toLowerCase() + " " + to;
    PdfPCell headerCell = new PdfPCell(new Phrase(prefix + " " + period, boldFont));

    headerCell.setBackgroundColor(Color.LIGHT_GRAY);
    headerCell.setColspan(10);
    table.addCell(headerCell);

    table.addCell(new PdfPCell(new Phrase(messageSource.getMessage("date.label", null, CTX_LOCALE), boldFont)));
    table.addCell(new PdfPCell(new Phrase(messageSource.getMessage("time.label", null, CTX_LOCALE), boldFont)));
    table.addCell(new PdfPCell(
            new Phrase(messageSource.getMessage("time.length.label", null, CTX_LOCALE), boldFont)));
    table.addCell(new PdfPCell(new Phrase(messageSource.getMessage("room.label", null, CTX_LOCALE), boldFont)));
    table.addCell(
            new PdfPCell(new Phrase(messageSource.getMessage("course.label", null, CTX_LOCALE), boldFont)));
    table.addCell(
            new PdfPCell(new Phrase(messageSource.getMessage("teacher.label", null, CTX_LOCALE), boldFont)));
    String abs = messageSource.getMessage("absence.label", null, CTX_LOCALE);
    table.addCell(new PdfPCell(new Phrase(abs != null ? abs.substring(0, 3) + "." : "", boldFont)));
    table.addCell(
            new PdfPCell(new Phrase(messageSource.getMessage("score.label", null, CTX_LOCALE), boldFont)));
    table.addCell(new PdfPCell(
            new Phrase(messageSource.getMessage("individual.logbook.label", null, CTX_LOCALE), boldFont)));
    table.addCell(new PdfPCell(
            new Phrase(messageSource.getMessage("collective.comment.label", null, CTX_LOCALE), boldFont)));

    fillPdfTable(table, getFollowUpSchedules(userId, from, to), normalFont);

    document.add(table);
    document.close();
    byte[] pdfBytes = byteArrayOutputStream.toByteArray();
    Files.write(Paths.get(path), pdfBytes);
    return f;
}

From source file:net.algem.security.UserCtrl.java

License:Open Source License

private void fillPdfTable(PdfPTable table, List<ScheduleElement> items, Font font) {
    for (ScheduleElement e : items) {
        List<ScheduleRangeElement> ranges = new ArrayList<ScheduleRangeElement>(
                (Collection<? extends ScheduleRangeElement>) e.getRanges());

        for (ScheduleRangeElement r : ranges) {
            String status = CommonDao.getAbsenceFromNumberStatus(r.getFollowUp().getStatus());
            String note = r.getFollowUp().getNote();
            String content1 = r.getFollowUp().getContent();
            String content2 = e.getFollowUp().getContent();
            table.addCell(new Phrase(e.getDateFr().toString(), font));
            table.addCell(new Phrase(r.getStart() + "-" + r.getEnd(), font));
            table.addCell(new Phrase(new Hour(r.getLength()).toString(), font));
            table.addCell(new Phrase(e.getDetail().get("room").getName(), font));
            table.addCell(new Phrase(e.getDetail().get("course").getName(), font));
            table.addCell(new Phrase(e.getDetail().get("teacher").getName(), font));
            table.addCell(new Phrase(status, font));
            table.addCell(new Phrase(note == null ? "" : note, font));
            table.addCell(new Phrase(content1 == null ? "" : content1.replaceAll("[\r\n]", " "), font));
            table.addCell(new Phrase(content2 == null ? "" : content2.replaceAll("[\r\n]", " "), font));
        }//from ww  w .ja va  2  s.  com
    }
}

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

License:Apache License

void initTable(List<String> headers, int[] relativeWidths) throws DocumentException {
    assert headers.size() == relativeWidths.length;
    final PdfPTable mytable = new PdfPTable(headers.size());
    mytable.setWidthPercentage(100);//ww  w. j a  v a 2s.com
    mytable.setWidths(relativeWidths);
    mytable.setHeaderRows(1);
    final PdfPCell defaultCell = mytable.getDefaultCell();
    defaultCell.setGrayFill(0.9f);
    defaultCell.setHorizontalAlignment(Element.ALIGN_CENTER);
    defaultCell.setPaddingLeft(0);
    defaultCell.setPaddingRight(0);
    final Font tableHeaderFont = PdfFonts.TABLE_HEADER.getFont();
    for (final String header : headers) {
        mytable.addCell(new Phrase(header, tableHeaderFont));
    }
    defaultCell.setPaddingLeft(2);
    defaultCell.setPaddingRight(2);
    this.table = mytable;
}

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

License:Apache License

private void writeGraphDetails() throws IOException, DocumentException {
    if (collector.isStopped()) {
        return;/*from w  w  w . j a v a  2s .co m*/
    }
    final PdfPTable jrobinTable = new PdfPTable(1);
    jrobinTable.setHorizontalAlignment(Element.ALIGN_CENTER);
    jrobinTable.setWidthPercentage(100);
    jrobinTable.getDefaultCell().setBorder(0);
    if (largeGraphs != null) {
        // si les graphiques ont t prinitialiss (en Swing) alors on les utilise
        for (final byte[] imageData : largeGraphs.values()) {
            final Image image = Image.getInstance(imageData);
            jrobinTable.addCell(image);
        }
    } else {
        final Collection<JRobin> counterJRobins = collector.getDisplayedCounterJRobins();
        if (counterJRobins.isEmpty()) {
            return;
        }
        for (final JRobin jrobin : counterJRobins) {
            // la hauteur de l'image est prvue pour qu'il n'y ait pas de graph seul sur une page
            final Image image = Image.getInstance(jrobin.graph(range, LARGE_GRAPH_WIDTH, LARGE_GRAPH_HEIGHT));
            jrobinTable.addCell(image);
        }
    }
    newPage();
    addToDocument(jrobinTable);
    newPage();
}

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

License:Apache License

private void writeRequestRumData() throws DocumentException {
    final CounterRequestRumData rumData = request.getRumData();
    final DecimalFormat percentFormat = I18N.createPercentFormat();
    final int networkTimeMean = rumData.getNetworkTimeMean();
    final int serverMean = request.getMean();
    final int domProcessingMean = rumData.getDomProcessingMean();
    final int pageRenderingMean = rumData.getPageRenderingMean();
    final int totalTime = networkTimeMean + serverMean + domProcessingMean + pageRenderingMean;
    final double networkPercent = 100d * networkTimeMean / totalTime;
    final double serverPercent = 100d * serverMean / totalTime;
    final double domProcessingPercent = 100d * domProcessingMean / totalTime;
    final double pageRenderingPercent = 100d * pageRenderingMean / totalTime;

    final PdfPTable table = new PdfPTable(2);
    table.setHorizontalAlignment(Element.ALIGN_LEFT);
    table.setWidthPercentage(25);//from  w w  w .  jav  a 2  s  .c o  m
    table.getDefaultCell().setBorderWidth(0);
    table.addCell(new Phrase(I18N.getString("Network"), cellFont));
    table.addCell(new Phrase(
            integerFormat.format(networkTimeMean) + " ms (" + percentFormat.format(networkPercent) + "%)",
            cellFont));
    table.addCell(new Phrase(I18N.getString("Server"), cellFont));
    table.addCell(new Phrase(
            integerFormat.format(serverMean) + " ms (" + percentFormat.format(serverPercent) + "%)", cellFont));
    table.addCell(new Phrase(I18N.getString("DOM_processing"), cellFont));
    table.addCell(new Phrase(integerFormat.format(domProcessingMean) + " ms ("
            + percentFormat.format(domProcessingPercent) + "%)", cellFont));
    table.addCell(new Phrase(I18N.getString("Page_rendering"), cellFont));
    table.addCell(new Phrase(integerFormat.format(pageRenderingMean) + " ms ("
            + percentFormat.format(pageRenderingPercent) + "%)", cellFont));
    addToDocument(table);
    addToDocument(new Phrase("\n", cellFont));
}

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

License:Apache License

private void writeGraph() throws IOException, DocumentException {
    final JRobin jrobin = collector.getJRobin(graphName);
    if (jrobin != null) {
        final byte[] img = jrobin.graph(range, 960, 400);
        final Image image = Image.getInstance(img);
        image.scalePercent(50);//from   w  ww .ja v  a  2s.c om

        final PdfPTable table = new PdfPTable(1);
        table.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.setWidthPercentage(100);
        table.getDefaultCell().setBorder(0);
        table.addCell("\n");
        table.addCell(image);
        table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);
        table.addCell(new Phrase(getString("graph_units"), cellFont));
        addToDocument(table);
    } else {
        // just in case request is null and collector.getJRobin(graphName) is null, we must write something in the document
        addToDocument(new Phrase("\n", cellFont));
    }
}

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

License:Apache License

private void writeHeader() throws DocumentException {
    final List<String> headers = new ArrayList<String>();
    headers.add("Beans");
    headers.addAll(calledBeans);/* w w w.j ava2 s  .  c o  m*/
    final int[] relativeWidths = new int[headers.size()];
    Arrays.fill(relativeWidths, 0, headers.size(), 1);
    relativeWidths[0] = 4;

    final PdfPTable table = new PdfPTable(headers.size());
    table.setWidthPercentage(100);
    table.setWidths(relativeWidths);
    table.setHeaderRows(1);
    final PdfPCell defaultCell = table.getDefaultCell();
    defaultCell.setGrayFill(0.9f);
    defaultCell.setHorizontalAlignment(Element.ALIGN_CENTER);
    defaultCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    defaultCell.setPaddingLeft(0);
    defaultCell.setPaddingRight(0);
    for (final String header : headers) {
        table.addCell(new Phrase(header, boldCellFont));
        // pas la premire entte de colonne
        defaultCell.setRotation(90);
    }
    defaultCell.setRotation(0);
    defaultCell.setPaddingLeft(2);
    defaultCell.setPaddingRight(2);
    currentTable = table;
}

From source file:net.nosleep.superanalyzer.Share.java

License:Open Source License

public static void saveAnalysisPdf(JFrame window, Analysis analysis, JProgressBar progressBar) {

    File pdfFile = askForFile(window, "pdf");
    if (pdfFile == null)
        return;//from  w w  w  .j  a  v a  2 s .c  o  m

    Misc.printMemoryInfo("pdfstart");

    DateFormat dateFormat = new SimpleDateFormat().getDateInstance(DateFormat.SHORT);
    String infoString = Misc.getString("CREATED_ON") + " "
            + dateFormat.format(Calendar.getInstance().getTime());

    int viewCount = 15;
    int viewsDone = 0;

    progressBar.setMinimum(0);
    progressBar.setMaximum(viewCount);

    Dimension d = new Dimension(500, 400);

    try {

        String tmpPath = System.getProperty("java.io.tmpdir") + "/image.png";

        // create the pdf document object
        Document document = new Document();

        // create a writer that listens to the document
        // and directs a PDF-stream to a file
        PdfWriter.getInstance(document, new FileOutputStream(pdfFile));

        // we open the document
        document.open();

        Font titleFont = FontFactory.getFont(FontFactory.HELVETICA, 18, Font.NORMAL,
                new Color(0x00, 0x00, 0x00));

        Paragraph p = new Paragraph(Misc.getString("MY_MUSIC_COLLECTION"), titleFont);
        p.setSpacingAfter(4);
        document.add(p);

        Font subtitleFont = FontFactory.getFont(FontFactory.HELVETICA, 8, Font.NORMAL,
                new Color(0x88, 0x88, 0x88));

        p = new Paragraph("The Super Analyzer by Nosleep Software", subtitleFont);
        p.setSpacingAfter(-2);
        document.add(p);

        p = new Paragraph(infoString, subtitleFont);
        p.setSpacingAfter(30);
        document.add(p);

        PdfPTable table = new PdfPTable(2);
        table.getDefaultCell().setBorder(PdfPCell.NO_BORDER);
        table.setTotalWidth(500f);
        table.setLockedWidth(true);

        Font statNameFont = FontFactory.getFont(FontFactory.HELVETICA, 8, Font.NORMAL,
                new Color(0x66, 0x66, 0x66));

        Font statValueFont = FontFactory.getFont(FontFactory.HELVETICA, 8, Font.NORMAL,
                new Color(0x00, 0x00, 0x00));

        Vector<StringTriple> statPairs = SummaryView.createStatPairs(analysis);
        Paragraph statParagraph = new Paragraph();

        Font summaryTitleFont = FontFactory.getFont(FontFactory.HELVETICA, 11, Font.BOLD,
                new Color(0x00, 0x00, 0x00));
        Paragraph titleParagraph = new Paragraph(Misc.getString("SUMMARY"), summaryTitleFont);
        statParagraph.add(titleParagraph);

        Paragraph spaceParagraph = new Paragraph("", statNameFont);
        statParagraph.add(spaceParagraph);

        for (int i = 0; i < statPairs.size(); i++) {
            Paragraph statLine = new Paragraph();
            StringTriple triple = statPairs.elementAt(i);
            Phrase namePhrase = new Phrase(triple.Name + ": ", statNameFont);
            Phrase valuePhrase = new Phrase(triple.Value, statValueFont);
            statLine.add(namePhrase);
            statLine.add(valuePhrase);
            statParagraph.add(statLine);
        }
        table.addCell(statParagraph);

        viewsDone++;
        progressBar.setValue(viewsDone);

        GenreView genreView = new GenreView(analysis);
        genreView.saveImage(new File(tmpPath), d);
        genreView = null;

        Image img = Image.getInstance(tmpPath);
        table.addCell(img);

        viewsDone++;
        progressBar.setValue(viewsDone);

        LikesView likesView = new LikesView(analysis);
        likesView.saveImage(new File(tmpPath), d);
        likesView = null;

        img = Image.getInstance(tmpPath);
        table.addCell(img);

        viewsDone++;
        progressBar.setValue(viewsDone);

        YearView yearView = new YearView(analysis);
        yearView.saveImage(new File(tmpPath), d);
        yearView = null;

        img = Image.getInstance(tmpPath);
        table.addCell(img);

        viewsDone++;
        progressBar.setValue(viewsDone);

        RatingView ratingView = new RatingView(analysis);
        ratingView.saveImage(new File(tmpPath), d);
        ratingView = null;

        img = Image.getInstance(tmpPath);
        table.addCell(img);

        viewsDone++;
        progressBar.setValue(viewsDone);

        TimeView timeView = new TimeView(analysis);
        timeView.saveImage(new File(tmpPath), d);
        timeView = null;

        img = Image.getInstance(tmpPath);
        table.addCell(img);

        viewsDone++;
        progressBar.setValue(viewsDone);

        QualityView qualityView = new QualityView(analysis);
        qualityView.saveImage(new File(tmpPath), d);
        qualityView = null;

        img = Image.getInstance(tmpPath);
        table.addCell(img);

        viewsDone++;
        progressBar.setValue(viewsDone);

        PlayCountView playCountView = new PlayCountView(analysis);
        playCountView.saveImage(new File(tmpPath), d);
        playCountView = null;

        img = Image.getInstance(tmpPath);
        table.addCell(img);

        viewsDone++;
        progressBar.setValue(viewsDone);

        MostPlayedAAView mostPlayedAAView = new MostPlayedAAView(analysis);

        mostPlayedAAView.saveImage(new File(tmpPath), d);
        img = Image.getInstance(tmpPath);
        table.addCell(img);

        mostPlayedAAView.saveImageExtra(new File(tmpPath), d);
        img = Image.getInstance(tmpPath);
        table.addCell(img);

        mostPlayedAAView = null;

        viewsDone++;
        progressBar.setValue(viewsDone);

        MostPlayedDGView mostPlayedDGView = new MostPlayedDGView(analysis);

        mostPlayedDGView.saveImage(new File(tmpPath), d);
        img = Image.getInstance(tmpPath);
        table.addCell(img);

        mostPlayedDGView.saveImageExtra(new File(tmpPath), d);
        img = Image.getInstance(tmpPath);
        table.addCell(img);

        mostPlayedDGView = null;

        viewsDone++;
        progressBar.setValue(viewsDone);

        EncodingKindView encodingKindView = new EncodingKindView(analysis);
        encodingKindView.saveImage(new File(tmpPath), d);
        encodingKindView = null;

        img = Image.getInstance(tmpPath);
        table.addCell(img);

        viewsDone++;
        progressBar.setValue(viewsDone);

        GrowthView growthView = new GrowthView(analysis);
        growthView.saveImage(new File(tmpPath), d);
        growthView = null;

        img = Image.getInstance(tmpPath);
        table.addCell(img);

        viewsDone++;
        progressBar.setValue(viewsDone);

        WordView wordView = new WordView(analysis);
        wordView.saveImage(new File(tmpPath), d);
        wordView = null;

        img = Image.getInstance(tmpPath);
        table.addCell(img);

        table.addCell("");

        viewsDone++;
        progressBar.setValue(viewsDone);
        Misc.printMemoryInfo("pdfend");

        document.add(table);

        // step 5: we close the document
        document.close();

    } catch (DocumentException de) {
        System.err.println(de.getMessage());
    } catch (IOException ioe) {
        System.err.println(ioe.getMessage());
    }
}