Example usage for com.lowagie.text Chunk NEWLINE

List of usage examples for com.lowagie.text Chunk NEWLINE

Introduction

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

Prototype

Chunk NEWLINE

To view the source code for com.lowagie.text Chunk NEWLINE.

Click Source Link

Document

This is a Chunk containing a newline.

Usage

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

License:Apache License

/**
 * Add "Resultados" section.//from   www  .jav a 2 s  . com
 * 
 * @param doc Document
 * @param eml EML
 * @throws DocumentException if problem occurs during add
 */

private void addResul(Document doc) throws DocumentException {
    Paragraph p = new Paragraph();
    p.setAlignment(Element.ALIGN_JUSTIFIED);
    p.setFont(font);
    p.add(new Phrase(getText("rtf.results"), fontTitle));
    p.add(Chunk.NEWLINE);
    p.add(Chunk.NEWLINE);

    doc.add(p);
    p.clear();
}

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

License:Apache License

/**
 * Add natural collections section.//w w w . j  a  va 2  s  .c  o  m
 * 
 * @param doc Document
 * @param eml EML
 * @throws DocumentException if problem occurs during add
 */
private void addNaturalCollections(Document doc, Eml eml) throws DocumentException {
    if (exists(eml.getParentCollectionId()) || exists(eml.getCollectionName()) || exists(eml.getCollectionId())
            || !eml.getTemporalCoverages().isEmpty() || exists(eml.getSpecimenPreservationMethod())
            || !eml.getJgtiCuratorialUnits().isEmpty()) {
        Paragraph p = new Paragraph();
        p.setAlignment(Element.ALIGN_JUSTIFIED);
        p.setFont(font);

        p.add(new Phrase(getText("rtf.collections.description"), fontTitle));
        p.add(Chunk.NEWLINE);
        p.add(Chunk.NEWLINE);

        if (exists(eml.getCollectionName())) {
            p.add(new Phrase(getText("rtf.collections.name") + ". ", fontTitle));
            p.add(eml.getCollectionName());
            p.add(Chunk.NEWLINE);
        }

        if (exists(eml.getCollectionId())) {
            p.add(new Phrase(getText("rtf.collections.identifier") + ". ", fontTitle));
            p.add(eml.getCollectionId());
            p.add(Chunk.NEWLINE);
        }

        if (exists(eml.getParentCollectionId())) {
            p.add(new Phrase(getText("rtf.collections.parent") + ". ", fontTitle));
            p.add(eml.getParentCollectionId());
            p.add(Chunk.NEWLINE);
        }

        if (exists(eml.getSpecimenPreservationMethod())) {
            p.add(new Phrase(getText("rtf.collections.specimen") + ". ", fontTitle));
            VocabularyConcept vocabConcept = vocabManager.get(Constants.VOCAB_URI_PRESERVATION_METHOD)
                    .findConcept(eml.getSpecimenPreservationMethod());
            // write preservation method in default language as matched from vocabulary or original value
            if (exists(vocabConcept)) {
                p.add(vocabConcept.getPreferredTerm(DEFAULT_LANGUAGE).getTitle());
            } else {
                p.add(eml.getSpecimenPreservationMethod().replace("\r\n", "\n"));
            }
            p.add(Chunk.NEWLINE);
        }

        for (TemporalCoverage coverage : eml.getTemporalCoverages()) {
            if (coverage.getType() == TemporalCoverageType.FORMATION_PERIOD) {
                p.add(new Phrase(getText("rtf.collections.formatPeriod") + ". ", fontTitle));
                p.add(coverage.getFormationPeriod());
                p.add(Chunk.NEWLINE);
            }
        }
        for (TemporalCoverage coverage : eml.getTemporalCoverages()) {
            if (coverage.getType() == TemporalCoverageType.LIVING_TIME_PERIOD) {
                p.add(new Phrase(getText("rtf.collections.livingPeriod") + ". ", fontTitle));
                p.add(coverage.getLivingTimePeriod());
                p.add(Chunk.NEWLINE);
            }
        }

        for (JGTICuratorialUnit unit : eml.getJgtiCuratorialUnits()) {
            p.add(new Phrase(getText("rtf.collections.curatorial") + ". ", fontTitle));
            if (unit.getType() == JGTICuratorialUnitType.COUNT_RANGE) {
                p.add("Entre " + unit.getRangeStart() + " y " + unit.getRangeEnd());
            }
            if (unit.getType() == JGTICuratorialUnitType.COUNT_WITH_UNCERTAINTY) {
                p.add(unit.getRangeMean() + " " + getText("rtf.collections.curatorial.text") + " "
                        + unit.getUncertaintyMeasure());
            }
            p.add(" (" + unit.getUnitType() + ")");
            p.add(Chunk.NEWLINE);
        }
        if (!p.isEmpty()) {
            doc.add(p);
        }
        p.clear();
    }
}

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

License:Apache License

/**
 * Add project data section.//  w  ww  . j  av a 2s .  com
 * 
 * @param doc Document
 * @param eml EML
 * @throws DocumentException if problem occurs during add
 */
private void addProjectData(Document doc, Eml eml) throws DocumentException {
    if (exists(eml.getProject().getTitle()) || exists(eml.getProject().getPersonnel().getFirstName())
            || exists(eml.getProject().getFunding())
            || exists(eml.getProject().getStudyAreaDescription().getDescriptorValue())
            || exists(eml.getProject().getDesignDescription())) {
        Map<String, String> roles = vocabManager.getI18nVocab(Constants.VOCAB_URI_ROLES, "es", false);
        String role = "";
        if (exists(eml.getProject().getPersonnel().getRole())) {
            role = " (" + roles.get(eml.getProject().getPersonnel().getRole()) + ")";
        }
        Paragraph p = new Paragraph();
        p.setAlignment(Element.ALIGN_JUSTIFIED);
        p.setFont(font);
        p.add(new Phrase(getText("rtf.project.details"), fontTitle));
        p.add(Chunk.NEWLINE);
        p.add(Chunk.NEWLINE);
        if (exists(eml.getProject().getTitle())) {
            p.add(new Phrase(getText("rtf.project.title") + ". ", fontTitle));
            p.add(eml.getProject().getTitle());
            p.add(Chunk.NEWLINE);
        }
        p.add(new Phrase(getText("rtf.project.personnel") + ". ", fontTitle));
        if (exists(eml.getProject().getPersonnel().getFirstName())) {
            p.add(eml.getProject().getPersonnel().getFirstName() + " "
                    + eml.getProject().getPersonnel().getLastName() + role);
            p.add(Chunk.NEWLINE);
        }
        if (exists(eml.getProject().getFunding())) {
            p.add(new Phrase(getText("rtf.project.funding") + ". ", fontTitle));
            p.add(eml.getProject().getFunding().replace("\r\n", "\n"));
            p.add(Chunk.NEWLINE);
        }
        if (exists(eml.getProject().getStudyAreaDescription().getDescriptorValue())) {
            p.add(new Phrase(getText("rtf.project.area") + ". ", fontTitle));
            p.add(eml.getProject().getStudyAreaDescription().getDescriptorValue().replace("\r\n", "\n"));
            p.add(Chunk.NEWLINE);
        }
        if (exists(eml.getProject().getDesignDescription())) {
            p.add(Chunk.NEWLINE);
            p.add(new Phrase(getText("rtf.project.design"), fontTitle));
            p.add(Chunk.NEWLINE);
            p.add(eml.getProject().getDesignDescription().replace("\r\n", "\n"));
            p.add(Chunk.NEWLINE);
        }
        doc.add(p);
        p.clear();
    }
}

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.
 * //from  w w w  .  j a  v  a2 s  .  co  m
 * @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

/**
 * Construct IPT URL public resource link, and add it to the document. Only public or registered resources can
 * have a public resource link./*from  www .  java  2  s.co m*/
 * </p>
 * e.g. Data published through GBIF: http://localhost:8090/ipt/resource.do?r=shortName
 * 
 * @param doc Document
 * @param resource Resource
 * @throws DocumentException if an error in adding to the document was encountered
 */
private void addResourceLink(Document doc, Resource resource) throws DocumentException {
    if (resource.getStatus() != PublicationStatus.PRIVATE) {
        // begin new paragraph
        Paragraph p = new Paragraph();
        p.setFont(font);

        // construct GBIF link
        p.add(new Phrase(getText("rtf.resourceLink") + " ", fontTitle));
        Anchor gbifLink = new Anchor("GBIF", fontLinkTitle);
        gbifLink.setReference(Constants.GBIF_HOME_PAGE_URL);
        //p.add(gbifLink);
        p.add(": ");

        // attach the IPT Public URL resource link
        URL url = resourceManager.getPublicResourceLink(resource.getShortname());
        String link = (url != null) ? url.toString() : null;
        // the link only gets added, if it isn't null
        if (link != null) {
            Anchor resourceLink = new Anchor(link, fontLink);
            resourceLink.setReference(link);
            p.add(resourceLink);
            p.add(Chunk.NEWLINE);
            doc.add(p);
            p.clear();
        }
    }
}

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

License:Apache License

/**
 * Add Spatial coverage section./*from   www  .  jav  a2s . c om*/
 * 
 * @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.
 * //from   w w  w .j  a v  a2 s.c o m
 * @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.// ww  w  .  j av a  2 s  . 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.gbif.ipt.task.Eml2Rtf.java

License:Apache License

/**
 * Construct RTF document, mainly out of information extracted from Resource's EML object. Currently, the decision
 * has been made to always do this in English.
 * /*from   w ww  .ja  v  a  2  s .c  om*/
 * @param doc Document
 * @param resource Resource
 * @throws DocumentException if problem occurs during add
 */
public void writeEmlIntoRtf(Document doc, Resource resource, String lng) throws DocumentException {
    // initialising resourceBundle.
    Locale loc = new Locale(lng);
    resourceBundle = ResourceBundle.getBundle("ApplicationResources", loc);
    // this.action = action;
    Eml eml = resource.getEml();
    // configure page
    doc.setMargins(72, 72, 72, 72);
    System.out.println(DataDir.CONFIG_DIR);
    // write metadata
    doc.addAuthor(resource.getCreator().getName());
    doc.addCreationDate();
    doc.addTitle((eml.getTitle() == null) ? resource.getShortname() : eml.getTitle());
    // add the keywords to the document
    StringBuilder keys = new StringBuilder();
    for (KeywordSet kw : eml.getKeywords()) {
        if (keys.length() == 0) {
            keys.append(kw.getKeywordsString(", "));
        } else {
            keys.append(", " + kw.getKeywordsString(", "));
        }
    }
    String keysValue = keys.toString();
    doc.addKeywords(keysValue);
    // write proper doc
    doc.open();
    // title
    addPara(doc, eml.getTitle(), fontHeader, 0, Element.ALIGN_CENTER);
    doc.add(Chunk.NEWLINE);
    // Authors, affiliations and corresponging authors
    addAuthors(doc, eml);
    // Other various sections..
    addDates(doc);
    //addCitations(doc);
    // Section called "Resource Citation" above "Abstract"
    addResourceCitation(doc, eml);
    setResAbs(eml);
    setPalKey(keysValue);
    setDisAgr(eml);
    //addAbstract(doc, eml);
    addRes(doc);
    //addKeywords(doc, keysValue);
    addPalcla(doc);
    addAbs(doc);
    addKeyWord(doc);
    addGeneralDescription(doc, eml);
    addProjectData(doc, eml);
    //addResourceLink(doc, resource);
    addTaxonomicCoverages(doc, eml, loc);
    addSpatialCoverage(doc, eml);
    addTemporalCoverages(doc, eml, loc);
    addNaturalCollections(doc, eml);
    addMethods(doc, eml);
    addResul(doc);
    addDatasetDescriptions(doc, resource);
    //addMetadataDescriptions(doc, eml);
    addDiscu(doc);
    addAgrad(doc);
    addReferences(doc, eml);
    doc.close();
}

From source file:org.jivesoftware.openfire.archive.ConversationUtils.java

License:Open Source License

private ByteArrayOutputStream buildPDFContent(Conversation conversation, Map<String, Font> colorMap) {
    Font roomEvent = FontFactory.getFont(FontFactory.HELVETICA, 12f, Font.ITALIC, new Color(0xFF, 0x00, 0xFF));

    try {/*from ww w.  java 2 s . co  m*/
        Document document = new Document(PageSize.A4, 50, 50, 50, 50);
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        PdfWriter writer = PdfWriter.getInstance(document, baos);
        writer.setPageEvent(new PDFEventListener());
        document.open();

        Paragraph p = new Paragraph(
                LocaleUtils.getLocalizedString("archive.search.pdf.title", MonitoringConstants.NAME),
                FontFactory.getFont(FontFactory.HELVETICA, 18, Font.BOLD));
        document.add(p);
        document.add(Chunk.NEWLINE);

        ConversationInfo coninfo = new ConversationUtils().getConversationInfo(conversation.getConversationID(),
                false);

        String participantsDetail;
        if (coninfo.getAllParticipants() == null) {
            participantsDetail = coninfo.getParticipant1() + ", " + coninfo.getParticipant2();
        } else {
            participantsDetail = String.valueOf(coninfo.getAllParticipants().length);
        }

        Paragraph chapterTitle = new Paragraph(
                LocaleUtils.getLocalizedString("archive.search.pdf.participants", MonitoringConstants.NAME)
                        + " " + participantsDetail,
                FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD));

        document.add(chapterTitle);

        Paragraph startDate = new Paragraph(
                LocaleUtils.getLocalizedString("archive.search.pdf.startdate", MonitoringConstants.NAME) + " "
                        + coninfo.getDate(),
                FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD));
        document.add(startDate);

        Paragraph duration = new Paragraph(
                LocaleUtils.getLocalizedString("archive.search.pdf.duration", MonitoringConstants.NAME) + " "
                        + coninfo.getDuration(),
                FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD));
        document.add(duration);

        Paragraph messageCount = new Paragraph(
                LocaleUtils.getLocalizedString("archive.search.pdf.messagecount", MonitoringConstants.NAME)
                        + " " + conversation.getMessageCount(),
                FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD));
        document.add(messageCount);
        document.add(Chunk.NEWLINE);

        Paragraph messageParagraph;

        for (ArchivedMessage message : conversation.getMessages()) {
            String time = JiveGlobals.formatTime(message.getSentDate());
            String from = message.getFromJID().getNode();
            if (conversation.getRoom() != null) {
                from = message.getToJID().getResource();
            }
            String body = message.getBody();
            String prefix;
            if (!message.isRoomEvent()) {
                prefix = "[" + time + "] " + from + ":  ";
                Font font = colorMap.get(message.getFromJID().toString());
                if (font == null) {
                    font = colorMap.get(message.getFromJID().toBareJID());
                }
                if (font == null) {
                    font = FontFactory.getFont(FontFactory.HELVETICA, 12f, Font.BOLD, Color.BLACK);
                }
                messageParagraph = new Paragraph(new Chunk(prefix, font));
            } else {
                prefix = "[" + time + "] ";
                messageParagraph = new Paragraph(new Chunk(prefix, roomEvent));
            }
            messageParagraph.add(body);
            messageParagraph.add(" ");
            document.add(messageParagraph);
        }

        document.close();
        return baos;
    } catch (DocumentException e) {
        Log.error("error creating PDF document: " + e.getMessage(), e);
        return null;
    }
}