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

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

Introduction

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

Prototype

String CP1250

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

Click Source Link

Document

A possible encoding.

Usage

From source file:com.app.gpo.pdf.utils.PDForderLabelCard.java

License:Open Source License

@Override
protected void buildPdfDocument(Map<String, Object> model, Document doc, PdfWriter writer,
        HttpServletRequest request, HttpServletResponse response) throws Exception {
    // get data model which is passed by the Spring container
    OrderItem orderItem = (OrderItem) model.get("orderItem");
    Font font = FontFactory.getFont(FontFactory.HELVETICA, BaseFont.CP1250, BaseFont.EMBEDDED);
    font.setSize(20);//from  ww w  .  ja va 2  s  .c o  m
    Font font2 = FontFactory.getFont(FontFactory.HELVETICA, BaseFont.CP1250, BaseFont.EMBEDDED);
    font2.setSize(12);

    String utf = orderItem.getorderItemName();
    byte[] data = utf.getBytes("CP1250");
    String ascii = new String(data);
    String code = orderItem.getorderNumber();
    Paragraph numberText = new Paragraph(code, font);
    numberText.setAlignment(Element.ALIGN_CENTER);
    doc.add(new Phrase("\n"));
    Paragraph nameText = new Paragraph(ascii, font2);
    nameText.setAlignment(Element.ALIGN_CENTER);
    // document.newPage()
    /*BarcodeEAN barcode = new BarcodeEAN();
    barcode.setCodeType(Barcode.CODE128);
    barcode.setCode(code);
    Rectangle barcodeRect = new Rectangle(400,200);
    barcode.placeBarcode(barcodeRect, BaseColor.BLACK, BaseColor.YELLOW);
    doc.add(barcode.createImageWithBarcode(writer.getDirectContent(), BaseColor.BLACK, BaseColor.GRAY));*/
    doc.add(numberText);
    doc.add(new Phrase("\n"));
    doc.add(nameText);
}

From source file:com.app.gpo.pdf.utils.PDForderLabelCards.java

License:Open Source License

@Override
protected void buildPdfDocument(Map<String, Object> model, Document doc, PdfWriter writer,
        HttpServletRequest request, HttpServletResponse response) throws Exception {
    // get data model which is passed by the Spring container
    List<OrderItem> orderItemList = (List<OrderItem>) model.get("orderItemList");
    Font font = FontFactory.getFont(FontFactory.HELVETICA, BaseFont.CP1250, BaseFont.EMBEDDED);
    font.setSize(18);/* w  w w  . j a va2s. c  o m*/
    Font font2 = FontFactory.getFont(FontFactory.HELVETICA, BaseFont.CP1250, BaseFont.EMBEDDED);
    font2.setSize(12);

    Iterator<OrderItem> it = orderItemList.iterator();
    while (it.hasNext()) {
        OrderItem orderItem = it.next();
        String utf = orderItem.getorderItemName();
        byte[] data = utf.getBytes("CP1250");
        String ascii = new String(data);
        String code = orderItem.getorderNumber();
        Paragraph numberText = new Paragraph(code, font);
        numberText.setAlignment(Element.ALIGN_CENTER);
        doc.add(new Phrase("\n"));
        Paragraph nameText = new Paragraph(ascii, font2);
        nameText.setAlignment(Element.ALIGN_CENTER);
        // document.newPage()
        /*BarcodeEAN barcode = new BarcodeEAN();
        barcode.setCodeType(Barcode.CODE128);
        barcode.setCode(code);
        Rectangle barcodeRect = new Rectangle(400,200);
        barcode.placeBarcode(barcodeRect, BaseColor.BLACK, BaseColor.YELLOW);
        doc.add(barcode.createImageWithBarcode(writer.getDirectContent(), BaseColor.BLACK, BaseColor.GRAY));*/
        doc.add(numberText);
        doc.add(new Phrase("\n"));
        doc.add(nameText);
        doc.newPage();
    }

}

From source file:com.cib.statementstamper.windows.StatementStamperMainWindow.java

License:Open Source License

@Override
public void attach() {
    super.attach();
    try {/*  www . j  a  va2  s  .com*/
        logo = Image
                .getInstance(StatementStamperMainWindow.class.getResource("/resources/images/cib_logo.jpg"));
        logo.setAlignment(Image.LEFT);
        logo.scalePercent(30);
        isplogo = Image
                .getInstance(StatementStamperMainWindow.class.getResource("/resources/images/isplogo.jpg"));
        isplogo.setAlignment(Image.LEFT);
        isplogo.scalePercent(50);
        baseFontArial = BaseFont.createFont("/resources/fonts/ARIAL.TTF", BaseFont.CP1250, BaseFont.EMBEDDED);
        myFontBase = BaseFont.createFont("/resources/fonts/courbd.ttf", BaseFont.CP1250, BaseFont.EMBEDDED);
        bottomFont = new Font(baseFontArial, 7, Font.NORMAL, BaseColor.BLACK);
        bottomFontBold = new Font(baseFontArial, 7, Font.BOLD, BaseColor.BLACK);
    } catch (DocumentException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    upload.addListener((Upload.SucceededListener) this);
    upload.addListener((Upload.StartedListener) this);
    upload.addListener((Upload.FinishedListener) this);
    upload.addListener((Upload.FailedListener) this);
    upload.setImmediate(true);
    addComponent(upload);
}

From source file:de.jost_net.JVerein.io.FormularAufbereitung.java

License:Open Source License

private void goFormularfeld(PdfContentByte contentByte, Formularfeld feld, Object val)
        throws DocumentException, IOException {
    BaseFont bf = null;/*from  w w  w  .j  ava  2 s  .  co  m*/
    if (feld.getFont().startsWith("FreeSans")) {
        String filename = "/fonts/FreeSans";
        if (feld.getFont().length() > 8) {
            filename += feld.getFont().substring(9);
        }
        bf = BaseFont.createFont(filename + ".ttf", BaseFont.IDENTITY_H, true);
    } else {
        bf = BaseFont.createFont(feld.getFont(), BaseFont.CP1250, false);
    }

    float x = mm2point(feld.getX().floatValue());
    float y = mm2point(feld.getY().floatValue());
    if (val == null) {
        return;
    }
    buendig = links;
    String stringVal = getString(val);
    stringVal = stringVal.replace("\\n", "\n");
    stringVal = stringVal.replaceAll("\r\n", "\n");
    String[] ss = stringVal.split("\n");
    for (String s : ss) {
        contentByte.setFontAndSize(bf, feld.getFontsize().floatValue());
        contentByte.beginText();
        float offset = 0;
        if (buendig == rechts) {
            offset = contentByte.getEffectiveStringWidth(s, true);
        }
        contentByte.moveText(x - offset, y);
        contentByte.showText(s);
        contentByte.endText();
        y -= feld.getFontsize().floatValue() + 3;
    }
}

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 {// w w  w  .  j  av a  2 s.  co 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);//w  w  w  .ja  va2  s.  c  o m

    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);/*  w w  w.ja va  2  s.  com*/

    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);/*w w  w  .j a  va2 s  . c  o  m*/

    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;
    }
}

From source file:fattura.Fattura.java

public void inserisciDatiGiubb(String cliente, String data, PdfStamper s)
        throws SQLException, IOException, DocumentException {
    ArrayGiubbotto arraygiubb = new ArrayGiubbotto();
    arraygiubb.ArrayIDgiubbotto(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   www. j av  a  2s  .  c om*/

    for (int j = 0; j < arraygiubb.IDgiubbotti.length; j++) {
        arraygiubb.accessoGiubbotti(j);
        importo = arraygiubb.importoGiubbotto(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 < arraygiubb.riga.length; z++) {
            content.showTextAligned(PdfContentByte.ALIGN_LEFT, arraygiubb.riga[z] + "   ", 95 + x, 538 - y, 0);
            x += 97; //sposta la coordinata y ad ogni stampa

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

}

From source file:fattura.Fattura.java

public void inserisciDatiFelpe(String cliente, String data, PdfStamper s)
        throws SQLException, IOException, DocumentException {
    ArrayFelpa arrayfelpa = new ArrayFelpa();
    arrayfelpa.ArrayIDfelpa(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);/* w w w.ja va 2 s  .c  om*/

    for (int j = 0; j < arrayfelpa.IDfelpe.length; j++) {
        arrayfelpa.accessoFelpe(j);
        importo = arrayfelpa.importoFelpa(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 < arrayfelpa.riga.length; z++) {
            content.showTextAligned(PdfContentByte.ALIGN_LEFT, arrayfelpa.riga[z] + "   ", 95 + x, 538 - y, 0);
            x += 97; //sposta la coordinata y ad ogni stampa

        }
        content.showTextAligned(PdfContentByte.ALIGN_LEFT, "Felpa", 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!

}