Example usage for com.lowagie.text Font BOLD

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

Introduction

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

Prototype

int BOLD

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

Click Source Link

Document

this is a possible style.

Usage

From source file:edu.csudh.goTorosBank.WithdrawServlet.java

public String writeIntoCheck(String filePath, String username, String theAmount, String amountInWords,
        String dateWrote, String person_payingto, String billType) throws IOException, NullPointerException {

    File blueCheck = new File("blank-blue-check.jpg");
    String pathToOriginal = getServletContext().getRealPath("/" + blueCheck);

    File file = new File(pathToOriginal);
    BufferedImage imageToCopy = null;
    try {/*  w  w  w  .  j a v  a 2  s.  c o m*/
        imageToCopy = ImageIO.read(file);
    } catch (IOException e) {
        e.printStackTrace();
    }

    String amount = theAmount;
    String person_gettingPayed = person_payingto;
    String amountinWords = amountInWords;
    String date = dateWrote;
    String bill_type = billType;

    int w = imageToCopy.getWidth();
    int h = imageToCopy.getHeight();
    BufferedImage img = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
    Graphics2D g2d = img.createGraphics();
    g2d.setColor(g2d.getBackground());
    g2d.fillRect(0, 0, w, h);
    g2d.drawImage(imageToCopy, 0, -100, null);
    g2d.setPaint(Color.black);
    g2d.setFont(new java.awt.Font("Serif", Font.BOLD, 36));
    //g2d.setFont(new Font("Serif", Font.BOLD, 36));

    FontMetrics fm = g2d.getFontMetrics();
    int x = img.getWidth() - fm.stringWidth(amount) - 100;
    int y = fm.getHeight();
    g2d.drawString(amount, x - 70, y + 335);
    g2d.drawString(person_gettingPayed, x - 800, y + 329);
    g2d.drawString(amountinWords, x - 940, y + 390);
    g2d.drawString(date, x - 340, y + 245);
    g2d.drawString(bill_type, x - 900, y + 530);

    String signature = "Use The Force";
    g2d.setFont(new java.awt.Font("Monotype Corsiva", Font.BOLD | Font.ITALIC, 36));
    g2d.drawString(signature, x - 340, y + 530);
    g2d.dispose();
    /*write check to file*/
    String filename = fileNameGenerator(username);
    String fullname = filePath + "_" + filename + ".jpg";
    ImageIO.write(img, "jpg", new File(fullname));
    return fullname;
}

From source file:edu.ku.brc.specify.plugins.PartialDateUI.java

License:Open Source License

@Override
public void setParent(final FormViewObj parent) {
    this.parent = parent;

    JLabel lbl = parent.getLabelFor(this);
    if (lbl != null && StringUtils.isNotEmpty(dateFieldName)) {
        DBTableInfo tblInfo = DBTableIdMgr.getInstance().getByClassName(parent.getView().getClassName());
        if (tblInfo != null) {
            final DBFieldInfo fi = tblInfo.getFieldByName(dateFieldName);
            if (fi != null) {
                title = fi.getTitle();// w w w  .  j  ava 2s.c  om
                isRequired = fi.isRequired();
                if (uivs[0] instanceof ValFormattedTextFieldSingle) {
                    ((ValFormattedTextFieldSingle) uivs[0]).setRequired(isRequired);
                } else {
                    for (UIValidatable uiv : uivs) {
                        ((ValFormattedTextField) uiv).setRequired(isRequired);
                    }
                }

                if (StringUtils.isNotEmpty(fi.getTitle())) {
                    lbl.setText(fi.getTitle() + ":");
                    if (isRequired) {
                        lbl.setFont(lbl.getFont().deriveFont(Font.BOLD));
                    }
                }

                if (lbl != null) {
                    lbl.addMouseListener(new MouseAdapter() {
                        @Override
                        public void mouseClicked(MouseEvent e) {
                            super.mouseClicked(e);
                            if (e.getClickCount() == 2) {
                                JOptionPane.showMessageDialog(UIRegistry.getMostRecentWindow(),
                                        "<html>" + fi.getDescription(),
                                        UIRegistry.getResourceString("FormViewObj.UNOTES"),
                                        JOptionPane.INFORMATION_MESSAGE);
                            }
                        }
                    });
                }
            } else {
                log.error("PartialDateUI - Couldn't find date field [" + dateFieldName + "] in data obj View: "
                        + parent.getView().getName());
            }
        }
    }
}

From source file:etc.Exporter.java

License:Open Source License

public static void saveAsPDF(File file, Task task) {
    try {//from   w  ww  .j  a v  a  2  s.  c  o m
        Document document = new Document();
        PdfWriter.getInstance(document, new FileOutputStream(file));

        document.open();
        Paragraph taskid = new Paragraph("ID e Detyres: " + task.getIdentifier(),
                FontFactory.getFont(FontFactory.COURIER, 10, Font.ITALIC));
        document.add(taskid);

        Paragraph creator = new Paragraph("Krijuar nga " + task.getCreator().toString() + "["
                + task.getCreationTime().format(DateTimeFormatter.ofPattern("dd.MM.yyyy - HH.mm")) + "]",
                FontFactory.getFont(FontFactory.COURIER, 10, Font.ITALIC));
        document.add(creator);

        Paragraph executor = new Paragraph("Per zbatim prej: " + task.getExecutor().toString(),
                FontFactory.getFont(FontFactory.COURIER, 10, Font.ITALIC));
        document.add(executor);

        Paragraph title = new Paragraph(task.getTitle().toUpperCase(),
                FontFactory.getFont(FontFactory.COURIER, 14, Font.BOLD));
        document.add(title);

        Paragraph description = new Paragraph(task.getDescription(),
                FontFactory.getFont(FontFactory.COURIER, 12, Font.NORMAL));
        document.add(description);

        PdfPCell cell = new PdfPCell();
        cell.setBorder(Rectangle.BOTTOM);

        PdfPTable table = new PdfPTable(1);
        table.addCell(cell);
        table.setWidthPercentage(100f);
        document.add(table);

        if (task instanceof dc.CompletedTask) {
            document.add(new Paragraph(
                    "Gjendja: Perfunduar [" + ((dc.CompletedTask) task).getCompletitionTime()
                            .format(DateTimeFormatter.ofPattern("dd.MM.yyyy HH.mm")) + "]",
                    FontFactory.getFont(FontFactory.COURIER, 10, Font.ITALIC)));
            document.add(new Paragraph("Shenimet e Zbatuesit".toUpperCase(),
                    FontFactory.getFont(FontFactory.COURIER, 14, Font.BOLD)));
            document.add(new Paragraph(((dc.CompletedTask) task).getAnnotations(),
                    FontFactory.getFont(FontFactory.COURIER, 12, Font.NORMAL)));
        } else if (task instanceof dc.RejectedTask) {
            document.add(new Paragraph(
                    "Gjendja: Refuzuar [" + ((dc.RejectedTask) task).getRejectionTime()
                            .format(DateTimeFormatter.ofPattern("dd.MM.yyyy HH.mm")) + "]",
                    FontFactory.getFont(FontFactory.COURIER, 10, Font.ITALIC)));
            document.add(new Paragraph("Shenimet e Zbatuesit".toUpperCase(),
                    FontFactory.getFont(FontFactory.COURIER, 14, Font.BOLD)));
            document.add(new Paragraph(((dc.RejectedTask) task).getAnnotations(),
                    FontFactory.getFont(FontFactory.COURIER, 12, Font.NORMAL)));
        } else {
            document.add(new Paragraph("Gjendja: Ne Pritje",
                    FontFactory.getFont(FontFactory.COURIER, 10, Font.ITALIC)));
        }

        document.close();

        Process p = Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + file.getAbsolutePath());
        p.waitFor();
    } catch (DocumentException | InterruptedException | IOException ex) {
        Logger.getLogger(Exporter.class.getName()).log(Level.SEVERE, null, ex);
    }
}

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   w w  w  . ja va 2  s. co  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 getRecipientLabel(String label) {
    Chunk recipientsLabel = new Chunk(label, new Font(Font.HELVETICA, 10, Font.BOLD));
    recipientsLabel.setTextRise(15.0f);//  ww w  .  j a  va  2 s.co 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)// w ww.  j  a v  a2s. c  o m
 */
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:fr.opensagres.odfdom.converter.pdf.internal.styles.StyleTextProperties.java

License:Open Source License

public int getStyleFlag() {
    int style = Font.NORMAL;
    if (Boolean.TRUE.equals(fontItalic)) {
        style |= Font.ITALIC;//from w  w  w .  ja va  2  s.  c om
    }
    if (Boolean.TRUE.equals(fontBold)) {
        style |= Font.BOLD;
    }
    if (Boolean.TRUE.equals(fontUnderline)) {
        style |= Font.UNDERLINE;
    }
    if (Boolean.TRUE.equals(fontStrikeThru)) {
        style |= Font.STRIKETHRU;
    }
    return style;
}

From source file:fr.opensagres.odfdom.converter.pdf.internal.styles.StyleTextProperties.java

License:Open Source License

public int getStyleFlagAsian() {
    int style = Font.NORMAL;
    if (Boolean.TRUE.equals(fontItalicAsian)) {
        style |= Font.ITALIC;//from w  ww.j ava 2s  .  c om
    }
    if (Boolean.TRUE.equals(fontBoldAsian)) {
        style |= Font.BOLD;
    }
    if (Boolean.TRUE.equals(fontUnderline)) {
        style |= Font.UNDERLINE;
    }
    if (Boolean.TRUE.equals(fontStrikeThru)) {
        style |= Font.STRIKETHRU;
    }
    return style;
}

From source file:fr.opensagres.odfdom.converter.pdf.internal.styles.StyleTextProperties.java

License:Open Source License

public int getStyleFlagComplex() {
    int style = Font.NORMAL;
    if (Boolean.TRUE.equals(fontItalicComplex)) {
        style |= Font.ITALIC;//from   ww w  . j av a  2 s . c  o  m
    }
    if (Boolean.TRUE.equals(fontBoldComplex)) {
        style |= Font.BOLD;
    }
    if (Boolean.TRUE.equals(fontUnderline)) {
        style |= Font.UNDERLINE;
    }
    if (Boolean.TRUE.equals(fontStrikeThru)) {
        style |= Font.STRIKETHRU;
    }
    return style;
}

From source file:fr.opensagres.poi.xwpf.converter.pdf.internal.FastPdfMapper.java

License:Open Source License

@Override
protected void visitRun(CTR run, CTP paragraph, boolean pageNumber, String url,
        IITextContainer pdfParagraphContainer) throws Exception {
    // Font family
    String fontFamilyAscii = stylesDocument.getFontFamilyAscii(run, paragraph);
    String fontFamilyEastAsia = stylesDocument.getFontFamilyEastAsia(run, paragraph);
    String fontFamilyHAnsi = stylesDocument.getFontFamilyHAnsi(run, paragraph);

    // Get font size
    Float fontSize = stylesDocument.getFontSize(run, paragraph);
    if (fontSize == null) {
        fontSize = -1f;//w  w  w  .  ja  v a2  s  . c o m
    }

    // Get font style
    int fontStyle = Font.NORMAL;
    Boolean bold = stylesDocument.getFontStyleBold(run, paragraph);
    if (bold != null && bold) {
        fontStyle |= Font.BOLD;
    }
    Boolean italic = stylesDocument.getFontStyleItalic(run, paragraph);
    if (italic != null && italic) {
        fontStyle |= Font.ITALIC;
    }
    Boolean strike = stylesDocument.getFontStyleStrike(run, paragraph);
    if (strike != null && strike) {
        fontStyle |= Font.STRIKETHRU;
    }

    // Font color
    Color fontColor = stylesDocument.getFontColor(run, paragraph);

    // Font
    this.currentRunFontAscii = getFont(fontFamilyAscii, fontSize, fontStyle, fontColor);
    this.currentRunFontEastAsia = getFont(fontFamilyEastAsia, fontSize, fontStyle, fontColor);
    this.currentRunFontHAnsi = getFont(fontFamilyHAnsi, fontSize, fontStyle, fontColor);

    // Underline patterns
    this.currentRunUnderlinePatterns = stylesDocument.getUnderline(run, paragraph);

    // background color
    this.currentRunBackgroundColor = stylesDocument.getBackgroundColor(run, paragraph);

    // highlight
    if (currentRunBackgroundColor == null) {
        this.currentRunBackgroundColor = stylesDocument.getTextHighlighting(run, paragraph);
    }

    StylableParagraph pdfParagraph = (StylableParagraph) pdfParagraphContainer;
    pdfParagraph.adjustMultipliedLeading(currentRunFontAscii);

    // addd symbol list item chunk if needed.
    String listItemText = pdfParagraph.getListItemText();
    if (StringUtils.isNotEmpty(listItemText)) {
        // FIXME: add some space after the list item
        listItemText += "    ";

        String listItemFontFamily = pdfParagraph.getListItemFontFamily();
        Float listItemFontSize = pdfParagraph.getListItemFontSize();
        int listItemFontStyle = pdfParagraph.getListItemFontStyle();
        java.awt.Color listItemFontColor = pdfParagraph.getListItemFontColor();
        Font listItemFont = options.getFontProvider().getFont(
                listItemFontFamily != null ? listItemFontFamily : fontFamilyAscii, options.getFontEncoding(),
                listItemFontSize != null ? listItemFontSize : fontSize,
                listItemFontStyle != Font.NORMAL ? listItemFontStyle : fontStyle,
                listItemFontColor != null ? listItemFontColor : Converter.toAwtColor(fontColor));
        Chunk symbol = createTextChunk(listItemText, false, listItemFont, currentRunUnderlinePatterns,
                currentRunBackgroundColor);
        pdfParagraph.add(symbol);
        pdfParagraph.setListItemText(null);
    }

    IITextContainer container = pdfParagraphContainer;
    if (url != null) {
        // URL is not null, generate a PDF hyperlink.
        StylableAnchor pdfAnchor = new StylableAnchor();
        pdfAnchor.setReference(url);
        pdfAnchor.setITextContainer(container);
        container = pdfAnchor;
    }
    super.visitRun(run, paragraph, pageNumber, url, pdfParagraphContainer);

    if (url != null) {
        // URL is not null, add the PDF hyperlink in the PDF paragraph
        pdfParagraphContainer.addElement((StylableAnchor) container);
    }

    this.currentRunFontAscii = null;
    this.currentRunFontEastAsia = null;
    this.currentRunFontHAnsi = null;
    this.currentRunUnderlinePatterns = null;
    this.currentRunBackgroundColor = null;
}