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:com.aripd.clms.service.ContractServiceBean.java

@Override
public void generatePdf(ContractEntity contract) {
    String baseFontUrl = "/fonts/Quivira.otf";
    FontFactory.register(baseFontUrl);//from w ww.  j a  v  a2  s .c  o m

    ByteArrayOutputStream output = new ByteArrayOutputStream();
    try {
        BaseFont bf = BaseFont.createFont(baseFontUrl, BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
        Font font18n = new Font(bf, 18, Font.NORMAL);
        Font font12n = new Font(bf, 12, Font.NORMAL);
        Font font8n = new Font(bf, 8, Font.NORMAL);
        Font font8nbu = new Font(bf, 8, Font.BOLD | Font.UNDERLINE);
        Font font8ng = new Font(bf, 8, Font.NORMAL, Color.DARK_GRAY);
        Font font6n = new Font(bf, 6, Font.NORMAL);

        Document document = new Document(PageSize.A4);
        PdfWriter writer = PdfWriter.getInstance(document, output);
        document.open();
        addMetaData(document);
        addTitlePage(document, contract);
        Image imgBlue = Image.getInstance(1, 1, 3, 8, new byte[] { (byte) 0, (byte) 0, (byte) 255, });
        imgBlue.scaleAbsolute(document.getPageSize().getWidth(), 10);
        imgBlue.setAbsolutePosition(0, document.getPageSize().getHeight() - imgBlue.getScaledHeight());
        PdfImage stream = new PdfImage(imgBlue, "", null);
        stream.put(new PdfName("ITXT_SpecialId"), new PdfName("123456789"));
        PdfIndirectObject ref = writer.addToBody(stream);
        imgBlue.setDirectReference(ref.getIndirectReference());
        document.add(imgBlue);

        PdfPTable table = new PdfPTable(2);
        table.setWidthPercentage(100);

        PdfPCell cell = new PdfPCell(new Paragraph(contract.getName(), font18n));
        cell.setBorder(Rectangle.NO_BORDER);
        cell.setColspan(2);
        cell.setPadding(5);
        table.addCell(cell);
        cell = new PdfPCell(new Paragraph("Version: " + contract.getVersion(), font8n));
        cell.setBorder(Rectangle.NO_BORDER);
        cell.setColspan(2);
        cell.setPadding(5);
        table.addCell(cell);
        cell = new PdfPCell(new Paragraph("Review: " + contract.getReview(), font8n));
        cell.setBorder(Rectangle.NO_BORDER);
        cell.setColspan(2);
        cell.setPadding(5);
        table.addCell(cell);
        cell = new PdfPCell(new Paragraph(contract.getRemark(), font12n));
        cell.setBorder(Rectangle.NO_BORDER);
        cell.setColspan(2);
        cell.setPadding(5);
        table.addCell(cell);
        document.add(table);
        // Start a new page
        document.newPage();

        HTMLWorker htmlWorker = new HTMLWorker(document);
        htmlWorker.parse(new StringReader(contract.getRemark()));
        // Start a new page
        document.newPage();

        document.add(new Paragraph("Review Board", font18n));
        document.add(new LineSeparator(0.5f, 100, null, 0, -5));

        table = new PdfPTable(3);
        table.setWidthPercentage(100);

        cell = new PdfPCell(new Paragraph("Review Board", font18n));
        cell.setColspan(3);
        table.addCell(cell);
        cell = new PdfPCell(new Paragraph("Version", font12n));
        table.addCell(cell);
        cell = new PdfPCell(new Paragraph("Date", font12n));
        table.addCell(cell);
        cell = new PdfPCell(new Paragraph("Review", font12n));
        table.addCell(cell);
        for (HistoryContractEntity history : historyContractService.listing(contract)) {
            cell = new PdfPCell(new Paragraph(history.getVersion().toString(), font8n));
            table.addCell(cell);
            cell = new PdfPCell(new Paragraph(history.getStartdate().toString(), font8n));
            table.addCell(cell);
            cell = new PdfPCell(new Paragraph(history.getReview(), font8n));
            table.addCell(cell);
        }
        document.add(table);

        document.close();

        FacesContext context = FacesContext.getCurrentInstance();
        HttpServletResponse response = (HttpServletResponse) context.getExternalContext().getResponse();
        response.reset();
        response.addHeader("Content-Type", "application/force-download");
        String filename = URLEncoder.encode(contract.getName() + ".pdf", "UTF-8");
        //            response.addHeader("Content-Disposition", "attachment; filename=\"" + filename + "\"");
        response.setHeader("Content-Disposition", "attachment; filename*=UTF-8''" + filename);
        response.getOutputStream().write(output.toByteArray());
        response.getOutputStream().flush();
        context.responseComplete();
        context.renderResponse();

    } catch (BadPdfFormatException | IOException ex) {
        Logger.getLogger(ContractServiceBean.class.getName()).log(Level.SEVERE, null, ex);
    } catch (DocumentException ex) {
        Logger.getLogger(ContractServiceBean.class.getName()).log(Level.SEVERE, null, ex);
    }

}

From source file:com.aryjr.nheengatu.util.TagsManager.java

License:Open Source License

public void doB() {
    ((GraphicsState) states.get(states.size() - 1)).getFont().setStyle(Font.BOLD);
}

From source file:com.aryjr.nheengatu.util.TagsManager.java

License:Open Source License

public void doH1() {
    ((GraphicsState) states.get(states.size() - 1)).getFont().setSize(16);
    ((GraphicsState) states.get(states.size() - 1)).getFont().setStyle(Font.BOLD);
    ((GraphicsState) states.get(states.size() - 1)).setSpacingBefore(8f);
    ((GraphicsState) states.get(states.size() - 1)).setSpacingAfter(8f);
}

From source file:com.aryjr.nheengatu.util.TagsManager.java

License:Open Source License

public void doH2() {
    ((GraphicsState) states.get(states.size() - 1)).getFont().setSize(14);
    ((GraphicsState) states.get(states.size() - 1)).getFont().setStyle(Font.BOLD);
    ((GraphicsState) states.get(states.size() - 1)).setSpacingBefore(7f);
    ((GraphicsState) states.get(states.size() - 1)).setSpacingAfter(7f);
}

From source file:com.aryjr.nheengatu.util.TagsManager.java

License:Open Source License

public void doH3() {
    ((GraphicsState) states.get(states.size() - 1)).getFont().setSize(12);
    ((GraphicsState) states.get(states.size() - 1)).getFont().setStyle(Font.BOLD);
    ((GraphicsState) states.get(states.size() - 1)).setSpacingBefore(6f);
    ((GraphicsState) states.get(states.size() - 1)).setSpacingAfter(6f);
}

From source file:com.aryjr.nheengatu.util.TagsManager.java

License:Open Source License

public void doH5() {
    ((GraphicsState) states.get(states.size() - 1)).getFont().setSize(11);
    ((GraphicsState) states.get(states.size() - 1)).getFont().setStyle(Font.BOLD);
}

From source file:com.aryjr.nheengatu.util.TagsManager.java

License:Open Source License

public void doH6() {
    ((GraphicsState) states.get(states.size() - 1)).getFont().setSize(11);
    ((GraphicsState) states.get(states.size() - 1)).getFont().setStyle(Font.BOLD);
}

From source file:com.bcpv.webapp.displaytag.decorators.ItextTotalWrapper.java

License:Artistic License

/**
 * Writes a total line./*w w w.  j  a v  a  2s.  c  om*/
 * @param value Total message.
 * @param total Total number.
 */
private void writeTotal(String value, double total) {
    if (assertRequiredState()) {
        try {
            this.font = FontFactory.getFont(this.font.getFamilyname(), this.font.size(), Font.BOLD,
                    this.font.color());
            table.addCell(this.getCell(""));
            table.addCell(this.getCell(""));
            table.addCell(this.getCell("-------------"));
            table.addCell(this.getCell(""));
            // new row
            table.addCell(this.getCell(""));
            table.addCell(this.getCell(value + " Total:"));
            table.addCell(this.getCell(total + ""));
            table.addCell(this.getCell(""));
        } catch (BadElementException e) {
        }
    }
}

From source file:com.bibisco.export.ITextExporter.java

License:GNU General Public License

@Override
public void startChapter(String pStrChapterTitle) {

    Font lFont = new Font();
    lFont.setFamily(mFont.getFamilyname());
    lFont.setSize(mFont.getSize());//w  ww .  java2s  .co m
    lFont.setStyle(Font.BOLD);

    Anchor anchor = new Anchor(pStrChapterTitle, lFont);
    anchor.setName(pStrChapterTitle);

    mChapter = new Chapter(new Paragraph(anchor), ++mIntChapterPosition);
    addEmptyLines(1);
}

From source file:com.bibisco.export.ITextExporter.java

License:GNU General Public License

@Override
public void addText(String pStrText, TextFormatting pTextFormatting) {

    mLog.debug("Start addText(): " + pStrText);

    Font lFont = new Font();
    lFont.setFamily(mFont.getFamilyname());
    lFont.setSize(mFont.getSize());//w  w w.ja v a  2  s .  c om

    int lIntStyle = 0;
    if (pTextFormatting.bold) {
        lIntStyle = lIntStyle | Font.BOLD;
    }
    if (pTextFormatting.italic) {
        lIntStyle = lIntStyle | Font.ITALIC;
    }
    if (pTextFormatting.underline) {
        lIntStyle = lIntStyle | Font.UNDERLINE;
    }
    if (pTextFormatting.strike) {
        lIntStyle = lIntStyle | Font.STRIKETHRU;
    }
    lFont.setStyle(lIntStyle);

    Chunk lChunk = new Chunk(pStrText, lFont);

    if (mListItem != null) {
        mListItem.add(lChunk);
    } else if (mParagraph != null) {
        mParagraph.add(lChunk);
    }

    mLog.debug("End addText()");
}