Example usage for com.lowagie.text Font HELVETICA

List of usage examples for com.lowagie.text Font HELVETICA

Introduction

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

Prototype

int HELVETICA

To view the source code for com.lowagie.text Font HELVETICA.

Click Source Link

Document

a possible value of a font family.

Usage

From source file:domain.reports.menu.PDFReportMenu.java

License:LGPL

/**
* Return group header (master)/*from   www.ja v  a2 s.c o  m*/
* @param master Recordset containing master records
* @return
* @throws Throwable
*/
Paragraph getGroupMaster(Recordset master) throws Throwable {

    String text = "Aplicacin: " + master.getString("aplication") + "\n";
    text = text + "Men: " + master.getString("title");

    Paragraph t = new Paragraph(text, new Font(Font.HELVETICA, 12f, Font.BOLD));
    t.setAlignment(Rectangle.ALIGN_LEFT);
    return t;

}

From source file:domain.reports.role.PDFReportRole.java

License:LGPL

/**
* Return group header (master)/*from  w w  w  .  j  a  v a2  s .  co m*/
* @param master Recordset containing master records
* @return
* @throws Throwable
*/
Paragraph getGroupMaster(Recordset master) throws Throwable {

    String text = "Aplicacin: " + master.getString("aplication") + "\n";
    text = text + "Rol: " + master.getString("rolename") + "\n" + "Descripcin: "
            + master.getString("description");

    Paragraph t = new Paragraph(text, new Font(Font.HELVETICA, 12f, Font.BOLD));
    t.setAlignment(Rectangle.ALIGN_LEFT);
    return t;

}

From source file:fr.aliasource.webmail.server.export.ConversationExporter.java

License:GNU General Public License

@SuppressWarnings("unchecked")
private void exportMessage(Set<ClientMessage> cm, Document d, boolean isForward) throws DocumentException {

    LineSeparator hr = new LineSeparator();
    StyleSheet styles = new StyleSheet();
    Font fnormal = new Font(Font.HELVETICA, 9, Font.NORMAL);
    Font fbold = new Font(Font.HELVETICA, 9, Font.BOLD);

    Iterator<ClientMessage> it = cm.iterator();
    Cell c = null;//from  www  . j a v  a2  s  . c  o  m
    while (it.hasNext()) {
        ClientMessage fwdCm = it.next();
        if (isForward) {
            c = new Cell();
        }

        // Subject (only if isForward)
        if (isForward) {
            String subjectText = fwdCm.getSubject();
            String dateText = formatDate(fwdCm.getDate());
            Chunk subject = new Chunk(subjectText, fbold);
            Chunk date = new Chunk(dateText, fbold);
            Paragraph subjectPar = new Paragraph(subject + ", " + date);
            subjectPar.setIndentationLeft(5.0f);
            c.add(subjectPar);
            c.add(Chunk.NEWLINE);
        } else {
            String dateText = formatDate(fwdCm.getDate());
            Chunk date = new Chunk(dateText, fbold);
            Paragraph datePar = new Paragraph(date);
            datePar.setAlignment(Element.ALIGN_RIGHT);
            d.add(datePar);
        }

        // Sender
        String senderText = formatAddress(fwdCm.getSender());
        Chunk sender = new Chunk(senderText, fbold);
        sender.setTextRise(10.0f);
        Paragraph senderPar = new Paragraph(sender);
        if (isForward) {
            senderPar.setIndentationLeft(5.0f);
            c.add(senderPar);
        } else {
            d.add(senderPar);
        }

        appendRecipients(d, c, isForward, "To:", fwdCm.getTo());
        appendRecipients(d, c, isForward, "Cc:", fwdCm.getCc());
        appendRecipients(d, c, isForward, "Bcc:", fwdCm.getBcc());
        if (isForward) {
            c.add(Chunk.NEWLINE);
        }

        // Body
        String bodyText = fwdCm.getBody().getCleanHtml();
        Paragraph bodyPar = new Paragraph();
        bodyPar.setFont(fnormal);
        if (bodyText != null && !bodyText.isEmpty()) {
            try {
                List<Element> objects = HTMLWorker.parseToList(new StringReader(bodyText), styles);
                for (Iterator<Element> iterator = objects.iterator(); iterator.hasNext();) {
                    Element el = iterator.next();
                    if (!(el instanceof Image)) {
                        // bodyPar.add(el);
                        if (isForward) {
                            c.add(el);
                        } else {
                            bodyPar.add(el);
                        }
                    }
                }
            } catch (Exception e) {
                logger.warn("Cannot generate pdf from html body use plain text instead", e);
                // bodyPar.add(fwdCm.getBody().getPlain());
                if (isForward) {
                    Chunk t = new Chunk(fwdCm.getBody().getPlain());
                    t.setFont(fnormal);
                    c.add(t);
                } else {
                    bodyPar.add(fwdCm.getBody().getPlain());
                }
            }
        } else {
            if (isForward) {
                Chunk t = new Chunk(fwdCm.getBody().getPlain());
                t.setFont(fnormal);
                c.add(t);
            } else {
                bodyPar.add(fwdCm.getBody().getPlain());
            }
        }

        if (isForward) {
            // c.add(bodyPar);
            Table t = new Table(1);
            t.setPadding(5);
            t.setBackgroundColor(new Color(242, 242, 242));
            t.addCell(c);
            d.add(t);
        } else {
            bodyPar.setIndentationLeft(15.0f);
            d.add(bodyPar);
        }

        if (fwdCm.getFwdMessages() != null) {
            this.exportMessage(fwdCm.getFwdMessages(), d, true);
        }
        d.add(hr);
    }

}

From source file:fr.aliasource.webmail.server.export.ConversationExporter.java

License:GNU General Public License

private Chunk getRecipientValue(List<EmailAddress> recipients) {
    Chunk recipientsChunk = null;/*from  w  w  w.  ja v a 2  s .  c o  m*/
    if (recipients != null && !recipients.isEmpty()) {
        StringBuilder recipientsText = new StringBuilder(200);
        formatRecipients(recipientsText, recipients, false);
        recipientsChunk = new Chunk(recipientsText.toString(), new Font(Font.HELVETICA, 9));
        recipientsChunk.setTextRise(15.0f);
    }
    return recipientsChunk;
}

From source file:fr.aliasource.webmail.server.export.ConversationExporter.java

License:GNU General Public License

private Chunk getRecipientLabel(String label) {
    Chunk recipientsLabel = new Chunk(label, new Font(Font.HELVETICA, 10, Font.BOLD));
    recipientsLabel.setTextRise(15.0f);//w ww . j a  v a 2 s  .c o m
    return recipientsLabel;
}

From source file:fr.aliasource.webmail.server.export.ConversationPdfEventHandler.java

License:GNU General Public License

/**
 * @see com.lowagie.text.pdf.PdfPageEventHelper#onOpenDocument(com.lowagie.text.pdf.PdfWriter,
 *      com.lowagie.text.Document)//from   ww w  .j  a v a 2s. com
 */
public void onOpenDocument(PdfWriter writer, Document document) {
    try {
        headerImage = Image.getInstance(getLogoUrl());
        table = new PdfPTable(new float[] { 1f, 2f });
        Phrase p = new Phrase();
        Chunk ck = new Chunk(cr.getTitle(), new Font(Font.HELVETICA, 16, Font.BOLD));
        p.add(ck);
        p.add(Chunk.NEWLINE);
        ck = new Chunk(ConversationExporter.formatName(account), new Font(Font.HELVETICA, 12, Font.BOLDITALIC));
        p.add(ck);
        p.add(Chunk.NEWLINE);
        ck = new Chunk(cm.length + " messages", new Font(Font.HELVETICA, 10));
        p.add(ck);
        table.getDefaultCell().setBorder(0);
        table.addCell(new Phrase(new Chunk(headerImage, 0, 0)));
        table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);
        table.addCell(p);
        // initialization of the template
        tpl = writer.getDirectContent().createTemplate(100, 100);
        tpl.setBoundingBox(new Rectangle(-20, -20, 100, 100));
        // initialization of the font
        helv = BaseFont.createFont("Helvetica", BaseFont.WINANSI, false);
    } catch (Exception e) {
        throw new ExceptionConverter(e);
    }
}

From source file:is.idega.idegaweb.egov.cases.business.CaseWriter.java

License:Open Source License

protected MemoryFileBuffer writePDF(IWContext iwc) {
    Font titleFont = new Font(Font.HELVETICA, 14, Font.BOLD);
    Font labelFont = new Font(Font.HELVETICA, 11, Font.BOLD);
    Font textFont = new Font(Font.HELVETICA, 11, Font.NORMAL);

    try {/* w  w w .ja  va2  s .com*/
        MemoryFileBuffer buffer = new MemoryFileBuffer();
        MemoryOutputStream mos = new MemoryOutputStream(buffer);

        Document document = new Document(PageSize.A4, 50, 50, 50, 50);
        PdfWriter.getInstance(document, mos);
        document.addAuthor("Idegaweb eGov");
        document.addSubject("Case");
        document.open();
        document.newPage();

        String title = iwrb.getLocalizedString("case_overview", "Case overview");
        Paragraph cTitle = new Paragraph(title, titleFont);
        cTitle.setSpacingAfter(24);
        document.setPageCount(1);
        document.add(cTitle);

        int[] widths = { 25, 75 };
        PdfPTable table = new PdfPTable(2);
        table.setWidths(widths);
        table.getDefaultCell().setBorder(0);
        table.getDefaultCell().setPaddingBottom(8);

        CaseCategory category = theCase.getCaseCategory();
        CaseCategory parentCategory = category.getParent();
        CaseType type = theCase.getCaseType();
        User user = theCase.getOwner();
        Address address = user != null ? getUserBusiness(iwc).getUsersMainAddress(user) : null;
        PostalCode postal = null;
        if (address != null) {
            postal = address.getPostalCode();
        }
        Phone phone = null;
        if (user != null) {
            try {
                phone = getUserBusiness(iwc).getUsersHomePhone(user);
            } catch (NoPhoneFoundException e) {
                //No phone found...
            }
        }
        Email email = null;
        if (user != null) {
            try {
                email = getUserBusiness(iwc).getUsersMainEmail(user);
            } catch (NoEmailFoundException e) {
                //No email found...
            }
        }

        IWTimestamp created = new IWTimestamp(theCase.getCreated());

        if (user != null) {
            table.addCell(new Phrase(iwrb.getLocalizedString("name", "Name"), labelFont));
            table.addCell(new Phrase(
                    new Name(user.getFirstName(), user.getMiddleName(), user.getLastName()).getName(locale),
                    textFont));

            table.addCell(new Phrase(iwrb.getLocalizedString("personal_id", "Personal ID"), labelFont));
            table.addCell(new Phrase(PersonalIDFormatter.format(user.getPersonalID(), locale), textFont));

            table.addCell(new Phrase(iwrb.getLocalizedString("address", "Address"), labelFont));
            table.addCell(new Phrase(address != null ? address.getStreetAddress() : "-", textFont));

            table.addCell(new Phrase(iwrb.getLocalizedString("zip_code", "Postal code"), labelFont));
            table.addCell(new Phrase(postal != null ? postal.getPostalAddress() : "-", textFont));

            table.addCell(new Phrase(iwrb.getLocalizedString("home_phone", "Home phone"), labelFont));
            table.addCell(new Phrase(phone != null ? phone.getNumber() : "-", textFont));

            table.addCell(new Phrase(iwrb.getLocalizedString("email", "Email"), labelFont));
            table.addCell(new Phrase(email != null ? email.getEmailAddress() : "-", textFont));

            table.addCell(new Phrase(""));
            table.addCell(new Phrase(""));
            table.addCell(new Phrase(""));
            table.addCell(new Phrase(""));
        }

        table.addCell(new Phrase(iwrb.getLocalizedString("case_nr", "Case nr."), labelFont));
        table.addCell(new Phrase(theCase.getPrimaryKey().toString(), textFont));

        if (getCasesBusiness(iwc).useTypes()) {
            table.addCell(new Phrase(iwrb.getLocalizedString("case_type", "Case type"), labelFont));
            table.addCell(new Phrase(type.getName(), textFont));
        }

        if (parentCategory != null) {
            table.addCell(new Phrase(iwrb.getLocalizedString("case_category", "Case category"), labelFont));
            table.addCell(new Phrase(parentCategory.getLocalizedCategoryName(locale), textFont));

            table.addCell(new Phrase(iwrb.getLocalizedString("sub_case_category", "Case category"), labelFont));
            table.addCell(new Phrase(category.getLocalizedCategoryName(locale), textFont));
        } else {
            table.addCell(new Phrase(iwrb.getLocalizedString("case_category", "Case category"), labelFont));
            table.addCell(new Phrase(category.getLocalizedCategoryName(locale), textFont));
        }

        table.addCell(new Phrase(iwrb.getLocalizedString("created_date", "Created date"), labelFont));
        table.addCell(new Phrase(created.getLocaleDateAndTime(locale, IWTimestamp.SHORT, IWTimestamp.SHORT),
                textFont));

        if (theCase.getSubject() != null) {
            table.addCell(new Phrase(iwrb.getLocalizedString("subject", "Subject"), labelFont));
            table.addCell(new Phrase(theCase.getSubject(), textFont));
        }

        table.addCell(new Phrase(iwrb.getLocalizedString("message", "Message"), labelFont));
        table.addCell(new Phrase(theCase.getMessage(), textFont));

        if (theCase.getReference() != null) {
            table.addCell(new Phrase(iwrb.getLocalizedString("reference", "Reference"), labelFont));
            table.addCell(new Phrase(theCase.getReference(), textFont));
        }

        table.setWidthPercentage(100);
        document.add(table);

        document.close();
        try {
            mos.close();
        } catch (Exception ex) {
            ex.printStackTrace();
        }

        buffer.setMimeType("application/pdf");
        return buffer;

    } catch (Exception ex) {
        ex.printStackTrace();
    }

    return null;
}

From source file:is.idega.idegaweb.egov.printing.business.DocumentBusinessBean.java

License:Open Source License

/**
 * Method getDefaultTextFont.//from w w w.  j av a 2 s . c  o  m
 * 
 * @return Font
 */
private Font getDefaultTextFont() {
    if (defaultTextFont == null) {
        defaultTextFont = new Font(Font.HELVETICA);
        defaultTextFont.setSize(12);
    }
    return defaultTextFont;
}

From source file:is.idega.idegaweb.egov.printing.business.DocumentBusinessBean.java

License:Open Source License

private Font getDefaultAddressTextFont() {
    if (defaultAddressTextFont == null) {
        defaultAddressTextFont = new Font(Font.HELVETICA);
        defaultAddressTextFont.setSize(12);
    }//from  w ww  . ja v  a2s. c  om
    return defaultAddressTextFont;
}

From source file:is.idega.idegaweb.egov.printing.business.DocumentBusinessBean.java

License:Open Source License

/**
 * Method getDefaultParagraphFont./*from w w w .  java  2 s.  c om*/
 * 
 * @return Font
 */
private Font getDefaultParagraphFont() {
    if (defaultParagraphFont == null) {
        defaultParagraphFont = new Font(Font.HELVETICA, 12, Font.BOLD);
    }
    return defaultParagraphFont;
}