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

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

Introduction

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

Prototype

String HELVETICA

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

Click Source Link

Document

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

Usage

From source file:edu.avans.ivh5.shared.util.generateInvoicePDF2.java

private void initializeFonts() {

    try {//from   w  w w.  j a  v a 2s. c om
        bfBold = BaseFont.createFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
        bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);

    } catch (DocumentException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

}

From source file:englishrusbook.Writer.java

public void write(Document document, HashMap<String, String> wordTranslateMap) {
    document.open();//from w  w  w .ja va  2s.com
    String delimiter = " : ";
    try {
        BaseFont helvetica = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
        Font font = new Font(helvetica, 12);
        for (Entry<String, String> entry : wordTranslateMap.entrySet()) {
            document.add(new Paragraph(entry.getKey() + delimiter + entry.getValue(), font));
        }
    } catch (DocumentException | IOException e) {
        System.out.println("ERROR in writing: " + e);
    } finally {
        document.close();
    }
}

From source file:EplanPrinter.PDFPrint.java

License:Open Source License

public String insertComment(String sx, String sy, String id, String deptValue, String userInit, String comment,
        int pageNum, int masterHeight, int masterWidth, int pinned, int customFontSize)
        throws DocumentException, IOException {
    float ratio = getRatio(masterHeight, masterWidth, pageNum);
    float x = Float.parseFloat(sx);
    float y = Float.parseFloat(sy);
    float[] f = commentTrans(x, y, masterHeight, masterWidth, pageNum);
    PdfGState gs1 = new PdfGState();
    gs1.setFillOpacity(1);/*from   ww  w .jav a2s.c om*/
    if (customFontSize > 0)
        fontSize = customFontSize;

    PdfContentByte fg = pds.getOverContent(pageNum);
    fg.setGState(gs1);
    BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.NOT_EMBEDDED);
    float[] trans = translate(x, y, r[pageNum - 1].getHeight(), r[pageNum - 1].getWidth(), masterHeight,
            masterWidth, pageNum);
    // comment tag image (width=35pts, height=8pts)
    float[] scalar = scale(trans[0], trans[1], 35, 8, masterHeight, masterWidth, pageNum);

    /* Addition. ftorres - 7/21/2015 - Added to account for rotated pages 
     *   with the origin (0,0) not set to the bottom-left of the page. [1400] */
    float coords[] = translateRotation(trans[0], trans[1], pageNum);
    coords = checkBounds(coords[0], coords[1], pageNum);

    /* Addition. ftorres - 10/20/2015 - If the comment was pinned in EPC, then
     *   render the comment inside a comment box. */
    if (pinned == 1) {
        insertPinnedComment(coords[0], coords[1], id + " - " + deptValue + " (" + userInit + ")", comment,
                pageNum, masterHeight, masterWidth);

        // Add the pinned comment text to page annotation -Jon Changkachith 11/24/2015
        Rectangle rect = new Rectangle(0, 0, 0, 0);
        PdfAnnotation annotation = PdfAnnotation.createText(pds.getWriter(), rect,
                id + " - " + deptValue + " (" + userInit + ")", cleanupComment(comment), true, id);
        pds.addAnnotation(annotation, pds.getWriter().getCurrentPageNumber());
    } else {
        Image image = Image.getInstance(commentIMGPath);
        image.setAbsolutePosition(coords[0] + (scalar[0] * (id.length() / 5f)), coords[1]);

        /*
         * Commented out by Jon Changkachith 12/09/2015 because it was throwing
         * DocumentException with the message "The image must have absolute positioning."
        image.scaleAbsoluteHeight(1);
        image.scaleAbsoluteWidth(1);
        */
        image.scalePercent(ratio); //Added to fix DocumentException "The image must have absolute positioning." Jon Changkachith 12/09/2015
        image.setAnnotation(new Annotation(id + " - " + deptValue + " (" + userInit + ")",
                cleanupComment(comment), 0, 0, 0, 0));
        fg.addImage(image);
    }

    fg.setLineWidth(.5f * ratio);
    fg.setColorStroke(new BaseColor(Color.decode("0x6E2405").getRGB()));
    fg.setColorFill(new BaseColor(Color.decode("0x6E2405").getRGB()));

    float tHeight = scalar[1];
    float tWidth = 0;
    if (id.length() > 3) {
        tWidth = (scalar[0] * (id.length() / 5f));
    } else {
        tWidth = (scalar[0]);
    }

    fg.moveTo(coords[0], coords[1]);
    fg.lineTo(coords[0] + (10f * ratio), coords[1] - (tHeight / 2));
    fg.lineTo(coords[0] + tWidth, coords[1] - (tHeight / 2));
    fg.lineTo(coords[0] + tWidth, coords[1] + (tHeight / 2));
    fg.lineTo(coords[0] + (10f * ratio), coords[1] + (tHeight / 2));

    fg.lineTo(coords[0], coords[1]);
    fg.closePathFillStroke();
    fg.fill();

    // Comment number that goes on the comment tag image
    Phrase p = new Phrase(id);
    p.getFont().setColor(BaseColor.WHITE);
    p.getFont().setSize(8f * ratio); //comment number font size = 8f
    //p.getChunks().get(0).setAnnotation(PdfAnnotation.createText(pds.getWriter(), new Rectangle(trans[0],trans[1], trans[0]+5f, trans[1]+5f), id, comment, true, id));

    float fs[] = translateRotation(f[0], f[1], pageNum);
    fs = checkBounds(fs[0], fs[1], pageNum);
    ColumnText.showTextAligned(fg, Element.ALIGN_LEFT, p, (float) (fs[0] + (9 * ratio)),
            (float) (fs[1] - (3 * ratio)), 0);

    return "";
}

From source file:EplanPrinter.PDFPrint.java

License:Open Source License

private void insertPinnedComment(float xCoord, float yCoord, String id, String comment, int pageNum,
        int masterHeight, int masterWidth) throws DocumentException, IOException {

    int standardHeight = 38;
    int standardWidth = 130;
    int lineHeight = 7;

    if (fontSize == 8) {
        standardHeight = 48;//from w w  w  .ja  v a 2  s .  c  o m
        standardWidth = 180;
        lineHeight = 10;
    } else if (fontSize == 10) {
        standardHeight = 70;
        standardWidth = 210;
        lineHeight = 12;
    }

    // comment box position defines lower-left corner
    xCoord += 41; // x-coordinate of comment text box
    yCoord -= 7; // lower offset moves box up

    float f = (float) 0.4;
    PdfGState gs1 = new PdfGState();
    gs1.setFillOpacity(f);

    PdfContentByte fg = pds.getOverContent(pageNum);
    fg.setGState(gs1);
    fg.setLineWidth(.5f * getRatio(masterHeight, masterWidth, pageNum));

    // Calculate additional needed height for the comment, based on length of comment.
    List<String> lines = createComment(cleanupComment(comment));
    int numLines = lines.size();
    int commentHeight = (numLines - 1) * lineHeight;

    // Draw the comment box
    String color = "0xF2F3E4";
    Color c = Color.decode(color);
    color = "0xFAFAF4";
    Color c2 = Color.decode(color);
    fg.setLineWidth(1f);
    fg.setColorStroke(new BaseColor(c.getRGB()));
    fg.setColorFill(new BaseColor(c2.getRGB()));
    float newCoords[] = pinnedCoords(xCoord, yCoord, standardWidth, standardHeight + commentHeight);
    fg.roundRectangle(xCoord, newCoords[1], standardWidth, standardHeight + commentHeight, 2f);
    fg.fillStroke();

    //BaseFont bf = BaseFont.createFont();
    BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, true);
    BaseFont bfb = BaseFont.createFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1252, true);
    fg.setColorFill(BaseColor.RED);
    gs1.setFillOpacity(0.8f);
    fg.setGState(gs1);

    // Adding comment title text
    Phrase phrase = new Phrase("Comment", new Font(bfb, fontSize));
    ColumnText.showTextAligned(fg, Element.ALIGN_LEFT, phrase, xCoord + 3, yCoord - 7, 0);

    // Adding comment number
    phrase = new Phrase(id, new Font(bf, fontSize));
    float offset = xCoord + 35;
    if (fontSize == 8)
        offset = xCoord + 45;
    else if (fontSize == 10)
        offset = xCoord + 55;
    ColumnText.showTextAligned(fg, Element.ALIGN_LEFT, phrase, offset, yCoord - 7, 0);

    /*  Remove 10/27/2015 Jon Changkachith
    // Adding 'comment' label text
    phrase = new Phrase("Comment", new Font(bfb, fontSize));
    ColumnText.showTextAligned(fg, Element.ALIGN_LEFT, phrase, xCoord + 3, yCoord - 20f, 0);
    */

    // Adding comment text
    int commentYOffset = 32;
    for (int i = 0; i < lines.size(); i++) {
        //phrase = new Phrase(lines.get(i), new Font(bf, fontSize));
        phrase = composePhrase(lines.get(i), bf, bfb);
        ColumnText.showTextAligned(fg, Element.ALIGN_LEFT, phrase, xCoord + 3, yCoord - commentYOffset, 0);
        commentYOffset += lineHeight;
    }

}

From source file:es.clinica.veterinaria.facturas.FacturaPdf.java

private void initializeFonts() throws DocumentException, IOException {
    try {//from   w w w. j av a  2 s .c  o m
        bfBold = BaseFont.createFont(BaseFont.TIMES_BOLD, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
        bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);

    } catch (DocumentException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:es.sm2.openppm.front.utils.DocumentUtils.java

License:Open Source License

/**
 * /*from   www  . j  av a2 s  .com*/
 * @param pagActual
 * @param pagTotal
 * @param headerImg
 * @param footerImg
 * @param reader
 * @param stamper
 * @param idioma
 * @throws DocumentException
 * @throws IOException
 */
private static void setHeaderFooter(int pagActual, int pagTotal, Image headerImg, Image footerImg,
        PdfReader reader, PdfStamper stamper, ResourceBundle idioma) throws DocumentException, IOException {

    PdfContentByte content = stamper.getUnderContent(pagActual);
    content.setFontAndSize(BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, false), 8);
    headerImg.setAbsolutePosition(74f, 745f);
    content.addImage(headerImg);
    footerImg.setAbsolutePosition(75f, 20f);
    content.addImage(footerImg);
    content.beginText();
    content.showTextAligned(Element.ALIGN_BOTTOM,
            "_____________________________________________________________________________________________________",
            75f, 55f, 0f);
    content.showTextAligned(Element.ALIGN_BOTTOM, "2010 OPEN PPM - Projet Portfolio Management. (Open PPM)",
            75f, 45f, 0f);
    content.showTextAligned(Element.ALIGN_BOTTOM, "www.sourceforce.net/openppm", 75f, 35f, 0f);
    content.showTextAligned(Element.ALIGN_BOTTOM,
            new ParamResourceBundle("pdf.pagination", pagActual, pagTotal).toString(idioma), 475f, 45f, 0f);
    content.endText();
    content.stroke();
}

From source file:fattura.Fattura.java

public void setFattura(String cliente, String data, AtomicInteger numerofattura, PdfStamper s)
        throws SQLException, DocumentException, FileNotFoundException, IOException { //Ho messo che il numero della fattura va passato come parametro, voglio capire se si pu fare altrimenti (con un contatore)

    try {/*from  w  w w . j a v  a  2s.  c  o m*/

        s.getAcroFields().setField("Num", numerofattura.toString()); // sistemare
        s.getAcroFields().setField("Data", data);
        s.getAcroFields().setField("Nome", cliente);
        PdfContentByte content = s.getUnderContent(1);//1 for the first page
        BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1250, BaseFont.EMBEDDED);
        content.beginText();
        content.setFontAndSize(bf, 7);
        inserisciDatiMaglie(cliente, data, s);
        inserisciDatiBorse(cliente, data, s);
        inserisciDatiPanta(cliente, data, s);
        inserisciDatiGiubb(cliente, data, s);
        inserisciDatiFelpe(cliente, data, s);
        inserisciDatiPubb(cliente, data, s);
        setImporti(s);
        content.endText();
        s.close();

    } catch (IOException | DocumentException e) {

    }
}

From source file:fattura.Fattura.java

public void inserisciDatiMaglie(String cliente, String data, PdfStamper s)
        throws SQLException, IOException, DocumentException {
    ArrayMaglia arraymaglia = new ArrayMaglia();
    arraymaglia.ArrayIDmaglia(cliente, data);
    float importo;

    PdfContentByte content = s.getUnderContent(1);//1 for the first page
    BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1250, BaseFont.EMBEDDED);
    content.setFontAndSize(bf, 7);/*from   ww  w  .j a v a 2  s.  com*/

    for (int j = 0; j < arraymaglia.IDmaglie.length; j++) {
        arraymaglia.accessoMaglie(j);
        importo = arraymaglia.importoMaglia(j);
        String convertitore = String.valueOf(importo); //Serve per convertire il ritorno del metodo importoUnitarioMaglia (float) a string per stamparlo,  solo un appoggio
        importi.add(importo); //salva l'importo maglia nella prima posizione array i cui elementi poi andranno sommati per calcolare il totale

        for (int z = 0; z < arraymaglia.riga.length; z++) {
            content.showTextAligned(PdfContentByte.ALIGN_LEFT, arraymaglia.riga[z] + "   ", 95 + x, 538 - y, 0);
            x += 97; //sposta la coordinata y ad ogni stampa
        }

        content.showTextAligned(PdfContentByte.ALIGN_LEFT, "Maglia", 95 + x, 538 - y, 0);
        x += 96;
        content.showTextAligned(PdfContentByte.ALIGN_LEFT, convertitore, 95 + x, 538 - y, 0);

        x = 0;
        y += 20;
    }

}

From source file:fattura.Fattura.java

public void inserisciDatiBorse(String cliente, String data, PdfStamper s)
        throws SQLException, IOException, DocumentException {
    ArrayBorsa arrayborsa = new ArrayBorsa();
    arrayborsa.ArrayIDborsa(cliente, data);
    float importo;

    PdfContentByte content = s.getUnderContent(1);//1 for the first page
    BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1250, BaseFont.EMBEDDED);
    content.setFontAndSize(bf, 7);/*from   ww  w. j  av a 2s  . c  om*/

    for (int j = 0; j < arrayborsa.IDborse.length; j++) {
        arrayborsa.accessoBorse(j);
        importo = arrayborsa.importoBorsa(j);
        String convertitore = String.valueOf(importo); //Serve per convertire il ritorno del metodo importoUnitarioMaglia (float) a string per stamparlo,  solo un appoggio
        importi.add(importo);
        for (int z = 0; z < arrayborsa.riga.length; z++) {
            content.showTextAligned(PdfContentByte.ALIGN_LEFT, arrayborsa.riga[z] + "   ", 95 + x, 538 - y, 0);
            x += 97; //sposta la coordinata y ad ogni stampa

        }
        content.showTextAligned(PdfContentByte.ALIGN_LEFT, "Borsa", 95 + x, 538 - y, 0);
        x += 97;
        content.showTextAligned(PdfContentByte.ALIGN_LEFT, convertitore, 95 + x, 538 - y, 0);
        x = 0;
        y += 20;
    }
    //MI calcolar il prezzo totale man mano che calcolo i preventivi lo agggiungo!

}

From source file:fattura.Fattura.java

public void inserisciDatiPanta(String cliente, String data, PdfStamper s)
        throws SQLException, IOException, DocumentException {
    ArrayPantalone arraypanta = new ArrayPantalone();
    arraypanta.ArrayIDpantalone(cliente, data);
    float importo = (float) 0.00;

    PdfContentByte content = s.getUnderContent(1);//1 for the first page
    BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1250, BaseFont.EMBEDDED);
    content.setFontAndSize(bf, 7);/*from w ww .jav  a 2 s  . com*/

    for (int j = 0; j < arraypanta.IDpantaloni.length; j++) {
        arraypanta.accessoPantaloni(j);
        importo = arraypanta.importoPanta(j);
        String convertitore = String.valueOf(importo); //Serve per convertire il ritorno del metodo importoUnitarioMaglia (float) a string per stamparlo,  solo un appoggio
        importi.add(importo);
        for (int z = 0; z < arraypanta.riga.length; z++) {
            content.showTextAligned(PdfContentByte.ALIGN_LEFT, arraypanta.riga[z] + "   ", 95 + x, 538 - y, 0);
            x += 97; //sposta la coordinata y ad ogni stampa

        }
        content.showTextAligned(PdfContentByte.ALIGN_LEFT, "Pantalone", 95 + x, 538 - y, 0);
        x += 97;
        content.showTextAligned(PdfContentByte.ALIGN_LEFT, convertitore, 95 + x, 538 - y, 0);
        x = 0;
        y += 20;
    }
}