Example usage for com.lowagie.text Font DEFAULTSIZE

List of usage examples for com.lowagie.text Font DEFAULTSIZE

Introduction

In this page you can find the example usage for com.lowagie.text Font DEFAULTSIZE.

Prototype

int DEFAULTSIZE

To view the source code for com.lowagie.text Font DEFAULTSIZE.

Click Source Link

Document

the value of the default size.

Usage

From source file:br.org.acessobrasil.silvinha.util.GeraRelatorioPDF.java

License:Open Source License

public static boolean geraRelatorio(File file) {
    TradGeraRelatorioPDF.carregaTexto(TokenLang.LANG);
    Document document = new Document(PageSize.A4);
    try {//from www .  j a v  a  2 s .c  o  m
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(file));
        writer.setPageEvent(new HeaderAndFooter());
        document.open();
        int linha = 0, j, tot_pg = ResumoDoRelatorio.getTotPage();
        //calcula o total de htmls
        float tot_link = 0.0f;
        for (j = 1; j <= tot_pg; j++) {
            String conteudo = ResumoDoRelatorio.getPage(j);
            String arr[] = conteudo.split("\n");
            tot_link += arr.length;
        }
        PainelStatusBar.showProgTarReq();
        //loop por todas as pginas da paginacao
        for (j = 1; j <= tot_pg; j++) {
            String conteudo = ResumoDoRelatorio.getPage(j);
            String arr[] = conteudo.split("\n");
            int tot = arr.length;
            int i;
            //loop por todos os links
            for (i = 0; i < tot; i++) {
                progresso = (linha++ / tot_link) * 100.0f;
                PainelStatusBar.setValueProgress((int) progresso);
                String arr2[] = arr[i].split("\t");

                if (arr2.length == 8) {

                    String strUrl = arr2[7];// URL
                    /*
                    int ap1 = Integer.parseInt(arr2[4]);// Aviso1
                    int ep1 = Integer.parseInt(arr2[1]);// Erro1
                    int ap2 = Integer.parseInt(arr2[5]);// Aviso2
                    int ep2 = Integer.parseInt(arr2[2]);// Erro2
                    int ap3 = Integer.parseInt(arr2[6]);// Aviso3
                    int ep3 = Integer.parseInt(arr2[3]);// Erro3
                    */
                    String myHash = arr2[0];

                    RelatorioDaUrl relatorio = new RelatorioDaUrl();
                    relatorio.recarregaArquivoRelatorioEmXml2(myHash);

                    document.add(new Phrase("\n"));
                    Font font = FontFactory.getFont(FontFactory.HELVETICA, Font.DEFAULTSIZE, Font.BOLD);

                    Chunk url = new Chunk(strUrl, font);
                    Paragraph p1 = new Paragraph(TradGeraRelatorioPDF.RELATORIO_URL);
                    p1.add(url);
                    p1.setAlignment(Paragraph.ALIGN_LEFT);
                    document.add(p1);
                    document.add(new Phrase("\n\n"));

                    if (relatorio.getErrosPrioridade1() <= 0 && relatorio.getErrosPrioridade2() <= 0
                            && relatorio.getErrosPrioridade3() <= 0) {
                        Paragraph p2 = new Paragraph(TradGeraRelatorioPDF.PAGINAS_SEM_ERROS);
                        p2.setAlignment(Paragraph.ALIGN_CENTER);
                        document.add(p2);

                    } else {

                        if (relatorio.getErrosPrioridade1() > 0) {
                            Paragraph p = new Paragraph(TradGeraRelatorioPDF.ERROS_P1, font);
                            p1.setAlignment(Paragraph.ALIGN_LEFT);
                            document.add(p);
                            document.add(new Chunk("\n"));
                            PdfPTable table = geraLista(relatorio.getListaErrosP1());
                            if (table != null) {
                                document.add(table);
                            }
                            document.add(new Phrase("\n\n"));
                        }

                        if (relatorio.getErrosPrioridade2() > 0) {
                            Paragraph p = new Paragraph(TradGeraRelatorioPDF.ERROS_P2, font);
                            p1.setAlignment(Paragraph.ALIGN_LEFT);
                            document.add(p);
                            document.add(new Chunk("\n"));
                            PdfPTable table = geraLista(relatorio.getListaErrosP2());
                            if (table != null) {
                                document.add(table);
                            }
                            document.add(new Phrase("\n\n"));
                        }

                        if (relatorio.getErrosPrioridade3() > 0) {
                            Paragraph p = new Paragraph(TradGeraRelatorioPDF.ERROS_P3, font);
                            p1.setAlignment(Paragraph.ALIGN_LEFT);
                            document.add(p);
                            document.add(new Chunk("\n"));
                            PdfPTable table = geraLista(relatorio.getListaErrosP3());
                            if (table != null) {
                                document.add(table);
                            }
                            document.add(new Phrase("\n\n"));
                        }
                        document.newPage();
                    }
                }
            }
        }
        writer.flush();
        document.close();
    } catch (DocumentException de) {
        log.error(de.getMessage(), de);
        PainelStatusBar.hideProgTarReq();
        return false;
    } catch (IOException ioe) {
        log.error(ioe.getMessage(), ioe);
        PainelStatusBar.hideProgTarReq();
        return false;
    }
    PainelStatusBar.hideProgTarReq();
    return true;
}

From source file:br.org.acessobrasil.silvinha.util.GeraRelatorioPDF.java

License:Open Source License

public static boolean geraRelatorio_bkp(File file, ResumoDoRelatorio resumo) {

    Document document = new Document(PageSize.A4);
    try {/*from  w ww  .j a  va  2  s  .c o  m*/
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(file));
        writer.setPageEvent(new HeaderAndFooter());
        document.open();

        ArrayList<RelatorioDaUrl> relatorios = resumo.getRelatorios();
        loop: for (RelatorioDaUrl relatorio : relatorios) {
            document.add(new Phrase("\n"));
            Font font = FontFactory.getFont(FontFactory.HELVETICA, Font.DEFAULTSIZE, Font.BOLD);

            Chunk url = new Chunk(relatorio.getUrl(), font);
            Paragraph p1 = new Paragraph(TradGeraRelatorioPDF.RELATORIO_URL);
            p1.add(url);
            p1.setAlignment(Paragraph.ALIGN_LEFT);
            document.add(p1);
            document.add(new Phrase("\n\n"));

            if (relatorio.getErrosPrioridade1() <= 0 && relatorio.getErrosPrioridade2() <= 0
                    && relatorio.getErrosPrioridade3() <= 0) {
                Paragraph p2 = new Paragraph(TradGeraRelatorioPDF.PAGINAS_SEM_ERROS);
                p2.setAlignment(Paragraph.ALIGN_CENTER);
                document.add(p2);
                continue loop;
            }

            if (relatorio.getErrosPrioridade1() > 0) {
                Paragraph p = new Paragraph(TradGeraRelatorioPDF.ERROS_P1_SEM_TAB, font);
                p1.setAlignment(Paragraph.ALIGN_LEFT);
                document.add(p);
                document.add(new Chunk("\n"));
                PdfPTable table = geraLista(relatorio.getListaErrosP1());
                if (table != null) {
                    document.add(table);
                }
                document.add(new Phrase("\n\n"));
            }

            if (relatorio.getErrosPrioridade2() > 0) {
                Paragraph p = new Paragraph(TradGeraRelatorioPDF.ERROS_P2_SEM_TAB, font);
                p1.setAlignment(Paragraph.ALIGN_LEFT);
                document.add(p);
                document.add(new Chunk("\n"));
                PdfPTable table = geraLista(relatorio.getListaErrosP2());
                if (table != null) {
                    document.add(table);
                }
                document.add(new Phrase("\n\n"));
            }

            if (relatorio.getErrosPrioridade3() > 0) {
                Paragraph p = new Paragraph(TradGeraRelatorioPDF.ERROS_P3_SEM_TAB, font);
                p1.setAlignment(Paragraph.ALIGN_LEFT);
                document.add(p);
                document.add(new Chunk("\n"));
                PdfPTable table = geraLista(relatorio.getListaErrosP3());
                if (table != null) {
                    document.add(table);
                }
                document.add(new Phrase("\n\n"));
            }
            document.newPage();
        }

        writer.flush();
        document.close();
    } catch (DocumentException de) {
        log.error(de.getMessage(), de);
        return false;
    } catch (IOException ioe) {
        log.error(ioe.getMessage(), ioe);
        return false;
    }
    return true;
}

From source file:com.bytecode.customexporter.PDFCustomExporter.java

@Override
public void export(ActionEvent event, String tableId, FacesContext context, String filename, String tableTitle,
        boolean pageOnly, boolean selectionOnly, String encodingType, MethodExpression preProcessor,
        MethodExpression postProcessor, boolean subTable) throws IOException {
    try {// www.j  a  v a  2 s  .  c  o m
        Document document = new Document();
        if (orientation.equalsIgnoreCase("Landscape"))
            document.setPageSize(PageSize.A4.rotate());
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        PdfWriter.getInstance(document, baos);
        StringTokenizer st = new StringTokenizer(tableId, ",");
        while (st.hasMoreElements()) {
            String tableName = (String) st.nextElement();
            UIComponent component = SearchExpressionFacade.resolveComponent(context, event.getComponent(),
                    tableName);
            if (component == null) {
                throw new FacesException("Cannot find component \"" + tableName + "\" in view.");
            }
            if (!(component instanceof DataTable || component instanceof DataList)) {
                throw new FacesException("Unsupported datasource target:\"" + component.getClass().getName()
                        + "\", exporter must target a PrimeFaces DataTable/DataList.");
            }

            if (preProcessor != null) {
                preProcessor.invoke(context.getELContext(), new Object[] { document });
            }

            if (!document.isOpen()) {
                document.open();
            }
            if (tableTitle != null && !tableTitle.isEmpty() && !tableId.contains("" + ",")) {

                Font tableTitleFont = FontFactory.getFont(FontFactory.TIMES, encodingType, Font.DEFAULTSIZE,
                        Font.BOLD);
                Paragraph title = new Paragraph(tableTitle, tableTitleFont);
                document.add(title);

                Paragraph preface = new Paragraph();
                addEmptyLine(preface, 3);
                document.add(preface);
            }
            PdfPTable pdf;
            DataList list = null;
            DataTable table = null;
            if (component instanceof DataList) {
                list = (DataList) component;
                pdf = exportPDFTable(context, list, pageOnly, encodingType);
            } else {
                table = (DataTable) component;
                pdf = exportPDFTable(context, table, pageOnly, selectionOnly, encodingType, subTable);
            }

            if (pdf != null) {
                document.add(pdf);
            }
            // add a couple of blank lines
            Paragraph preface = new Paragraph();
            addEmptyLine(preface, datasetPadding);
            document.add(preface);

            if (postProcessor != null) {
                postProcessor.invoke(context.getELContext(), new Object[] { document });
            }
        }
        document.close();

        writePDFToResponse(context.getExternalContext(), baos, filename);

    } catch (DocumentException e) {
        throw new IOException(e.getMessage());
    }
}

From source file:com.bytecode.customexporter.PDFCustomExporter.java

protected void createCustomFonts(String encoding) {

    if (fontName != null && FontFactory.getFont(fontName).getBaseFont() != null) {
        this.cellFont = FontFactory.getFont(fontName, encoding);
        this.facetFont = FontFactory.getFont(fontName, encoding, Font.DEFAULTSIZE, Font.BOLD);
    } else {//from   ww  w  .ja  va 2s. c  om
        this.cellFont = FontFactory.getFont(FontFactory.TIMES, encoding);
        this.facetFont = FontFactory.getFont(FontFactory.TIMES, encoding, Font.DEFAULTSIZE, Font.BOLD);
    }
    if (facetFontColor != null) {
        this.facetFont.setColor(facetFontColor);
    }
    if (facetFontSize != null) {
        this.facetFont.setSize(facetFontSize);
    }
    if (facetFontStyle != null) {
        this.facetFont.setStyle(facetFontStyle);
    }
    if (cellFontColor != null) {
        this.cellFont.setColor(cellFontColor);
    }
    if (cellFontSize != null) {
        this.cellFont.setSize(cellFontSize);
    }
    if (cellFontStyle != null) {
        this.cellFont.setStyle(cellFontStyle);
    }
}

From source file:com.crm.webapp.util.PDFCustomExporter.java

License:Apache License

@Override
public void export(ActionEvent event, String tableId, FacesContext context, String filename, String tableTitle,
        boolean pageOnly, boolean selectionOnly, String encodingType, MethodExpression preProcessor,
        MethodExpression postProcessor, boolean subTable) throws IOException {
    try {//from w ww. j  a  va 2 s. c  om
        Document document = new Document();
        if (orientation.equalsIgnoreCase("Landscape")) {
            document.setPageSize(PageSize.A4.rotate());
        }

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        PdfWriter.getInstance(document, baos);
        StringTokenizer st = new StringTokenizer(tableId, ",");
        while (st.hasMoreElements()) {
            String tableName = (String) st.nextElement();
            UIComponent component = SearchExpressionFacade.resolveComponent(context, event.getComponent(),
                    tableName);
            if (component == null) {
                throw new FacesException("Cannot find component \"" + tableName + "\" in view.");
            }

            if (!(component instanceof DataTable || component instanceof DataList)) {
                throw new FacesException("Unsupported datasource target:\"" + component.getClass().getName()
                        + "\", exporter must target a PrimeFaces DataTable/DataList.");
            }

            if (preProcessor != null) {
                preProcessor.invoke(context.getELContext(), new Object[] { document });
            }

            if (!document.isOpen()) {
                document.open();
            }

            if (tableTitle != null && !tableTitle.isEmpty() && !tableId.contains("" + ",")) {
                Font tableTitleFont = FontFactory.getFont(FontFactory.TIMES, encodingType, Font.DEFAULTSIZE,
                        Font.BOLD);
                Paragraph title = new Paragraph(tableTitle, tableTitleFont);
                document.add(title);

                Paragraph preface = new Paragraph();
                addEmptyLine(preface, 3);
                document.add(preface);
            }

            PdfPTable pdf;
            DataList list = null;
            DataTable table = null;
            if (component instanceof DataList) {
                list = (DataList) component;
                pdf = exportPDFTable(context, list, pageOnly, encodingType);
            } else {
                table = (DataTable) component;
                pdf = exportPDFTable(context, table, pageOnly, selectionOnly, encodingType, subTable);
            }

            if (pdf != null) {
                document.add(pdf);
            }

            // add a couple of blank lines
            Paragraph preface = new Paragraph();
            addEmptyLine(preface, datasetPadding);
            document.add(preface);

            if (postProcessor != null) {
                postProcessor.invoke(context.getELContext(), new Object[] { document });
            }
        }

        document.close();

        writePDFToResponse(context.getExternalContext(), baos, filename);
    } catch (DocumentException e) {
        throw new IOException(e.getMessage());
    }
}

From source file:com.crm.webapp.util.PDFCustomExporter.java

License:Apache License

protected void createCustomFonts(String encoding) {
    this.cellFont = FontFactory.getFont(FontFactory.TIMES, encoding);
    this.facetFont = FontFactory.getFont(FontFactory.TIMES, encoding, Font.DEFAULTSIZE, Font.BOLD);
    if (facetFontColor != null) {
        this.facetFont.setColor(facetFontColor);
    }/*from  www  . j  a va  2s  . c  o m*/

    if (facetFontSize != null) {
        this.facetFont.setSize(facetFontSize);
    }

    if (facetFontStyle != null) {
        this.facetFont.setStyle(facetFontStyle);
    }

    if (cellFontColor != null) {
        this.cellFont.setColor(cellFontColor);
    }

    if (cellFontSize != null) {
        this.cellFont.setSize(cellFontSize);
    }

    if (cellFontStyle != null) {
        this.cellFont.setStyle(cellFontStyle);
    }

    if (fontName != null) {
        cellFont.setFamily(fontName);
        facetFont.setFamily(fontName);
    }
}

From source file:com.stratelia.webactiv.kmelia.control.Callback.java

License:Open Source License

@Override
public void handleStartTag(Tag t, MutableAttributeSet a, int pos) throws KmeliaRuntimeException {
    SilverTrace.info("kmelia", "Callback.handleStartTag", "root.MSG_ENTRY_METHOD", "t = " + t.toString());
    if (TABLE.equals(t)) {
        try {/*from w  ww . ja  v  a 2s  . c  o  m*/
            tbl = new Table(Integer.parseInt(columns.get(++current_table)));
            tbl.setBorderWidth(0);
            tbl.setAlignment(Element.ALIGN_LEFT);
            attribute = a.getAttribute(Attribute.WIDTH);
            if (attribute != null) {
                attribute_value = attribute.toString();
                if ("%".equals(attribute_value.substring(attribute_value.length() - 1))) {
                    tbl.setWidth(
                            (Integer.parseInt(attribute_value.substring(0, attribute_value.length() - 1))));
                }
            }
            attribute = a.getAttribute(Attribute.CELLPADDING);
            if (attribute != null) {
                attribute_value = attribute.toString();
                tbl.setSpacing(Integer.parseInt(attribute_value));
            }
            attribute = a.getAttribute(Attribute.CELLSPACING);
            if (attribute != null) {
                attribute_value = attribute.toString();
                tbl.setPadding(Integer.parseInt(attribute_value));
            }
        } catch (Exception ex) {
            throw new KmeliaRuntimeException("Callback.handleStartTag", SilverpeasRuntimeException.WARNING,
                    "kmelia.EX_CANNOT_SHOW_PDF_GENERATION", ex);
        }
    } else if (TD.equals(t)) {
        try {
            if (cl == null) {
                cl = new Cell();
                cl.setBorderWidth(0);
            }
            is_was_text = false;
        } catch (Exception ex) {
            throw new KmeliaRuntimeException("Callback.handleStartTag", SilverpeasRuntimeException.WARNING,
                    "kmelia.EX_CANNOT_SHOW_PDF_GENERATION", ex);
        }
    } else if (H1.equals(t)) {
        font_size = Font.DEFAULTSIZE + 1;
    } else if (H2.equals(t)) {
        font_size = Font.DEFAULTSIZE + 2;
    } else if (H3.equals(t)) {
        font_size = Font.DEFAULTSIZE + 3;
    } else if (H4.equals(t)) {
        font_size = Font.DEFAULTSIZE + 4;
    } else if (H5.equals(t)) {
        font_size = Font.DEFAULTSIZE + 5;
    } else if (H6.equals(t)) {
        font_size = Font.DEFAULTSIZE + 6;
    } else if (FONT.equals(t)) {
        attribute = a.getAttribute(Attribute.SIZE);
        if (attribute != null) {
            font_size = Integer.parseInt(attribute.toString()) + Font.DEFAULTSIZE - 1;
        }
    } else if (t.equals(B)) {
        font_properties = font_properties | Font.BOLD;
    } else if (t.equals(I)) {
        font_properties = font_properties | Font.ITALIC;
    } else if (t.equals(U)) {
        // current PDF package doesn't support it
    }
}

From source file:desktopbugtracker.export.PdfFont.java

License:Open Source License

public static Font bold() {
    return new Font(Font.HELVETICA, Font.DEFAULTSIZE, Font.BOLD);
}

From source file:ec.edu.chyc.manejopersonal.managebean.PDFCustomExporter.java

License:Apache License

@Override
public void export(ActionEvent event, String tableId, FacesContext context, String filename, String tableTitle,
        boolean pageOnly, boolean selectionOnly, String encodingType, MethodExpression preProcessor,
        MethodExpression postProcessor, boolean subTable) throws IOException {
    try {//w  w  w  .j  av a2 s . c  om
        Document document = new Document();
        if (orientation.equalsIgnoreCase("Landscape")) {
            document.setPageSize(PageSize.A4.rotate());
        }
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        PdfWriter.getInstance(document, baos);
        StringTokenizer st = new StringTokenizer(tableId, ",");
        while (st.hasMoreElements()) {
            String tableName = (String) st.nextElement();
            UIComponent component = SearchExpressionFacade.resolveComponent(context, event.getComponent(),
                    tableName);
            if (component == null) {
                throw new FacesException("Cannot find component \"" + tableName + "\" in view.");
            }
            if (!(component instanceof DataTable || component instanceof DataList)) {
                throw new FacesException("Unsupported datasource target:\"" + component.getClass().getName()
                        + "\", exporter must target a PrimeFaces DataTable/DataList.");
            }

            if (preProcessor != null) {
                preProcessor.invoke(context.getELContext(), new Object[] { document });
            }

            if (!document.isOpen()) {
                document.open();
            }
            if (tableTitle != null && !tableTitle.isEmpty() && !tableId.contains("" + ",")) {

                Font tableTitleFont = FontFactory.getFont(FontFactory.TIMES, encodingType, Font.DEFAULTSIZE,
                        Font.BOLD);
                Paragraph title = new Paragraph(tableTitle, tableTitleFont);
                document.add(title);

                Paragraph preface = new Paragraph();
                addEmptyLine(preface, 3);
                document.add(preface);
            }
            PdfPTable pdf;
            DataList list = null;
            DataTable table = null;
            if (component instanceof DataList) {
                list = (DataList) component;
                pdf = exportPDFTable(context, list, pageOnly, encodingType);
            } else {
                table = (DataTable) component;
                pdf = exportPDFTable(context, table, pageOnly, selectionOnly, encodingType, subTable);
            }

            if (pdf != null) {
                document.add(pdf);
            }
            // add a couple of blank lines
            Paragraph preface = new Paragraph();
            addEmptyLine(preface, datasetPadding);
            document.add(preface);

            if (postProcessor != null) {
                postProcessor.invoke(context.getELContext(), new Object[] { document });
            }
        }
        document.close();

        writePDFToResponse(context.getExternalContext(), baos, filename);

    } catch (DocumentException e) {
        throw new IOException(e.getMessage());
    }
}

From source file:ec.edu.chyc.manejopersonal.managebean.PDFCustomExporter.java

License:Apache License

protected void createCustomFonts(String encoding) {

    if (fontName != null && FontFactory.getFont(fontName).getBaseFont() != null) {
        this.cellFont = FontFactory.getFont(fontName, encoding);
        this.facetFont = FontFactory.getFont(fontName, encoding, Font.DEFAULTSIZE, Font.BOLD);
    } else {/*from  ww  w  . java  2s  .  com*/
        this.cellFont = FontFactory.getFont(FontFactory.HELVETICA, encoding);
        this.facetFont = FontFactory.getFont(FontFactory.HELVETICA, encoding, Font.DEFAULTSIZE, Font.BOLD);
    }
    if (facetFontColor != null) {
        this.facetFont.setColor(facetFontColor);
    }
    if (facetFontSize != null) {
        this.facetFont.setSize(facetFontSize);
    }
    if (facetFontStyle != null) {
        this.facetFont.setStyle(facetFontStyle);
    }
    if (cellFontColor != null) {
        this.cellFont.setColor(cellFontColor);
    }
    if (cellFontSize != null) {
        this.cellFont.setSize(cellFontSize);
    }
    if (cellFontStyle != null) {
        this.cellFont.setStyle(cellFontStyle);
    }
}