Example usage for com.lowagie.text Paragraph setAlignment

List of usage examples for com.lowagie.text Paragraph setAlignment

Introduction

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

Prototype

public void setAlignment(String alignment) 

Source Link

Document

Sets the alignment of this paragraph.

Usage

From source file:org.gbif.ipt.task.Eml2Rtf.java

License:Apache License

/**
 * Add Biobliography section. For each Bibliography listed in the References section, include the Citation identifier
 * after the Citation. If there is no Citation, only a Citation Identifier, then it will appear by itself.
 * /*w ww  .  ja  v  a 2  s .  c om*/
 * @param doc Document
 * @param eml EML
 * @throws DocumentException if problem occurs during add
 */
private void addReferences(Document doc, Eml eml) throws DocumentException {
    if (exists(eml.getBibliographicCitationSet())
            && !eml.getBibliographicCitationSet().getBibliographicCitations().isEmpty()) {
        // start new paragraph
        Paragraph p = new Paragraph();
        p.setAlignment(Element.ALIGN_JUSTIFIED);
        p.setFont(font);
        p.add(new Phrase(getText("rtf.references"), fontTitle));
        p.add(Chunk.NEWLINE);

        // for each Bibliography listed in the References section, include the Citation identifier after the Citation
        for (Citation citation : eml.getBibliographicCitationSet().getBibliographicCitations()) {
            // add citation text
            if (exists(citation.getCitation())) {
                p.add(citation.getCitation().replace("\r\n", "\n"));
            }
            // add optional identifier attribute
            if (exists(citation.getIdentifier())) {
                p.add(" ");
                p.add(citation.getIdentifier());
            }
            // separate each citation by a new line
            p.add(Chunk.NEWLINE);
        }
        // add to document
        doc.add(p);
        p.clear();
    }
}

From source file:org.gbif.ipt.task.Eml2Rtf.java

License:Apache License

/**
 * Add Spatial coverage section.//from ww  w  .j  a v a 2 s  .co m
 * 
 * @param doc Document
 * @param eml EML
 * @throws DocumentException if problem occurs during add
 */
private void addSpatialCoverage(Document doc, Eml eml) throws DocumentException {
    if (exists(eml.getGeospatialCoverages()) && !eml.getGeospatialCoverages().isEmpty()) {
        Paragraph p = new Paragraph();
        p.setAlignment(Element.ALIGN_JUSTIFIED);
        p.setFont(font);
        boolean firstCoverage = true;
        for (GeospatialCoverage coverage : eml.getGeospatialCoverages()) {
            if (firstCoverage) {
                firstCoverage = false;
            } else {
                p.add(Chunk.NEWLINE);
            }
            if (exists(coverage.getDescription())) {
                p.add(new Phrase(getText("rtf.spatialCoverage"), fontTitle));
                p.add(Chunk.NEWLINE);
                p.add(Chunk.NEWLINE);
                p.add(new Phrase(getText("rtf.spatialCoverage.general") + ". ", fontTitle));
                p.add(coverage.getDescription().replace("\r\n", "\n"));
                p.add(Chunk.NEWLINE);
            }
            p.add(new Phrase(getText("rtf.spatialCoverage.coordinates") + ". ", fontTitle));
            BBox coordinates = coverage.getBoundingCoordinates();
            p.add(CoordinateUtils.decToDms(coordinates.getMin().getLatitude(), CoordinateUtils.LATITUDE));
            p.add(" " + getText("rtf.spatialCoverage.and") + " ");
            p.add(CoordinateUtils.decToDms(coordinates.getMax().getLatitude(), CoordinateUtils.LATITUDE));
            p.add(" " + getText("rtf.spatialCoverage.latitude") + "; ");
            p.add(CoordinateUtils.decToDms(coordinates.getMin().getLongitude(), CoordinateUtils.LONGITUDE));
            p.add(" " + getText("rtf.spatialCoverage.and") + " ");
            p.add(CoordinateUtils.decToDms(coordinates.getMax().getLongitude(), CoordinateUtils.LONGITUDE));
            p.add(" " + getText("rtf.spatialCoverage.longitude") + " ");
            p.add(Chunk.NEWLINE);
        }
        doc.add(p);
        p.clear();
    }
}

From source file:org.gbif.ipt.task.Eml2Rtf.java

License:Apache License

/**
 * Add taxonomic coverages, writing in this order: description, ranks, then common names.
 * /*w ww  .j a v  a 2s  .com*/
 * @param doc Document
 * @param eml EML object
 * @throws DocumentException if an error occurred adding to the Document
 */
private void addTaxonomicCoverages(Document doc, Eml eml, Locale local) throws DocumentException {
    // proceed, provided there is at least 1 Taxonomic Coverage to iterate over
    if (exists(eml.getTaxonomicCoverages()) && !eml.getTaxonomicCoverages().isEmpty()) {

        // begin new paragraph
        Paragraph p = new Paragraph();
        p.setAlignment(Element.ALIGN_JUSTIFIED);
        p.setFont(font);
        boolean firstTaxon = true;
        for (TaxonomicCoverage taxcoverage : eml.getTaxonomicCoverages()) {
            if (!firstTaxon) {
                p.add(Chunk.NEWLINE);
            }
            firstTaxon = false;
            p.add(new Phrase(getText("rtf.taxcoverage"), fontTitle));
            p.add(Chunk.NEWLINE);
            p.add(Chunk.NEWLINE);
            if (exists(taxcoverage.getDescription())) {
                p.add(new Phrase(getText("rtf.taxcoverage.description") + ". ", fontTitle));
                p.add(taxcoverage.getDescription().replace("\r\n", "\n"));
                p.add(Chunk.NEWLINE);
                p.add(Chunk.NEWLINE);
            }
            /*
            String requestedLocale = Strings.emptyToNull(XSSUtil.stripXSS(local.getLanguage()).trim());
            ResourceBundle resourceBundle = textProvider.getTexts(new Locale(requestedLocale));
            */
            Map<String, String> ranks = vocabManager.getI18nVocab(Constants.VOCAB_URI_RANKS, "es", false);
            boolean firstRank = true;
            for (String rank : ranks.keySet()) {
                boolean wroteRank = false;
                for (TaxonKeyword keyword : taxcoverage.getTaxonKeywords()) {
                    if (exists(keyword.getRank()) && keyword.getRank().equals(rank)) {
                        if (!wroteRank) {
                            if (firstRank) {
                                p.add(new Phrase(getText("rtf.taxcoverage.rank"), fontTitle));
                            }
                            p.add(Chunk.NEWLINE);
                            p.add(new Phrase(StringUtils.capitalize(ranks.get(rank)) + ". ", fontTitle)); //**
                            p.add(keyword.getScientificName());
                            wroteRank = true;
                            firstRank = false;
                        } else {
                            p.add(", " + keyword.getScientificName());
                        }
                    }
                }
            }
            p.add(Chunk.NEWLINE);
            boolean isFirst = true;
            for (TaxonKeyword keyword : taxcoverage.getTaxonKeywords()) {
                if (exists(keyword.getCommonName())) {
                    if (isFirst) {
                        p.add(new Phrase(getText("rtf.taxcoverage.common") + ". ", fontTitle)); //**
                    } else {
                        p.add(", ");
                    }
                    isFirst = false;
                    p.add(keyword.getCommonName());
                }
            }
        }
        p.add(Chunk.NEWLINE);
        doc.add(p);
        p.clear();
    }
}

From source file:org.gbif.ipt.task.Eml2Rtf.java

License:Apache License

/**
 * Add temporal coverages section./*from   w ww . jav  a 2s  . c o  m*/
 * 
 * @param doc Document
 * @param eml EML
 * @throws DocumentException if problem occurs during add
 */
private void addTemporalCoverages(Document doc, Eml eml, Locale loc) throws DocumentException {
    if (exists(eml.getTemporalCoverages()) && !eml.getTemporalCoverages().isEmpty()) {
        Paragraph p = new Paragraph();
        p.setAlignment(Element.ALIGN_JUSTIFIED);
        p.setFont(font);
        DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.LONG, loc);
        SimpleDateFormat timeFormat = new SimpleDateFormat("SSS", loc);
        SimpleDateFormat yearFormat = new SimpleDateFormat("yyyy", loc);
        boolean firstCoverage = true;
        for (TemporalCoverage coverage : eml.getTemporalCoverages()) {
            if (coverage.getType().equals(TemporalCoverageType.SINGLE_DATE)) {
                if (coverage.getStartDate() != null) {
                    if (firstCoverage) {
                        firstCoverage = false;
                    } else {
                        p.add(Chunk.NEWLINE);
                    }
                    p.add(new Phrase(getText("rtf.tempcoverage"), fontTitle));
                    p.add(Chunk.NEWLINE);
                    if (timeFormat.format(coverage.getStartDate()).equals("001")) {
                        p.add(yearFormat.format(coverage.getStartDate()));
                    } else {
                        p.add(dateFormat.format(coverage.getStartDate()));
                    }
                    p.add(Chunk.NEWLINE);
                }
            } else if (coverage.getType() == TemporalCoverageType.DATE_RANGE) {
                if (coverage.getStartDate() != null && coverage.getEndDate() != null) {
                    if (firstCoverage) {
                        firstCoverage = false;
                    } else {
                        p.add(Chunk.NEWLINE);
                    }
                    p.add(new Phrase(getText("rtf.tempcoverage"), fontTitle));
                    p.add(Chunk.NEWLINE);
                    if (timeFormat.format(coverage.getStartDate()).equals("001")) {
                        p.add(yearFormat.format(coverage.getStartDate()));
                    } else {
                        p.add(dateFormat.format(coverage.getStartDate()));
                    }
                    p.add(" - ");
                    if (timeFormat.format(coverage.getEndDate()).equals("001")) {
                        p.add(yearFormat.format(coverage.getEndDate()));
                    } else {
                        p.add(dateFormat.format(coverage.getEndDate()));
                    }
                    p.add(Chunk.NEWLINE);
                }
            }
        }
        doc.add(p);
        p.clear();
    }
}

From source file:org.goodoldai.jeff.report.pdf.PDFReportBuilder.java

License:Open Source License

/**
 * This method inserts the header into the PDF report. The header consists 
 * of general data collected from the explanation (date and time created, 
 * owner, title, language and country). If any of this data is missing, it is not
 * inserted into the report. Since the report format is PDF, the provided 
 * stream should be an instance of com.lowagie.text.Document.
 * /*w  ww  .  j a va  2s  .  co m*/
 * @param explanation explanation from which the header data is to be
 * collected
 * @param stream output stream that the header is supposed to be inserted
 * into
 * 
 * @throws org.goodoldai.jeff.explanation.ExplanationException if any of the arguments are
 * null or if the entered output stream type is not com.lowagie.text.Document
 */
protected void insertHeader(Explanation explanation, Object stream) {
    if (explanation == null) {
        throw new ExplanationException("The argument 'explanation' is mandatory, so it can not be null");
    }

    if (stream == null) {
        throw new ExplanationException("The argument 'stream' is mandatory, so it can not be null");
    }

    if (!(stream instanceof Document)) {
        throw new ExplanationException("The entered stream must be a com.lowagie.text.Document instance");
    }

    Document doc = (Document) stream;

    String owner = explanation.getOwner();
    String title = explanation.getTitle();

    doc.addCreator("JEFF (Java Explanation Facility Framework)");
    doc.addAuthor(owner + " [OWNER]");
    doc.addCreationDate();

    if (title != null) {
        try {
            Phrase p = new Phrase(title, new Font(Font.HELVETICA, 16));
            Paragraph pa = new Paragraph(p);
            pa.setSpacingBefore(10);
            pa.setSpacingAfter(30);
            pa.setAlignment(Element.ALIGN_CENTER);
            doc.add(pa);
        } catch (DocumentException ex) {
            throw new ExplanationException(ex.getMessage());
        }
    }

}

From source file:org.gtdfree.addons.PDFExportAddOn.java

License:Open Source License

@Override
public void export(GTDModel model, ActionsCollection collection, OutputStream out,
        ExportAddOn.ExportOrder order, FileFilter ff, boolean compact) throws Exception {

    fontSelector = new FontSelector();
    fontSelectorB = new FontSelector();
    fontSelectorB2 = new FontSelector();
    fontSelectorB4 = new FontSelector();

    baseFont = fontModel.getBaseFont();//from   w w w.jav a2 s . com

    for (BaseFont bf : fontModel.getFonts()) {
        fontSelector.addFont(new Font(bf, baseFontSize));
        fontSelectorB.addFont(new Font(bf, baseFontSize, Font.BOLD));
        fontSelectorB2.addFont(new Font(bf, baseFontSize + 2, Font.BOLD));
        fontSelectorB4.addFont(new Font(bf, baseFontSize + 4, Font.BOLD));
    }

    boolean emptyH2 = false;
    boolean emptyH3 = false;

    PdfPTable actionTable = null;

    Document doc = new Document();

    if (sizeSet) {
        doc.setPageSize(pageSize);
    }
    if (marginSet) {
        doc.setMargins(marginLeft, marginRight, marginTop, marginBottom);
    }

    //System.out.println("PDF size "+doc.getPageSize().toString());
    //System.out.println("PDF m "+marginLeft+" "+marginRight+" "+marginTop+" "+marginBottom);

    @SuppressWarnings("unused")
    PdfWriter pw = PdfWriter.getInstance(doc, out);

    doc.addCreationDate();
    doc.addTitle("GTD-Free PDF");
    doc.addSubject("GTD-Free data exported as PDF");

    HeaderFooter footer = new HeaderFooter(newParagraph(), true);
    footer.setAlignment(HeaderFooter.ALIGN_CENTER);
    footer.setBorder(HeaderFooter.TOP);
    doc.setFooter(footer);

    doc.open();

    Phrase ch = newTitle("GTD-Free Data");
    Paragraph p = new Paragraph(ch);
    p.setAlignment(Paragraph.ALIGN_CENTER);

    PdfPTable t = new PdfPTable(1);
    t.setWidthPercentage(100f);
    PdfPCell c = newCell(p);
    c.setBorder(Table.BOTTOM);
    c.setBorderWidth(2.5f);
    c.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    c.setPadding(5f);
    t.addCell(c);
    doc.add(t);

    Iterator<Object> it = collection.iterator(order);

    while (it.hasNext()) {
        Object o = it.next();

        if (o == ActionsCollection.ACTIONS_WITHOUT_PROJECT) {

            if (order == ExportAddOn.ExportOrder.FoldersProjectsActions) {

                doc.add(newSubSection(ActionsCollection.ACTIONS_WITHOUT_PROJECT));

                emptyH2 = false;
                emptyH3 = true;
            } else {

                doc.add(newSection(ActionsCollection.ACTIONS_WITHOUT_PROJECT));

                emptyH2 = true;
                emptyH3 = false;
            }

            continue;
        }

        if (o instanceof Folder) {

            Folder f = (Folder) o;

            if (actionTable != null) {
                doc.add(actionTable);
                actionTable = null;
            }

            if (f.isProject()) {

                if (order == ExportAddOn.ExportOrder.ProjectsActions
                        || order == ExportAddOn.ExportOrder.ProjectsFoldersActions) {

                    if (emptyH2 || emptyH3) {
                        p = newParagraph(NONE_DOT);
                        doc.add(p);
                    }

                    doc.add(newSection(f.getName()));

                    if (compact) {
                        if (f.getDescription() != null && f.getDescription().length() > 0) {
                            p = newParagraph(f.getDescription());
                            p.setIndentationLeft(10f);
                            p.setIndentationRight(10f);
                            doc.add(p);
                        }
                    } else {
                        t = new PdfPTable(2);
                        t.setKeepTogether(true);
                        t.setSpacingBefore(5f);
                        t.setWidthPercentage(66f);
                        t.setWidths(new float[] { 0.33f, 0.66f });

                        c = newCell("ID");
                        t.addCell(c);
                        c = newCell(newStrongParagraph(String.valueOf(f.getId())));
                        t.addCell(c);
                        c = newCell("Type");
                        t.addCell(c);
                        c = newCell(newStrongParagraph("Project"));
                        t.addCell(c);
                        c = newCell("Open");
                        t.addCell(c);
                        c = newCell(newStrongParagraph(String.valueOf(f.getOpenCount())));
                        t.addCell(c);
                        c = newCell("All");
                        t.addCell(c);
                        c = newCell(newStrongParagraph(String.valueOf(f.size())));
                        t.addCell(c);
                        c = newCell("Description");
                        t.addCell(c);
                        c = newDescriptionCell(f.getDescription());
                        t.addCell(c);

                        doc.add(t);
                    }

                    emptyH2 = true;
                    emptyH3 = false;

                } else {

                    if (emptyH3) {
                        p = newParagraph(NONE_DOT);
                        doc.add(p);
                    }

                    doc.add(newSubSection("Project:" + " " + f.getName()));

                    emptyH2 = false;
                    emptyH3 = true;
                }

                continue;

            }
            if (order == ExportAddOn.ExportOrder.FoldersActions
                    || order == ExportAddOn.ExportOrder.FoldersProjectsActions) {

                if (emptyH2 || emptyH3) {
                    p = newParagraph(NONE_DOT);
                    doc.add(p);
                }

                doc.add(newSection(f.getName()));

                if (compact) {
                    if (f.getDescription() != null && f.getDescription().length() > 0) {
                        p = newParagraph(f.getDescription());
                        p.setIndentationLeft(10f);
                        p.setIndentationRight(10f);
                        doc.add(p);
                    }
                } else {

                    t = new PdfPTable(2);
                    t.setKeepTogether(true);
                    t.setSpacingBefore(5f);
                    t.setWidthPercentage(66f);
                    t.setWidths(new float[] { 0.33f, 0.66f });

                    c = newCell("ID");
                    t.addCell(c);
                    c = newCell(newStrongParagraph(String.valueOf(f.getId())));
                    t.addCell(c);

                    String type = "";
                    if (f.isAction()) {
                        type = "Action list";
                    } else if (f.isInBucket()) {
                        type = "In-Bucket";
                    } else if (f.isQueue()) {
                        type = "Next action queue";
                    } else if (f.isReference()) {
                        type = "Reference list";
                    } else if (f.isSomeday()) {
                        type = "Someday/Maybe list";
                    } else if (f.isBuildIn()) {
                        type = "Default list";
                    }

                    c = newCell("Type");
                    t.addCell(c);
                    c = newCell(newStrongParagraph(type));
                    t.addCell(c);
                    c = newCell("Open");
                    t.addCell(c);
                    c = newCell(newStrongParagraph(String.valueOf(f.getOpenCount())));
                    t.addCell(c);
                    c = newCell("All");
                    t.addCell(c);
                    c = newCell(newStrongParagraph(String.valueOf(f.size())));
                    t.addCell(c);
                    c = newCell("Description");
                    t.addCell(c);
                    c = newDescriptionCell(f.getDescription());
                    t.addCell(c);

                    doc.add(t);
                }

                emptyH2 = true;
                emptyH3 = false;

            } else {

                if (emptyH3) {
                    p = newParagraph(NONE_DOT);
                    doc.add(p);
                }

                doc.add(newSubSection("List:" + " " + f.getName()));

                emptyH2 = false;
                emptyH3 = true;

            }

            continue;

        }

        if (o instanceof Action) {
            emptyH2 = false;
            emptyH3 = false;

            Action a = (Action) o;

            if (compact) {

                if (actionTable == null) {
                    actionTable = new PdfPTable(5);
                    actionTable.setWidthPercentage(100f);
                    actionTable.setHeaderRows(1);
                    actionTable.setSpacingBefore(5f);
                    c = newHeaderCell("ID");
                    actionTable.addCell(c);
                    c = newHeaderCell("Pri.");
                    actionTable.addCell(c);
                    c = newHeaderCell("Description");
                    actionTable.addCell(c);
                    c = newHeaderCell("Reminder");
                    actionTable.addCell(c);
                    c = newHeaderCell(CHECK_RESOLVED);
                    actionTable.addCell(c);

                    float width = doc.getPageSize().getWidth() - doc.getPageSize().getBorderWidthLeft()
                            - doc.getPageSize().getBorderWidthRight();
                    int i = model.getLastActionID();
                    float step = baseFontSize - 1;
                    int steps = (int) Math.floor(Math.log10(i)) + 1;
                    // ID column
                    float col1 = 8 + steps * step;
                    // Priority column
                    float col2 = 4 + 3 * (baseFontSize + 4);
                    // Reminder column
                    float col4 = 10 + step * 11;
                    // Resolved column
                    float col5 = 8 + baseFontSize;
                    // Description column
                    float col3 = width - col1 - col2 - col4 - col5;
                    actionTable.setWidths(new float[] { col1, col2, col3, col4, col5 });

                }

                addSingleActionRow(a, actionTable);

            } else {
                addSingleActionTable(model, doc, a);
            }
        }

    }

    if (actionTable != null) {
        doc.add(actionTable);
        actionTable = null;
    }
    if (emptyH2 || emptyH3) {

        p = newParagraph(NONE_DOT);
        doc.add(p);
    }

    //w.writeCharacters("Exported: "+ApplicationHelper.toISODateTimeString(new Date()));

    doc.close();
}

From source file:org.inbio.modeling.core.manager.impl.ExportManagerImpl.java

License:Open Source License

private void addDocumentFooter(Document d, String[] texts) throws DocumentException {

    Font smallFont = new Font(Font.TIMES_ROMAN, 12, Font.BOLD);
    Font smallGreenFont = new Font(Font.TIMES_ROMAN, 12, Font.BOLD, Color.GREEN);
    Font smallDarkGreenFont = new Font(Font.TIMES_ROMAN, 12, Font.BOLD, new Color(135, 194, 53));

    Paragraph footer = new Paragraph();
    this.addLineSeparator(footer, 1);
    footer.setAlignment(Paragraph.ALIGN_CENTER);
    this.addEmptyLine(footer, 1);
    footer.add(new Paragraph(texts[0], smallFont));
    footer.add(new Paragraph(texts[1], smallGreenFont));
    footer.add(new Paragraph(texts[2], smallDarkGreenFont));
    this.addEmptyLine(footer, 1);
    d.add(footer);// ww  w.j av  a2 s  .  c  o  m
}

From source file:org.inbio.modeling.core.manager.impl.ExportManagerImpl.java

License:Open Source License

private void addImageSection(Document d, String mapName, Long currentSessionId)
        throws BadElementException, MalformedURLException, IOException, DocumentException {

    Image mapImage = Image.getInstance(mapsHome + mapName + "_T_" + currentSessionId + ".png");
    mapImage.scaleToFit(550, 413);/*from w  w  w  . j  a  v  a2  s  . c  om*/
    mapImage.setAlignment(Image.ALIGN_LEFT);

    // scale
    Image scaleImage = Image.getInstance(mapsHome + "scale.jpg");
    scaleImage.scaleToFit(30, 150);
    scaleImage.setAlignment(Image.ALIGN_RIGHT);

    Paragraph images = new Paragraph();
    images.setAlignment(Paragraph.ALIGN_RIGHT);

    //upper scale leyend
    images.add(new Chunk(this.getI18nString("pdfReport.scaleUpper") + "\n\n\n\n\n\n\n",
            new Font(Font.COURIER, 8, Font.BOLDITALIC)));
    // Map
    images.add(new Chunk(mapImage, 1F, 1F));
    // Scale
    images.add(new Chunk(scaleImage, 1F, 1F));
    // lower scale leyend
    images.add(new Chunk("\n" + this.getI18nString("pdfReport.scaleLower") + "\n",
            new Font(Font.COURIER, 8, Font.BOLDITALIC)));

    d.add(images);
}

From source file:org.jmesa.view.pdfp.PdfPView.java

License:Apache License

public Paragraph getTableCaption() throws Exception {

    Paragraph p = new Paragraph(getTable().getCaption(), getFont(HELVETICA, 18, BOLD, getCaptionFontColor()));
    p.setAlignment(getCaptionAlignment());
    return p;/*from  w w  w.  ja  va 2 s  .c o  m*/
}

From source file:org.kuali.kfs.module.ar.batch.service.impl.CustomerInvoiceWriteoffBatchServiceImpl.java

License:Open Source License

protected void writeFileNameSectionTitle(com.lowagie.text.Document pdfDoc, String filenameLine) {
    Font font = FontFactory.getFont(FontFactory.COURIER, 10, Font.BOLD);

    //  file name title, get title only, on windows & unix platforms
    String fileNameOnly = filenameLine.toUpperCase();
    int indexOfSlashes = fileNameOnly.lastIndexOf("\\");
    if (indexOfSlashes < fileNameOnly.length()) {
        fileNameOnly = fileNameOnly.substring(indexOfSlashes + 1);
    }/*from   ww  w . j  a v  a2s .co  m*/
    indexOfSlashes = fileNameOnly.lastIndexOf("/");
    if (indexOfSlashes < fileNameOnly.length()) {
        fileNameOnly = fileNameOnly.substring(indexOfSlashes + 1);
    }

    Paragraph paragraph = new Paragraph();
    paragraph.setAlignment(com.lowagie.text.Element.ALIGN_LEFT);
    Chunk chunk = new Chunk(fileNameOnly, font);
    chunk.setBackground(Color.LIGHT_GRAY, 5, 5, 5, 5);
    paragraph.add(chunk);

    //  blank line
    paragraph.add(new Chunk("", font));

    try {
        pdfDoc.add(paragraph);
    } catch (DocumentException e) {
        LOG.error("iText DocumentException thrown when trying to write content.", e);
        throw new RuntimeException("iText DocumentException thrown when trying to write content.", e);
    }
}