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

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

Introduction

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

Prototype

String TIMES_ROMAN

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

Click Source Link

Document

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

Usage

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

License:Open Source License

public static void drawBout(PdfContentByte cb, BaseFont bf, float x, float y, String red, boolean strikeRed,
        String green, boolean strikeGreen, String boutNum, String round, int winner)
        throws DocumentException, IOException {

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

    float width = boutRectWidth;
    float height = boutRectHeight;
    float length = boutLineLength;
    float fontSize = 12;
    float pad = padForVS;
    float linePad = 2;

    BracketSheetUtil.drawStringCentered(cb, bf, x + (width / 2), y + (boutRectHeight / 4), fontSize, round, 0);
    x += width;
    BracketSheetUtil.drawRectangle(cb, x, y, width, height, 1, 0);
    BracketSheetUtil.drawStringCentered(cb, bf, x + (width / 2), y + (boutRectHeight / 4), fontSize, boutNum,
            0);
    x += width;
    BracketSheetUtil.drawHorizontalLine(cb, x, y, length, 1, 0);
    if (red != null) {
        BracketSheetUtil.drawString(cb, bf, x + boxPad, y + linePad, fontSize, red, strikeRed);
    }

    x += length;
    BracketSheetUtil.drawRectangle(cb, x, y, width, height, 1, 0);
    if (winner == 1) {
        BracketSheetUtil.drawStringCentered(cb, bf, x + (width / 2), y + (height / 4), fontSize, "X", 0);
    }
    x += width + pad;
    BracketSheetUtil.drawString(cb, bf, x, y + linePad, fontSize, "vs");
    x += pad + spaceForVS;
    BracketSheetUtil.drawHorizontalLine(cb, x, y, length, 1, 0);
    if (green != null) {
        BracketSheetUtil.drawString(cb, bf, x + boxPad, y + linePad, fontSize, green, strikeGreen);
    }
    x += length;
    BracketSheetUtil.drawRectangle(cb, x, y, width, height, 1, 0);
    if (winner == 2) {
        BracketSheetUtil.drawStringCentered(cb, bf, x + (width / 2), y + (height / 4), fontSize, "X", 0);
    }
}

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

License:Open Source License

public static void drawWrestlerNameHeader(PdfContentByte cb, BaseFont bf, float x, float y, float width)
        throws DocumentException, IOException {

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

    float fontSize = 8;
    float mid;

    mid = x + (width / 2);
    BracketSheetUtil.drawStringCentered(cb, bf, mid, y, fontSize, "Wins", 0);
    mid += width;
    BracketSheetUtil.drawStringCentered(cb, bf, mid, y, fontSize, "Losses", 0);
    mid += width;
    BracketSheetUtil.drawStringCentered(cb, bf, mid, y, fontSize, "Place", 0);
}

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

License:Open Source License

public static void drawWrestlerNameLine(PdfContentByte cb, BaseFont bf, float x, float y, float length,
        int tablePad, float width, float height, int wins, int losses, Integer place)
        throws DocumentException, IOException {

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

    BracketSheetUtil.drawHorizontalLine(cb, x, y, length, 1, 0);

    x = x + length + tablePad;
    BracketSheetUtil.drawRectangle(cb, x, y, width, height, 1, 0); // wins
    if (wins >= 0) {
        BracketSheetUtil.drawStringCentered(cb, bf, x + (width / 2), y + (height / 4), 12,
                Integer.toString(wins), 0);
    }
    x += width;
    BracketSheetUtil.drawRectangle(cb, x, y, width, height, 1, 0); // losses
    if (losses >= 0) {
        BracketSheetUtil.drawStringCentered(cb, bf, x + (width / 2), y + (height / 4), 12,
                Integer.toString(losses), 0);
    }
    x += width;
    BracketSheetUtil.drawRectangle(cb, x, y, width, height, 1, 0); // place
    if (place != null) {
        BracketSheetUtil.drawStringCentered(cb, bf, x + (width / 2), y + (height / 4), 12, place.toString(), 0);
    }
}

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

License:Open Source License

public static void drawTitle(PdfContentByte cb, BaseFont bf, float mid, float y, Group group, float rotation)
        throws DocumentException, IOException {

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

    if (group == null) {
        return;
    }

    String classification = group.getClassification();
    if (classification == null) {
        classification = "";
    }

    String div = group.getAgeDivision();
    if (div == null) {
        div = "";
    }

    String weightClass = group.getWeightClass();
    if (weightClass == null) {
        weightClass = "";
    }

    String title = String.format("%s    %s    %s", classification, div, weightClass);
    title.trim();

    BracketSheetUtil.drawStringCentered(cb, bf, mid, y, 18, title, rotation);
}

From source file:bouttime.utility.boutsheet.BoutSheetMaker.java

License:Open Source License

/**
 * @param args the command line arguments
 *//* w ww  .  j  a  va 2 s .c  o m*/
public static void main(String[] args) {
    // step 1: creation of a document-object
    // rotate to make page landscape
    Document document = new Document(PageSize.A4.rotate());

    try {

        // step 2: creation of the writer
        PdfWriter writer;
        if (args.length >= 1) {
            writer = PdfWriter.getInstance(document, new FileOutputStream(args[0]));
        } else {
            System.err.println("ERROR : Must specify output file.");
            return;
        }

        // 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);
        float pageWidth = cb.getPdfDocument().getPageSize().getWidth();
        float midPage = pageWidth / 2;

        drawBout(cb, bf, 35, midPage - 35);
        drawBout(cb, bf, midPage + 35, pageWidth - 35);
    } catch (DocumentException de) {
        System.err.println(de.getMessage());
        return;
    } catch (IOException ioe) {
        System.err.println(ioe.getMessage());
        return;
    }

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

    if ((args.length == 3) && (Boolean.parseBoolean(args[2]))) {
        showPDF(args[0]);
    }
}

From source file:bouttime.utility.bracketsheet.Bracket16Maker.java

License:Open Source License

/**
 * @param args the command line arguments
 * arg0 String filename for output file/*www .  ja v  a 2 s. c  om*/
 * arg1 boolean value "true" will render/show PDF file in viewer, default is false
 *
 * For example :
 *     Bracket2Maker /tmp/test.pdf true
 */
public static void main(String[] args) {
    // step 1: creation of a document-object
    Document document = new Document();

    try {

        // step 2: creation of the writer
        PdfWriter writer;
        if (args.length >= 1) {
            writer = PdfWriter.getInstance(document, new FileOutputStream(args[0]));
        } else {
            System.err.println("ERROR : Must specify output file.");
            return;
        }

        // 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);
    } catch (DocumentException de) {
        System.err.println(de.getMessage());
        return;
    } catch (IOException ioe) {
        System.err.println(ioe.getMessage());
        return;
    }

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

    if ((args.length == 2) && (Boolean.parseBoolean(args[1]))) {
        RoundRobinBracketMaker.showPDF(args[0]);
    }
}

From source file:bouttime.utility.bracketsheet.RoundRobinBracketMaker.java

License:Open Source License

/**
 * @param args the command line arguments
 * arg0 String filename for output file/*w  ww  .j av a2s  . co m*/
 * arg1 int number of wrestlers
 * arg2 boolean value "true" will render/show PDF file in viewer, default is false
 *
 * For example :
 *     RoundRobinBracketMaker /tmp/test.pdf 3 true
 */
public static void main(String[] args) {
    // step 1: creation of a document-object
    Document document = new Document();

    try {

        // step 2: creation of the writer
        PdfWriter writer;
        int numWrestlers;
        if (args.length >= 2) {
            writer = PdfWriter.getInstance(document, new FileOutputStream(args[0]));
            numWrestlers = Integer.parseInt(args[1]);
        } else {
            System.err.println("ERROR : Must specify output file and number of wrestlers.");
            return;
        }

        // 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, numWrestlers);
    } catch (DocumentException de) {
        System.err.println(de.getMessage());
        return;
    } catch (IOException ioe) {
        System.err.println(ioe.getMessage());
        return;
    }

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

    if ((args.length == 3) && (Boolean.parseBoolean(args[2]))) {
        showPDF(args[0]);
    }
}

From source file:co.ordinate.printer.NewJFrame.java

private void A4BTNActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_A4BTNActionPerformed

    new SwingWorker<Object, Object>() {
        String filename;/*from   ww  w .  j  a  v  a 2 s.  c o m*/

        @Override
        protected void done() {

            ConsoleMsg("Printing PROFILE SHEET IN PROGRESS.. ");

        }

        @Override
        protected Object doInBackground() throws Exception {

            Document doc = new Document();
            try {
                PdfWriter writer = PdfWriter.getInstance(doc, new FileOutputStream("A4.pdf"));
                doc.open();
                doc.addTitle("Recruitment PET Sheett - " + "Created By SOS : ");
                doc.addSubject("Confidential Report Eyes Only");
                doc.addKeywords("");
                doc.addAuthor("SOS");
                doc.addCreator("SOS");

                // A4 = 210mm x 297mm ~ 605points x 855points
                doc.setPageSize(PageSize.A4);
                doc.setMargins(10f, 10f, 10f, 10f);

                /////////////////////////////////////////////////////////////
                int pageno = 1;

                for (int i = 0; i == pageno; i++) {

                    //    doc.add(imageRight);
                }

                PdfContentByte cb = writer.getDirectContent();

                int i = 1;
                while (i <= pageno) {
                    doc.newPage();

                    i++;
                }
                BaseFont labelFont = BaseFont.createFont(BaseFont.TIMES_ROMAN, "Cp1252", true);
                float width = doc.getPageSize().getWidth();
                float height = doc.getPageSize().getHeight();
                for (float h = 0; h <= height; h++) {
                    for (float w = 0; w <= width; w++) {
                        cb.beginText();
                        // cb.setColorFill(TITLE_COLOR);
                        cb.setFontAndSize(labelFont, 2);
                        cb.setTextMatrix(w, h);

                        cb.showText(String.valueOf(h) + ":" + String.valueOf(w));
                        cb.endText();
                        w += 15;
                    }
                    h += 2;
                }
                cb.beginText();
                // cb.setColorFill(TITLE_COLOR);
                cb.setFontAndSize(labelFont, 4);
                cb.setTextMatrix(20f, 220f);
                cb.showText("abcd");
                cb.endText();

            } catch (Exception e) {
                System.err.println(e.getMessage());

                ConsoleMsg(e.getMessage());
            } finally {
                doc.close();
            }

            ConsoleMsg("PDF... GENERATED");

            return null;
            //    throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }
    }.execute();

    // TODO add your handling code here:
}

From source file:co.ordinate.printer.NewJFrame.java

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
    new SwingWorker<Object, Object>() {
        String filename;//from ww  w . ja  v a  2s  . c  om

        @Override
        protected void done() {

            ConsoleMsg("Printing PROFILE SHEET IN PROGRESS.. ");

        }

        @Override
        protected Object doInBackground() throws Exception {

            Document doc = new Document();
            try {
                PdfWriter writer = PdfWriter.getInstance(doc, new FileOutputStream("letter.pdf"));
                doc.open();
                doc.addTitle("Recruitment PET Sheett - " + "Created By SOS : ");
                doc.addSubject("Confidential Report Eyes Only");
                doc.addKeywords("");
                doc.addAuthor("SOS");
                doc.addCreator("SOS");

                // A4 = 210mm x 297mm ~ 605points x 855points
                doc.setPageSize(PageSize.LETTER);
                doc.setMargins(10f, 10f, 10f, 10f);

                /////////////////////////////////////////////////////////////
                int pageno = 1;

                for (int i = 0; i == pageno; i++) {

                    //    doc.add(imageRight);
                }

                PdfContentByte cb = writer.getDirectContent();

                int i = 1;
                while (i <= pageno) {
                    doc.newPage();

                    i++;
                }
                BaseFont labelFont = BaseFont.createFont(BaseFont.TIMES_ROMAN, "Cp1252", true);
                float width = doc.getPageSize().getWidth();
                float height = doc.getPageSize().getHeight();
                for (float h = 0; h <= height; h++) {
                    for (float w = 0; w <= width; w++) {
                        cb.beginText();
                        // cb.setColorFill(TITLE_COLOR);
                        cb.setFontAndSize(labelFont, 4);
                        cb.setTextMatrix(w, h);

                        cb.showText(String.valueOf(h) + ":" + String.valueOf(w));
                        cb.endText();
                        w += 25;
                    }
                    h += 5;
                }
                cb.beginText();
                // cb.setColorFill(TITLE_COLOR);
                cb.setFontAndSize(labelFont, 4);
                cb.setTextMatrix(20f, 220f);
                cb.showText("abcd");
                cb.endText();

            } catch (Exception e) {
                System.err.println(e.getMessage());

                ConsoleMsg(e.getMessage());
            } finally {
                doc.close();
            }

            ConsoleMsg("PDF... GENERATED");

            return null;
            //    throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }
    }.execute();

    // TODO add your handling code here:
}

From source file:co.ordinate.printer.NewJFrame.java

private void printA6Sheet() {
    new SwingWorker<Object, Object>() {
        String filename;//from   w w  w  .j  a  va  2s . c  o m

        @Override
        protected void done() {

            ConsoleMsg("Printing PROFILE SHEET IN PROGRESS.. ");
            System.err.println("Printing Done");
        }

        @Override
        protected Object doInBackground() throws Exception {

            Document doc = new Document();
            try {
                PdfWriter writer = PdfWriter.getInstance(doc, new FileOutputStream("A6.pdf"));
                doc.open();
                doc.addTitle("Recruitment PET Sheett - " + "Created By SOS : ");
                doc.addSubject("Confidential Report Eyes Only");
                doc.addKeywords("");
                doc.addAuthor("SOS");
                doc.addCreator("SOS");

                // A4 = 210mm x 297mm ~ 605points x 855points
                doc.setPageSize(PageSize.A5);
                doc.setMargins(10f, 10f, 10f, 10f);

                /////////////////////////////////////////////////////////////
                int pageno = 1;

                for (int i = 0; i == pageno; i++) {

                    //    doc.add(imageRight);
                }

                PdfContentByte cb = writer.getDirectContent();

                int i = 1;
                while (i <= pageno) {
                    doc.newPage();

                    i++;
                }
                BaseFont labelFont = BaseFont.createFont(BaseFont.TIMES_ROMAN, "Cp1252", true);
                float width = doc.getPageSize().getWidth();
                float height = doc.getPageSize().getHeight();
                for (float h = 0; h <= height; h++) {
                    for (float w = 0; w <= width; w++) {
                        cb.beginText();
                        // cb.setColorFill(TITLE_COLOR);
                        cb.setFontAndSize(labelFont, 4);
                        cb.setTextMatrix(w, h);

                        cb.showText(String.valueOf(h) + ":" + String.valueOf(w));
                        cb.endText();
                        w += 30;
                    }
                    h += 8;
                }
                cb.beginText();
                // cb.setColorFill(TITLE_COLOR);
                cb.setFontAndSize(labelFont, 4);
                cb.setTextMatrix(20f, 220f);
                cb.showText("abcd");
                cb.endText();

            } catch (Exception e) {
                System.err.println(e.getMessage());

                ConsoleMsg(e.getMessage());
            } finally {
                doc.close();
            }

            ConsoleMsg("PDF... GENERATED");
            System.err.println("Printing Done");
            return null;
            //    throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }
    }.execute(); // TODO add your handling code here:

}