Example usage for com.itextpdf.text.pdf BaseFont EMBEDDED

List of usage examples for com.itextpdf.text.pdf BaseFont EMBEDDED

Introduction

In this page you can find the example usage for com.itextpdf.text.pdf BaseFont EMBEDDED.

Prototype

boolean EMBEDDED

To view the source code for com.itextpdf.text.pdf BaseFont EMBEDDED.

Click Source Link

Document

if the font has to be embedded

Usage

From source file:bouttime.report.bracketsheet.BracketSheetUtil.java

License:Open Source License

public static void drawString(PdfContentByte cb, BaseFont bf, float mid, float y, float fontSize, String string,
        float rotation) throws DocumentException, IOException {

    if (bf == null) {
        bf = BaseFont.createFont(BaseFont.TIMES_ROMAN, BaseFont.CP1252, BaseFont.EMBEDDED);
    }//from  w  w w . ja v a  2  s .  co  m

    cb.setFontAndSize(bf, fontSize);

    cb.beginText();
    cb.showTextAligned(PdfContentByte.ALIGN_LEFT, string, mid, y, rotation);
    cb.endText();
    cb.stroke();
}

From source file:bouttime.report.bracketsheet.BracketSheetUtil.java

License:Open Source License

public static void drawString(PdfContentByte cb, BaseFont bf, float mid, float y, float fontSize, String string,
        float rotation, boolean strikethrough) throws DocumentException, IOException {

    if (bf == null) {
        bf = BaseFont.createFont(BaseFont.TIMES_ROMAN, BaseFont.CP1252, BaseFont.EMBEDDED);
    }//www.j ava2  s.co  m

    drawString(cb, bf, mid, y, fontSize, string, rotation);
    if (strikethrough) {
        float halfHeight = (bf.getAscentPoint(string, fontSize)) / 2;
        float width = bf.getWidthPointKerned(string, fontSize);
        if (rotation == 0) {
            drawHorizontalLine(cb, mid, y + halfHeight, width, 1.5f, 0);
        } else if (rotation == 90) {
            drawVerticalLine(cb, mid - halfHeight, y, width, 1.5f, 0);
        }
    }
}

From source file:bouttime.report.bracketsheet.BracketSheetUtil.java

License:Open Source License

public static void drawStringAligned(PdfContentByte cb, BaseFont bf, int alignment, float mid, float y,
        float fontSize, String string, float rotation) throws DocumentException, IOException {

    if (bf == null) {
        bf = BaseFont.createFont(BaseFont.TIMES_ROMAN, BaseFont.CP1252, BaseFont.EMBEDDED);
    }//from  w w  w.  j  a v a  2  s.co m

    cb.setFontAndSize(bf, fontSize);

    cb.beginText();
    cb.showTextAligned(alignment, string, mid, y, rotation);
    cb.endText();
    cb.stroke();
}

From source file:bouttime.report.bracketsheet.BracketSheetUtil.java

License:Open Source License

public static void drawStringCentered(PdfContentByte cb, BaseFont bf, float mid, float y, float fontSize,
        String string, float rotation) throws DocumentException, IOException {

    if (bf == null) {
        bf = BaseFont.createFont(BaseFont.TIMES_ROMAN, BaseFont.CP1252, BaseFont.EMBEDDED);
    }//from w  w w  .ja v a2  s .  c  om

    cb.setFontAndSize(bf, fontSize);

    cb.beginText();
    cb.showTextAligned(PdfContentByte.ALIGN_CENTER, (string != null) ? string : "", mid, y, rotation);
    cb.endText();
    cb.stroke();
}

From source file:bouttime.report.bracketsheet.BracketSheetUtil.java

License:Open Source License

public static void drawTournamentHeader(PdfContentByte cb, BaseFont bf, float x, float y, Dao dao,
        float rotation) throws DocumentException, IOException {

    if (bf == null) {
        bf = BaseFont.createFont(BaseFont.TIMES_ROMAN, BaseFont.CP1252, BaseFont.EMBEDDED);
    }//from   w w w . j  av  a  2 s. co m

    float linePad = 15;

    String name = dao.getName();
    if (name != null) {
        drawString(cb, bf, x, y, 12, name, rotation);
        if (rotation == 0) {
            y -= linePad;
        } else {
            x += linePad;
        }
    }

    String site = dao.getSite();
    if (site != null) {
        drawString(cb, bf, x, y, 12, site, rotation);
        if (rotation == 0) {
            y -= linePad;
        } else {
            x += linePad;
        }
    }

    String city = dao.getCity();
    String state = dao.getState();
    if ((city != null) || (state != null)) {
        String cityState = "";
        if (city != null) {
            cityState = city;
            if (state != null) {
                cityState += ", ";
            }
        }
        if (state != null) {
            cityState += state;
        }

        drawString(cb, bf, x, y, 12, cityState, rotation);
        if (rotation == 0) {
            y -= linePad;
        } else {
            x += linePad;
        }
    }

    String month = dao.getMonth();
    Integer day = dao.getDay();
    Integer year = dao.getYear();
    if ((month != null) || (year != null)) {
        String date = "";
        if (month != null) {
            date = month;
            if (day != null) {
                date += " " + day;
            }

            if (year != null) {
                date += ", ";
            }
        }

        if (year != null) {
            date += year;
        }

        drawString(cb, bf, x, y, 12, date, rotation);
    }
}

From source file:bouttime.report.bracketsheet.BracketSheetUtil.java

License:Open Source License

public static void drawBoutLabel(PdfContentByte cb, BaseFont bf, float x, float y, float r, float topPad,
        float botPad, int fontsize, float lineWidth, float grayStroke, String boutLabel, float rotation)
        throws DocumentException, IOException {

    if (bf == null) {
        bf = BaseFont.createFont(BaseFont.TIMES_ROMAN, BaseFont.CP1252, BaseFont.EMBEDDED);
    }//from  ww w .j  a v a 2  s  . co  m

    drawCircle(cb, x, y, r, lineWidth, grayStroke);
    if (rotation == 0) {
        float mid = x + (r / 2);
        drawStringCentered(cb, bf, mid, y + r + topPad, fontsize, boutLabel, rotation);
    } else if (rotation == 90) {
        drawStringCentered(cb, bf, x + topPad, y, fontsize, boutLabel, rotation);
    }
}

From source file:bouttime.report.bracketsheet.BracketSheetUtil.java

License:Open Source License

public static void drawBoutNum(PdfContentByte cb, BaseFont bf, float x, float y, float width, float height,
        float topPad, float botPad, int fontsize, float lineWidth, float grayStroke, String boutNum,
        float rotation) throws DocumentException, IOException {

    if (bf == null) {
        bf = BaseFont.createFont(BaseFont.TIMES_ROMAN, BaseFont.CP1252, BaseFont.EMBEDDED);
    }//from  w ww. j  a va2  s.c o m

    drawRectangle(cb, x, y, width, height, lineWidth, grayStroke);
    if (rotation == 0) {
        float mid = x + (width / 2);
        drawStringCentered(cb, bf, mid, y + botPad, fontsize, boutNum, rotation);
    } else if (rotation == 90) {
        float mid = y + (height / 2);
        drawStringCentered(cb, bf, x + width - botPad, mid, fontsize, boutNum, rotation);
    }
}

From source file:bouttime.report.bracketsheet.BracketSheetUtil.java

License:Open Source License

public static void drawMatBox(PdfContentByte cb, BaseFont bf, float x, float y, float width, float height,
        float topPad, float botPad, float lineWidth, float grayStroke, String mat, float rotation)
        throws DocumentException, IOException {

    if (bf == null) {
        bf = BaseFont.createFont(BaseFont.TIMES_ROMAN, BaseFont.CP1252, BaseFont.EMBEDDED);
    }/*  w w w .j av a2s  .com*/

    drawRectangle(cb, x, y, width, height, lineWidth, grayStroke);

    if (rotation == 0) {
        float mid = x + (width / 2);
        drawStringCentered(cb, bf, mid, y + height - topPad, 12, "Mat", rotation);
        drawStringCentered(cb, bf, mid, y + botPad, 16, mat, rotation);
    } else if (rotation == 90) {
        float mid = y + (height / 2);
        drawStringCentered(cb, bf, x + topPad, mid, 12, "Mat", rotation);
        drawStringCentered(cb, bf, x + width - botPad, mid, 16, mat, rotation);
    }
}

From source file:bouttime.report.bracketsheet.BracketSheetUtil.java

License:Open Source License

public static void drawTimestamp(PdfContentByte cb, BaseFont bf, float x, float y, int fontsize,
        String timestamp, float rotation) throws DocumentException, IOException {

    if (bf == null) {
        bf = BaseFont.createFont(BaseFont.TIMES_ROMAN, BaseFont.CP1252, BaseFont.EMBEDDED);
    }//from  ww  w. ja  v  a2 s  . c o m

    drawString(cb, bf, x, y, fontsize, timestamp, rotation);
}

From source file:bouttime.report.bracketsheet.CommonBracketSheet.java

License:Open Source License

public Boolean doBlankPage(FileOutputStream fos, Dao dao) {
    if (!dao.isOpen()) {
        return false;
    }/*from   w  w w  . j  av  a 2  s .  c  o  m*/

    // step 1: creation of a document-object
    Document document = new Document();

    try {

        // step 2: creation of the writer
        if (fos == null) {
            return false;
        }
        PdfWriter writer = PdfWriter.getInstance(document, fos);

        // step 3: we open the document
        document.open();

        // step 4: we grab the ContentByte and do some stuff with it
        PdfContentByte cb = writer.getDirectContent();

        BaseFont bf = BaseFont.createFont(BaseFont.TIMES_ROMAN, BaseFont.CP1252, BaseFont.EMBEDDED);

        drawBracket(cb, bf, dao, null, false);

    } catch (DocumentException de) {
        logger.error("Document Exception", de);
        return false;
    } catch (IOException ioe) {
        logger.error("IO Exception", ioe);
        return false;
    }

    // step 5: we close the document
    document.close();

    return true;
}