Example usage for com.lowagie.text Paragraph add

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

Introduction

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

Prototype

public boolean add(Object o) 

Source Link

Document

Adds an Object to the Paragraph.

Usage

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);//from  w w w  .ja  va 2 s .  c o  m
}

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

License:Open Source License

private void addLineSeparator(Paragraph p, int number) {
    LineSeparator sep = new LineSeparator();
    sep.setOffset(-5F);/*from  w ww  .j a  v  a 2 s .  com*/
    for (int i = 0; i < number; i++)
        p.add(sep);
}

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

License:Open Source License

private void addEmptyLine(Paragraph p, int number) {
    for (int i = 0; i < number; i++) {
        p.add(new Paragraph(" "));
    }//from  w  w  w  . j av  a2  s  .  c  om
}

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

License:Open Source License

private void addNewLine(Paragraph p, int number) {
    for (int i = 0; i < number; i++)
        p.add("\n");
}

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

License:Open Source License

private void addTitleOne(Document d, String text) throws DocumentException {

    Font titleFont = new Font(Font.TIMES_ROMAN, 24, Font.BOLD);

    Paragraph p = new Paragraph();
    this.addEmptyLine(p, 1);
    p.add(new Paragraph(text, titleFont));
    this.addEmptyLine(p, 1);
    d.add(p);/* w  ww .j a v a  2  s . c  om*/
}

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

License:Open Source License

private void addTitleTwo(Document d, String text) throws DocumentException {

    Font subtitleFont = new Font(Font.TIMES_ROMAN, 16, Font.BOLD);

    Paragraph p = new Paragraph();
    this.addEmptyLine(p, 1);
    p.add(new Paragraph(text, subtitleFont));
    this.addEmptyLine(p, 1);
    d.add(p);/*from  w  w  w  .j a v  a  2 s .  co  m*/
}

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

License:Open Source License

private void addTitleTwo(Document d, String text, boolean underline) throws DocumentException {

    Font subtitleFont = new Font(Font.TIMES_ROMAN, 16, Font.BOLD);

    Paragraph p = new Paragraph();
    this.addEmptyLine(p, 1);
    p.add(new Paragraph(text, subtitleFont));

    if (underline)
        this.addLineSeparator(p, 1);

    this.addEmptyLine(p, 1);
    d.add(p);/*from w  ww . jav  a 2  s.com*/
}

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

License:Open Source License

private void addTitleThree(Document d, String text) throws DocumentException {
    Font layerNameFont = new Font(Font.TIMES_ROMAN, 14, Font.BOLD);
    Paragraph p = new Paragraph();
    this.addEmptyLine(p, 1);
    p.add(new Paragraph(text, layerNameFont));
    this.addLineSeparator(d, 1);
    d.add(p);/*from   w  w  w  . j  a  v a2s  . co 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   www.  j  a  v a2  s. co  m
    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.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 {//www .  ja  va 2s.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;
    }
}