Example usage for com.itextpdf.text Font UNDEFINED

List of usage examples for com.itextpdf.text Font UNDEFINED

Introduction

In this page you can find the example usage for com.itextpdf.text Font UNDEFINED.

Prototype

int UNDEFINED

To view the source code for com.itextpdf.text Font UNDEFINED.

Click Source Link

Document

the value of an undefined attribute.

Usage

From source file:adams.gui.chooser.PdfFontChooserPanel.java

License:Open Source License

/**
 * Sets the selected font. If null is provided, the default font/size will
 * be used./*from   w  w  w.j a va2 s. c  o  m*/
 *
 * @param value   the font, can be null
 */
public void setCurrent(PdfFont value) {
    String[] styles;
    int[] indices;
    int i;

    m_IgnoreUpdates = true;

    if (value == null)
        value = new PdfFont();

    m_ListFontName.setSelectedValue(value.getFontFamilyName(), true);
    if (m_ListFontName.getSelectedIndex() == -1)
        m_ListFontName.setSelectedValue(DEFAULT_FONT, true);

    if ((value.getFontFace() != Font.NORMAL) && (value.getFontFace() != Font.UNDEFINED)) {
        styles = value.getFontFaces();
        indices = new int[styles.length];
        for (i = 0; i < styles.length; i++)
            indices[i] = Arrays.binarySearch(FONT_FACES, styles[i]);
    } else {
        indices = new int[0];
    }
    m_ListFontFace.setSelectedIndices(indices);

    m_ListFontSize.setSelectedValue((int) value.getSize(), true);
    if (m_ListFontSize.getSelectedIndex() == -1)
        m_ListFontSize.setSelectedValue(DEFAULT_SIZE, true);

    m_IgnoreUpdates = false;

    previewFont();
}

From source file:com.iisigroup.cap.report.factory.ItextFontFactory.java

License:Open Source License

public Font getFont(String fontname, String fontType, String encoding, boolean embedded, float size) {
    return getFont(fontname, fontType, encoding, embedded, size, Font.UNDEFINED, null);
}

From source file:com.masscustsoft.service.ToPdf.java

License:Open Source License

private void getChunks(Paragraph p, final Map it, String text) throws Exception {
    if (text == null) {
        text = (String) it.get("text");
    }/* w ww.j a  v  a  2  s .  c  o  m*/
    if (text != null) {
        if (text.startsWith("<") || text.endsWith(">")) {
            //treat as HTML
            Reader in = new StringReader(text);
            FontFactoryImp ffi = new FontFactoryImp() {
                @Override
                public Font getFont(String fontname, String encoding, boolean embedded, float size, int style,
                        BaseColor color, boolean cached) {
                    if (size == Font.UNDEFINED)
                        size = getSize(it);
                    if (style == Font.UNDEFINED)
                        style = getStyle(it);
                    if (color == null)
                        color = getColor(it, "color");
                    return super.getFont(fontname, encoding, embedded, size, style, color, cached);
                }
            };
            HashMap map = new HashMap();
            map.put("font_factory", ffi);
            List list = DirectHtmlWorker.parse2List(in, null, null, map);
            for (int i = 0; i < list.size(); i++) {
                Object el = list.get(i);
                if (el instanceof Paragraph) {
                    Paragraph pp = (Paragraph) el;
                    applyFont(pp, it);
                    p.add(pp);
                }
            }
            return;
        }
        List<BaseFont> base = new ArrayList<BaseFont>();
        String st = text;
        StringBuffer buf = new StringBuffer();
        for (int i = 0; i < st.length(); i++) {
            char c = st.charAt(i);
            if (!compatible(base, c)) {
                processMacro(buf.toString(), base.get(0), it, p);
                buf.delete(0, buf.length());
                base.clear();
            }
            buf.append(c);
        }
        if (buf.length() > 0) {
            processMacro(buf.toString(), base.get(0), it, p);
        }
    }
}

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

License:Open Source License

public static Font getFreeSans(float size, BaseColor color) {
    return FontFactory.getFont("/fonts/FreeSans.ttf", BaseFont.IDENTITY_H, size, Font.UNDEFINED, color);
}

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

License:Open Source License

public static Font getFreeSansBold(float size, BaseColor color) {
    return FontFactory.getFont("/fonts/FreeSansBold.ttf", BaseFont.IDENTITY_H, size, Font.UNDEFINED, color);
}

From source file:Export.ExportViagemSemanaPdf.java

public static void criarDoc(Date dataInicio, Date dateFim, String user, String nomeFuncinario) {
    Font fontTableCorpo = FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 6f);
    Font fontTableTitile = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 6f);

    Font fontRoadape = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 8f);
    Font fontRoadapeP = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 6f);
    Font fontRoadapeB = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 8f);
    Font fontRoadapeBU = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 8f,
            Font.UNDEFINED);

    Font fontCabecalhoN = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED,
            9.5f);/*from  w w w . j  av a 2s . c o m*/
    Font fontCorpoNG = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 9.5f);
    Font fontCabecalhoNG = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 16f,
            Font.UNDERLINE);

    OutputStream outputStraem;
    try {
        SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy hh.mm.ss");
        SimpleDateFormat sdfTitile = new SimpleDateFormat("dd-MM-yyyy");
        Document documento = new Document();
        documento.setPageSize(PageSize.A4.rotate());
        documento.setMargins(10f, 10f, 35f, 20f);

        File ff = new File(ConfigDoc.Fontes.getDiretorio() + "/" + user + "/Seguro Viagem/");
        ff.mkdirs();

        String Ddata = sdf.format(new Date());

        ff = new File(ff.getAbsoluteFile() + "/" + "Export Mapa Viagem Semanal " + Ddata + ".pdf");
        String reString = "../Documentos/" + user + "/Seguro Viagem/" + "Export Mapa Viagem Semanal " + Ddata
                + ".pdf";
        outputStraem = new FileOutputStream(ff);

        PdfWriter writer = PdfWriter.getInstance(documento, outputStraem);

        PdfPTable tableDados = new PdfPTable(
                new float[] { 5f, 10.6f, 5f, 5f, 4.6f, 19f, 5.6f, 6f, 10.6f, 9.6f, 7f, 5.5f, 5.5f });
        tableDados.setWidthPercentage(100f);

        BaseColor colorCinza = new BaseColor(129, 138, 145);

        for (int j = 0; j < 13; j++) {
            PdfPCell cellTitileTable = new PdfPCell(new Phrase(titileTable(j), fontTableTitile));
            cellTitileTable.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
            cellTitileTable.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);

            cellTitileTable.setBackgroundColor(colorCinza);
            tableDados.addCell(cellTitileTable);
        }

        dataViagem(dataInicio, dateFim);

        float premiototal = 0;

        for (HashMap<String, Object> data : hasList) {
            tableDados.addCell(new Phrase(toString(data.get(DATA)), fontTableCorpo));
            tableDados.addCell(ExportViagemSemanaPdf
                    .cellEspecial(new PdfPCell(new Phrase(toString(data.get(NUMEROAPOLICE)), fontTableCorpo))));
            tableDados.addCell(
                    new Phrase(ConfigDoc.toFormat(toString(data.get(INICIO)), "dd-MM-yyyy", "yyyy-MM-dd"),
                            fontTableCorpo));
            tableDados.addCell(new Phrase(
                    ConfigDoc.toFormat(toString(data.get(FIM)), "dd-MM-yyyy", "yyyy-MM-dd"), fontTableCorpo));

            premiototal += toFloat(data.get(PREMIO));

            PdfPCell cellRigh = new PdfPCell(
                    new Phrase(ConfigDoc.toMoeda(toFloat(data.get(PREMIO)), ""), fontTableCorpo));
            cellRigh.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
            tableDados.addCell(cellRigh);

            tableDados.addCell(new Phrase(toString(data.get(CLIENTE)), fontTableCorpo));
            tableDados.addCell(new Phrase(toString(data.get(DATANASCIMENTO)), fontTableCorpo));
            tableDados.addCell(new Phrase(toString(data.get(TELEFONE)), fontTableCorpo));
            tableDados.addCell(new Phrase(toString(data.get(ENDERECO)), fontTableCorpo));
            tableDados.addCell(new Phrase(toString(data.get(LOCALNASCIMENTO)), fontTableCorpo));
            tableDados.addCell(new Phrase(toString(data.get(PAISDESTINO)), fontTableCorpo));
            tableDados.addCell(new Phrase(toString(data.get(CIDADEDESTINO)), fontTableCorpo));
            tableDados.addCell(new Phrase(toString(data.get(ZONADESTINO)), fontTableCorpo));
        }

        PdfPCell cellTotal = new PdfPCell(ExportViagemSemanaPdf.cellEspecial(new PdfPCell(
                new Phrase("AL AMOUNT..........................................", fontTableTitile))));
        cellTotal.setColspan(4);
        cellTotal.setPadding(1.5f);
        cellTotal.setBackgroundColor(colorCinza);
        tableDados.addCell(cellTotal);

        cellTotal = new PdfPCell(ExportViagemSemanaPdf
                .cellEspecial(new PdfPCell(new Phrase(ConfigDoc.toMoeda(premiototal, ""), fontTableTitile))));
        cellTotal.setPadding(1.5f);
        cellTotal.setBackgroundColor(colorCinza);
        tableDados.addCell(cellTotal);

        cellTotal = new PdfPCell(
                ExportViagemSemanaPdf.cellEspecial(new PdfPCell(new Phrase(" ", fontTableTitile))));
        cellTotal.setColspan(8);
        cellTotal.setPadding(1.5f);
        cellTotal.setBackgroundColor(colorCinza);
        tableDados.addCell(cellTotal);

        PdfPTable pTableEmpresaPricipal = new PdfPTable(new float[] { 15f, 85f });
        PdfPTable pTableEmpresaInforImpres1 = new PdfPTable(1);
        PdfPTable pTableEmpresaInforImpres5 = new PdfPTable(1);

        PdfPCell pCellNomeEmpresa = new PdfPCell(new Phrase(ConfigDoc.Empresa.NOME, fontCabecalhoNG));
        pCellNomeEmpresa.setBorder(0);
        PdfPCell pCellNomeEndereco = new PdfPCell(new Phrase(ConfigDoc.Empresa.ENDERECO, fontCabecalhoN));
        pCellNomeEndereco.setBorder(0);
        PdfPCell pCellCaixaPostal = new PdfPCell(new Phrase(ConfigDoc.Empresa.CAIXAPOSTAL, fontCabecalhoN));
        pCellCaixaPostal.setBorder(0);
        PdfPCell pCellTeleFax = new PdfPCell(
                new Phrase(ConfigDoc.Empresa.TELEFAX + " " + ConfigDoc.Empresa.EMAIL, fontCabecalhoN));
        pCellTeleFax.setBorder(0);
        PdfPCell pCellSociedade = new PdfPCell(new Phrase(ConfigDoc.Empresa.SOCIEDADE, fontCabecalhoN));
        pCellSociedade.setBorder(0);
        Image imageEmpresa = Image.getInstance("logo.png");
        imageEmpresa.scaleToFit(120f, 85f);
        pTableEmpresaInforImpres1.addCell(pCellNomeEmpresa);
        pTableEmpresaInforImpres1.addCell(pCellNomeEndereco);
        pTableEmpresaInforImpres1.addCell(pCellCaixaPostal);
        pTableEmpresaInforImpres1.addCell(pCellTeleFax);
        pTableEmpresaInforImpres1.addCell(pCellSociedade);
        PdfPCell cellTabela3 = new PdfPCell(pTableEmpresaInforImpres1);
        cellTabela3.setBorder(0);
        pTableEmpresaInforImpres5.addCell(cellTabela3);
        PdfPCell cellTabela5 = new PdfPCell(pTableEmpresaInforImpres5);
        cellTabela5.setBorder(0);
        PdfPCell cellTabela6 = new PdfPCell(imageEmpresa);
        cellTabela6.setBorder(0);
        pTableEmpresaPricipal.setWidthPercentage(95);
        pTableEmpresaPricipal.addCell(cellTabela6);
        pTableEmpresaPricipal.addCell(cellTabela5);

        PdfPTable pTableTitulo = new PdfPTable(1);
        pTableTitulo.setHorizontalAlignment(Element.ALIGN_CENTER);
        pTableTitulo.setWidthPercentage(100);

        PdfPCell cellTitulo = new PdfPCell(new Phrase("RLELATORIO SEMANAL NO. " + "" + "\n"
                + ((dataInicio != null) ? sdfTitile.format(dataInicio) + " - " : "")
                + ((dateFim != null) ? sdfTitile.format(dateFim) : ""), fontCorpoNG));
        cellTitulo.setBorder(0);
        cellTitulo.setPaddingBottom(20f);
        cellTitulo.setPaddingTop(10f);
        cellTitulo.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        pTableTitulo.addCell(cellTitulo);

        pTableEmpresaPricipal.setHorizontalAlignment(Element.ALIGN_CENTER);

        PdfPTable pTableRodape = new PdfPTable(new float[] { 50f, 50f });
        pTableRodape.setWidthPercentage(90f);

        PdfPCell cellRodape = new PdfPCell(new Phrase("DEPARTAMENTO FINANCEIRO", fontRoadapeBU));
        cellRodape.setBorder(0);
        cellRodape.setColspan(2);
        cellRodape.setPaddingTop(20f);
        pTableRodape.addCell(cellRodape);

        cellRodape = new PdfPCell(new Phrase("QUEIRA POR FAVOR CONFERIR OS PAGAMENTOS", fontRoadape));
        cellRodape.setColspan(2);
        cellRodape.setBorder(0);
        pTableRodape.addCell(cellRodape);

        cellRodape = new PdfPCell(new Phrase("ELABORADO POR", fontRoadapeB));
        cellRodape.setBorder(0);
        pTableRodape.addCell(cellRodape);
        cellRodape = new PdfPCell(new Phrase("VENFICADO POR", fontRoadapeB));
        cellRodape.setBorder(0);
        cellRodape.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
        pTableRodape.addCell(cellRodape);

        cellRodape = new PdfPCell(new Phrase("................................................", fontRoadape));
        cellRodape.setBorder(0);
        cellRodape.setPaddingTop(30f);
        pTableRodape.addCell(cellRodape);
        cellRodape = new PdfPCell(new Phrase("................................................", fontRoadape));
        cellRodape.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
        cellRodape.setBorder(0);
        cellRodape.setPaddingTop(30f);
        pTableRodape.addCell(cellRodape);

        cellRodape = new PdfPCell(new Phrase(nomeFuncinario, fontRoadapeP));
        cellRodape.setColspan(2);
        cellRodape.setBorder(0);
        pTableRodape.addCell(cellRodape);

        documento.open();
        documento.add(pTableEmpresaPricipal);
        documento.add(pTableTitulo);
        documento.add(tableDados);
        documento.add(pTableRodape);
        documento.close();

        RequestContext.getCurrentInstance().execute("openAllDocument('" + reString + "')");

    } catch (FileNotFoundException | DocumentException ex) {
        Logger.getLogger(ExportViagemSemanaPdf.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException ex) {
        Logger.getLogger(ExportViagemSemanaPdf.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:fc.extensions.itext.Writer.java

License:MIT License

private Font getFont(int fontSize) {
    if (!fontMap.containsKey(fontSize)) {
        fontMap.put(fontSize, new Font(baseFont, fontSize, Font.UNDEFINED, baseColor));
    }// w  ww  .  j  a v  a  2  s . c om
    return fontMap.get(fontSize);
}

From source file:fc.extensions.itext.Writer.java

License:MIT License

private Font getAnsiFont(int fontSize) {
    if (!ansiFontMap.containsKey(fontSize)) {
        ansiFontMap.put(fontSize, new Font(engBaseFont, fontSize, Font.UNDEFINED, baseColor));
    }//ww w.  ja  v  a 2 s .  c  om
    return ansiFontMap.get(fontSize);
}