Example usage for com.lowagie.text FontFactory COURIER

List of usage examples for com.lowagie.text FontFactory COURIER

Introduction

In this page you can find the example usage for com.lowagie.text FontFactory COURIER.

Prototype

String COURIER

To view the source code for com.lowagie.text FontFactory COURIER.

Click Source Link

Document

This is a possible value of a base 14 type 1 font

Usage

From source file:org.sonarqube.report.extendedpdf.OverviewPDFReporter.java

License:Open Source License

protected void printFrontPage(Document frontPageDocument, PdfWriter frontPageWriter)
        throws org.dom4j.DocumentException, ReportException {
    String frontPageTemplate = "/templates/frontpage.pdf";
    try {//w  w w. j a va2s  .  c  o  m
        PdfContentByte cb = frontPageWriter.getDirectContent();
        PdfReader reader = new PdfReader(this.getClass().getResourceAsStream(frontPageTemplate));
        PdfImportedPage page = frontPageWriter.getImportedPage(reader, 1);
        frontPageDocument.newPage();
        cb.addTemplate(page, 0, 0);

        Project project = getProject();

        Rectangle pageSize = frontPageDocument.getPageSize();
        PdfPTable projectInfo = new PdfPTable(1);
        projectInfo.getDefaultCell().setVerticalAlignment(PdfCell.ALIGN_MIDDLE);
        projectInfo.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT);
        projectInfo.getDefaultCell().setBorder(Rectangle.BOTTOM);
        projectInfo.getDefaultCell().setPaddingBottom(10);
        projectInfo.getDefaultCell().setBorderColor(Color.GRAY);
        Font font = FontFactory.getFont(FontFactory.COURIER, 18, Font.NORMAL, Color.LIGHT_GRAY);

        Phrase projectName = new Phrase("Project: " + project.getName(), font);
        projectInfo.addCell(projectName);

        Phrase projectVersion = new Phrase("Version: " + project.getMeasures().getVersion(), font);
        projectInfo.addCell(projectVersion);

        SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy hh:mm");
        Phrase projectAnalysisDate = new Phrase("Analysis Date: " + df.format(project.getMeasures().getDate()),
                font);
        projectInfo.addCell(projectAnalysisDate);

        projectInfo.setTotalWidth(
                pageSize.getWidth() - frontPageDocument.leftMargin() * 2 - frontPageDocument.rightMargin() * 2);
        projectInfo.writeSelectedRows(0, -1, frontPageDocument.leftMargin(), pageSize.getHeight() - 575,
                frontPageWriter.getDirectContent());
        projectInfo.setSpacingAfter(10);
    } catch (IOException e) {
        Logger.error("Cannot find the required template: " + frontPageTemplate);
        e.printStackTrace();
    }
}

From source file:org.unitime.timetable.util.PdfFont.java

License:Open Source License

private static Font createFont(float size, boolean fixed, boolean bold, boolean italic) {
    String font = null;//from   w  w w .ja  va  2  s .  c o m
    if (fixed)
        font = ApplicationProperty.PdfFontFixed.value();
    else if (bold) {
        if (italic)
            font = ApplicationProperty.PdfFontBoldItalic.value();
        else
            font = ApplicationProperty.PdfFontBold.value();
    } else if (italic)
        font = ApplicationProperty.PdfFontItalic.value();
    else
        font = ApplicationProperty.PdfFontNormal.value();
    if (font != null && !font.isEmpty()) {
        try {
            BaseFont base = BaseFont.createFont(font, BaseFont.IDENTITY_H, true);
            if (base != null)
                return new Font(base, size);
        } catch (Throwable t) {
        }
    }
    font = (fixed ? ApplicationProperty.PdfFontFixed.value() : ApplicationProperty.PdfFontNormal.value());
    if (font != null && !font.isEmpty()) {
        try {
            BaseFont base = BaseFont.createFont(font, BaseFont.IDENTITY_H, true);
            if (base != null)
                return new Font(base, size, italic && bold ? Font.BOLDITALIC
                        : italic ? Font.ITALIC : bold ? Font.BOLD : Font.NORMAL);
        } catch (Throwable t) {
        }
    }
    if (fixed)
        return FontFactory.getFont(bold ? italic ? FontFactory.COURIER_BOLDOBLIQUE : FontFactory.COURIER_BOLD
                : italic ? FontFactory.COURIER_OBLIQUE : FontFactory.COURIER, size);
    else
        return FontFactory
                .getFont(bold ? italic ? FontFactory.HELVETICA_BOLDOBLIQUE : FontFactory.HELVETICA_BOLD
                        : italic ? FontFactory.HELVETICA_OBLIQUE : FontFactory.HELVETICA, size);
}

From source file:webBoltOns.server.servletUtil.Text2PDF.java

License:Mozilla Public License

public static void convert2PDFfile(String inputTextFile, String outputPDFfile) throws Exception {
    BufferedReader r = new BufferedReader(new FileReader(inputTextFile));
    Document document = new Document(PageSize.A4.rotate());
    PdfWriter.getInstance(document, new FileOutputStream(outputPDFfile));
    document.open();/*from w  w w  .  ja va  2s .  c  o m*/

    Font courier10pt = FontFactory.getFont(FontFactory.COURIER, 10);
    String str;
    while ((str = r.readLine()) != null) {
        document.add(new Paragraph(str.equals("") ? " " : str, courier10pt));
    }

    document.close();
    r.close();
}