Example usage for com.itextpdf.text Image setAlignment

List of usage examples for com.itextpdf.text Image setAlignment

Introduction

In this page you can find the example usage for com.itextpdf.text Image setAlignment.

Prototype


public void setAlignment(final int alignment) 

Source Link

Document

Sets the alignment for the image.

Usage

From source file:utils.pdf.cv_templates.Template1.java

private void addImageLine5() throws DocumentException, IOException {
    Image line_img;
    line_img = Image// w ww. j ava2 s.c  o m
            .getInstance(String.format("public/images/orientation/cv-templates/CV1/ic_barra_lineas3.png"));
    line_img.setAbsolutePosition(40, 550);
    line_img.setAlignment(Image.LEFT | Image.TEXTWRAP);
    line_img.setBorder(Image.BOX);
    line_img.setBorderWidth(10);
    line_img.setBorderColor(BaseColor.WHITE);
    line_img.scaleToFit(1000, 100);
    document.add(line_img);
}

From source file:utils.pdf.cv_templates.Template3.java

private void addLineImage() throws DocumentException, IOException {
    Image short_line_img = Image.getInstance(SHORT_LINE_IMAGE);
    short_line_img.setAbsolutePosition(213, 756);
    short_line_img.setAlignment(Image.MIDDLE | Image.TEXTWRAP);
    short_line_img.setBorderWidth(10);
    short_line_img.setBorderColor(BaseColor.WHITE);
    short_line_img.scaleToFit(300, 55);
    document.add(short_line_img);
}

From source file:utils.pdf.cv_templates.Template4.java

private void addImage(User user) throws DocumentException, IOException {
    Image photo_img;
    if (!user.photo.id.equals("")) {
        photo_img = Image/* w w w .java 2  s. c om*/
                .getInstance(String.format("https://s3.amazonaws.com/aunclickdelempleo2/" + user.photo.id));
    } else {
        photo_img = Image.getInstance(String.format("public/images/orientation/photo/ic_profile.png"));
    }

    photo_img.setAbsolutePosition(450, 690);
    photo_img.setAlignment(Image.LEFT | Image.TEXTWRAP);
    photo_img.setBorder(Image.BOX);
    photo_img.setBorderWidth(10);
    photo_img.setBorderColor(BaseColor.WHITE);
    photo_img.scaleToFit(1000, 115);
    document.add(photo_img);
}

From source file:View.TelaRelatorio.java

public void GerarEntrega(int codigo) throws IOException {
    NegociosCompra nc = new NegociosCompra();
    Compra compra = nc.ConsultarCompra(codigo);

    Document documentoPDF = new Document();
    String output = "C:\\Users\\Marilia Nayara\\Documents\\NetBeansProjects\\SistemaInformao\\Relatorios\\VendasEntrega\\Compra"
            + codigo + ".pdf";
    try {//  w  ww .ja v  a2s.c o  m

        PdfWriter.getInstance(documentoPDF, new FileOutputStream(output));

        documentoPDF.open();

        documentoPDF.setPageSize(PageSize.A4);

        Image imagem = Image.getInstance(
                "C:\\Users\\Marilia Nayara\\Documents\\NetBeansProjects\\SistemaInformao\\src\\View\\image.png");

        imagem.scaleToFit(100, 75);

        imagem.setAlignment(Element.ALIGN_CENTER);

        documentoPDF.add(imagem);

        Font fonte1 = new Font(Font.FontFamily.TIMES_ROMAN, 8, Font.BOLD);

        Paragraph agr = new Paragraph("Aplicao para Gesto de Restaurantes", fonte1);

        agr.setAlignment(Element.ALIGN_CENTER);

        documentoPDF.add(agr);

        Font fonte = new Font(Font.FontFamily.TIMES_ROMAN, 24, Font.BOLD);

        Paragraph cabecalho = new Paragraph("COMPRA ENTREGA", fonte);

        cabecalho.setAlignment(Element.ALIGN_CENTER);

        documentoPDF.add(cabecalho);

        documentoPDF.add(new Paragraph("\n"));

        Cliente c = new NegociosCliente().ProcurarCliente(compra.getCpf_c());

        Timestamp t = compra.getData();
        SimpleDateFormat formato = new SimpleDateFormat("dd/MM/yyyy");
        String a = formato.format(t);

        PdfPTable dadosC = new PdfPTable(new float[] { 0.10f, 0.70f, 0.20f });

        List<String> dados = new ArrayList<String>();

        dados.add("CODIGO DA COMPRA");
        dados.add("CLIENTE");
        dados.add("DATA DA COMPRA");
        dados.add("" + compra.getCodigo());
        dados.add(c.getNome());
        dados.add(a);

        for (String s : dados) {
            dadosC.addCell(s);
        }

        dadosC.setWidthPercentage(110f);
        documentoPDF.add(dadosC);

        documentoPDF.add(new Paragraph("\n"));
        /*documentoPDF.add(new Paragraph(" LISTA DE PRODUTOS COMPRADOS"));
        documentoPDF.add(new Paragraph("\n"));
        documentoPDF.add(new Paragraph("Codigo       Produto                                         Valor Unitrio          Quantidade             Valor   "));
        String tam = "Codigo       Produto                                         Valor Unitrio          Quantidade             Valor   ";
        JOptionPane.showMessageDialog(null, tam.length());
        for(int x=0;x<compra.getLista_prod().size();x++){
        Produto p = new NegociosProduto().ProcurarProduto(compra.getLista_prod().get(x).intValue());
        String cod = ""+p.getCodigo();
        String nome = p.getNome();
        float pv = p.getPvenda();
        String pvs = ""+pv;
        int quant = compra.getQuantidades().get(x).intValue();
        String squant = ""+quant;
        float pf = pv*quant;
        String spf = ""+pf;
                
        int espaco = 13 - cod.length();
        String esp = "";        
            for(int y = 0;y <espaco;y++){
                   esp=esp+" "; 
                }
        cod = cod+esp;
                    
        espaco = 49 - nome.length();
        esp = "";
            for(int y = 0;y <espaco;y++){
                   esp=esp+" "; 
            }
        nome = nome + esp;
                
        espaco = 24 - pvs.length();
        esp = "";
            for(int y = 0;y <espaco;y++){
                       esp=esp+" "; 
            }
        pvs = pvs + esp;
                
        espaco = 23 - squant.length();
        esp = "";
            for(int y = 0;y <espaco;y++){
                       esp=esp+" "; 
            }
        squant = squant + esp;
                
        espaco = 8 - spf.length();
        esp = "";
            for(int y = 0;y <espaco;y++){
                       esp=esp+" "; 
            }
        spf = spf + esp;
                
        String fina = cod+nome+pvs+squant+spf;
        //JOptionPane.showMessageDialog(null, fina.length());
        documentoPDF.add(new Paragraph(fina));
        }*/
        Font fonte3 = new Font(Font.FontFamily.TIMES_ROMAN, 14, Font.NORMAL);

        // Criando uma tabela com 3 colunas
        PdfPTable table = new PdfPTable(new float[] { 0.1f, 0.45f, 0.15f, 0.15f, 0.15f });

        table.setWidthPercentage(110.f);
        // Ttulo para a tabela
        Paragraph tableHeader = new Paragraph("LISTA DE PRODUTOS COMPRADOS", fonte3);

        PdfPCell header = new PdfPCell(tableHeader);
        // Definindo que o header vai ocupar as 3 colunas
        header.setColspan(5);
        // Definindo alinhamento do header
        header.setHorizontalAlignment(Paragraph.ALIGN_CENTER);
        // Adicionando o header  tabela
        table.addCell(header);

        List<String> list = new ArrayList<String>();

        list.add("CODIGO");
        list.add("PRODUTO");
        list.add("VALOR UNIT?RIO");
        list.add("QUANTIDADE");
        list.add("VALOR");

        for (int x = 0; x < compra.getLista_prod().size(); x++) {
            Produto p = new NegociosProduto().ProcurarProduto(compra.getLista_prod().get(x).intValue());
            String cod = "" + p.getCodigo();
            String nome = p.getNome();
            float pv = p.getPvenda();
            String pvs = "" + pv;
            int quant = compra.getQuantidades().get(x).intValue();
            String squant = "" + quant;
            float pf = pv * quant;
            String spf = "" + pf;
            list.add(cod);
            list.add(nome);
            list.add(pvs);
            list.add(squant);
            list.add(spf);
        }

        for (String s : list) {
            table.addCell(s);
        }

        documentoPDF.add(table);

        documentoPDF.add(new Paragraph("\n"));

        Paragraph total = new Paragraph("Total: " + compra.getPreco_final(), fonte3);

        total.setAlignment(Element.ALIGN_RIGHT);

        documentoPDF.add(total);

        documentoPDF.add(new Paragraph("\n"));

        PdfPTable endereco = new PdfPTable(new float[] { 0.30f, 0.80f });

        endereco.setWidthPercentage(60f);

        endereco.setHorizontalAlignment(Element.ALIGN_CENTER);

        Paragraph tableH = new Paragraph("ENDEREO DE ENTREGA", fonte3);

        PdfPCell hea = new PdfPCell(tableH);

        hea.setColspan(2);

        hea.setHorizontalAlignment(Paragraph.ALIGN_CENTER);

        endereco.addCell(hea);

        List<String> dadosE = new ArrayList<String>();

        dadosE.add("LOGRADOURO");
        dadosE.add(c.getEndereco().getRua());
        dadosE.add("NUMERO");
        dadosE.add("" + c.getEndereco().getNumero());
        dadosE.add("BAIRRO");
        dadosE.add(c.getEndereco().getBairro());
        dadosE.add("CIDADE");
        dadosE.add(c.getEndereco().getCidade());
        dadosE.add("ESTADO");
        dadosE.add(c.getEndereco().getEstado());

        for (String s : dadosE) {
            endereco.addCell(s);
        }

        documentoPDF.add(endereco);

        documentoPDF.add(new Paragraph("\n"));

        documentoPDF
                .add(new Paragraph("Assinatura:  __________________________________________________________"));

        Paragraph ass = new Paragraph("(" + c.getNome() + ")", fonte1);

        ass.setAlignment(Element.ALIGN_CENTER);
        documentoPDF.add(ass);

        documentoPDF.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));

        Paragraph comp = new Paragraph("COMPROVANTE DE ENTREGA");

        comp.setAlignment(Element.ALIGN_CENTER);

        documentoPDF.add(comp);

        documentoPDF.add(new Paragraph("\n"));

        documentoPDF.add(dadosC);

        documentoPDF.add(total);

        documentoPDF
                .add(new Paragraph("Assinatura:  __________________________________________________________"));

        documentoPDF.add(ass);

    } catch (DocumentException de) {
        de.printStackTrace();
    } catch (IOException ioe) {
        ioe.printStackTrace();
    } finally {
        documentoPDF.close();
        java.awt.Desktop.getDesktop().open(new File(output));
    }
}

From source file:View.TelaRelatorio.java

public void GerarVendidosSemana(String inicio, String Final)
        throws FileNotFoundException, BadElementException, IOException {
    NegocioRelatorio nr = new NegocioRelatorio();

    Document documentoPDF = new Document();
    String nome = inicio.toString();
    String comp = Final.toString();
    String output = "C:\\Users\\Marilia Nayara\\Documents\\NetBeansProjects\\SistemaInformao\\Relatorios\\MaisVendidos\\MVdia.pdf";
    try {//w w  w. ja  v  a  2 s .c o m

        PdfWriter.getInstance(documentoPDF, new FileOutputStream(output));

        documentoPDF.open();

        documentoPDF.setPageSize(PageSize.A4);

        Image imagem = Image.getInstance(
                "C:\\Users\\Marilia Nayara\\Documents\\NetBeansProjects\\SistemaInformao\\src\\View\\image.png");

        imagem.scaleToFit(100, 75);

        imagem.setAlignment(Element.ALIGN_CENTER);

        documentoPDF.add(imagem);

        Font fonte1 = new Font(Font.FontFamily.TIMES_ROMAN, 8, Font.BOLD);

        Paragraph agr = new Paragraph("Aplicao para Gesto de Restaurantes", fonte1);

        agr.setAlignment(Element.ALIGN_CENTER);

        documentoPDF.add(agr);

        Font fonte = new Font(Font.FontFamily.TIMES_ROMAN, 24, Font.BOLD);

        Paragraph cabecalho = new Paragraph("MAIS VENDIDAS DA SEMANA", fonte);

        cabecalho.setAlignment(Element.ALIGN_CENTER);

        documentoPDF.add(cabecalho);

        documentoPDF.add(new Paragraph("\n"));

        List<MaisVendidos> mv = nr.MaisVendidos(inicio, Final);

        System.out.println("voltou");
        SimpleDateFormat formato = new SimpleDateFormat("dd/MM/yyyy");
        List<Timestamp> gamb = new ArrayList<Timestamp>();
        String aux;
        String aux1;
        for (int j = 0; j < mv.size(); j++) {
            int gam = 0;
            Date d = new Date(mv.get(j).getData().getTime());
            aux = formato.format(d);

            for (int i = 0; i < gamb.size(); i++) {

                aux1 = formato.format(gamb.get(i).getTime());

                if (aux.equals(aux1)) {
                    gam = 1;
                    System.out.println("entroy aki");
                }
            }

            if (gam == 0) {
                gamb.add(mv.get(j).getData());
                System.out.println(j);
                String a = formato.format(mv.get(j).getData());
                Calendar cal = Calendar.getInstance();
                cal.setTime(mv.get(j).getData());//  ========> Objeto Date  
                int day = cal.get(Calendar.DAY_OF_WEEK);

                Paragraph dia = new Paragraph();
                if (day == 1) {
                    dia = new Paragraph("DOMINGO                      " + a);
                } else if (day == 2) {
                    dia = new Paragraph("SEGUNDA-FEIRA                     " + a);
                } else if (day == 3) {
                    dia = new Paragraph("TERA-FEIRA                     " + a);
                } else if (day == 4) {
                    dia = new Paragraph("QUARTA-FEIRA                     " + a);
                } else if (day == 5) {
                    dia = new Paragraph("QUINTA-FEIRA                     " + a);
                } else if (day == 6) {
                    dia = new Paragraph("SEXTA-FEIRA                     " + a);
                } else if (day == 7) {
                    dia = new Paragraph("SABADO                     " + a);
                }
                documentoPDF.add(dia);
                documentoPDF.add(new Paragraph("\n"));
                PdfPTable dadosC = new PdfPTable(new float[] { 0.30f, 0.50f, 0.15f, 0.15f });

                List<String> dados = new ArrayList<String>();

                dados.add("CATEGORIA");
                dados.add("PRODUTO");
                dados.add("QUANTIDADE");
                dados.add("VALOR");

                List<String> categorias = new ArrayList<String>();
                for (int x = 0; x < mv.size(); x++) {
                    String aux2 = formato.format(mv.get(x).getData().getTime());
                    int contc = 0;
                    System.out.println(aux);
                    System.out.println(aux2);
                    if (aux.equals(aux2)) {
                        Categoria c = new NegociosCategoria().ProcurarCategoria(mv.get(x).getIdent());
                        for (int k = 0; k < categorias.size(); k++) {
                            if (c.getNome().equals(categorias.get(k).toString())) {
                                contc = 1;
                            }
                        }
                        if (contc == 0) {
                            categorias.add(c.getNome());
                            dados.add(c.getNome());
                            Produto p = new NegociosProduto().ProcurarProduto(mv.get(x).getCodigo());
                            dados.add(p.getNome());
                            dados.add("" + mv.get(x).getQuantidade());
                            double valor = mv.get(x).getQuantidade() * mv.get(x).getPtotal();
                            dados.add("" + valor);
                        }
                    }
                }

                for (String s : dados) {
                    dadosC.addCell(s);
                }

                dadosC.setWidthPercentage(110f);
                documentoPDF.add(dadosC);
            }

        }
    } catch (DocumentException de) {
        de.printStackTrace();
    } catch (IOException ioe) {
        ioe.printStackTrace();
    } finally {
        documentoPDF.close();
        java.awt.Desktop.getDesktop().open(new File(output));
    }
}

From source file:View.TelaRelatorio.java

public void GerarEntregas() throws DocumentException, FileNotFoundException, BadElementException, IOException {
    NegocioRelatorio nr = new NegocioRelatorio();

    Document documentoPDF = new Document();
    String output = "C:\\Users\\Marilia Nayara\\Documents\\NetBeansProjects\\SistemaInformao\\Relatorios\\MaisVendidos\\EntregasRealizadas.pdf";
    try {// www.j  a v  a  2 s.  c  om

        PdfWriter.getInstance(documentoPDF, new FileOutputStream(output));

        documentoPDF.open();

        documentoPDF.setPageSize(PageSize.A4);

        Image imagem = Image.getInstance(
                "C:\\Users\\Marilia Nayara\\Documents\\NetBeansProjects\\SistemaInformao\\src\\View\\image.png");

        imagem.scaleToFit(100, 75);

        imagem.setAlignment(Element.ALIGN_CENTER);

        documentoPDF.add(imagem);

        Font fonte1 = new Font(Font.FontFamily.TIMES_ROMAN, 8, Font.BOLD);

        Paragraph agr = new Paragraph("Aplicao para Gesto de Restaurantes", fonte1);

        agr.setAlignment(Element.ALIGN_CENTER);

        documentoPDF.add(agr);

        Font fonte = new Font(Font.FontFamily.TIMES_ROMAN, 24, Font.BOLD);

        Paragraph cabecalho = new Paragraph("ENTREGAS REALIZADAS", fonte);

        cabecalho.setAlignment(Element.ALIGN_CENTER);

        documentoPDF.add(cabecalho);

        documentoPDF.add(new Paragraph("\n\n"));

        List<EntregasRealizadas> ER = nr.EntregasRealizadas();
        SimpleDateFormat formato = new SimpleDateFormat("dd/MM/yyyy");
        int d = 0, se = 0, te = 0, qa = 0, qi = 0, sex = 0, sa = 0;

        for (int x = 0; x < ER.size(); x++) {
            String a = formato.format(ER.get(x).getDatas());
            Calendar cal = Calendar.getInstance();
            cal.setTime(ER.get(x).getDatas());//  ========> Objeto Date  
            int day = cal.get(Calendar.DAY_OF_WEEK);

            if (day == 1) {
                d = d + ER.get(x).getQuant();
            } else if (day == 2) {
                se = se + ER.get(x).getQuant();
            } else if (day == 3) {
                te = te + ER.get(x).getQuant();
            } else if (day == 4) {
                qa = qa + ER.get(x).getQuant();
            } else if (day == 5) {
                qi = qi + ER.get(x).getQuant();
            } else if (day == 6) {
                sex = sex + ER.get(x).getQuant();
            } else if (day == 7) {
                sa = sa + ER.get(x).getQuant();
            }
        }

        PdfPTable dadosC = new PdfPTable(new float[] { 0.50f, 0.50f });

        List<String> dados = new ArrayList<String>();

        dados.add("DIA");
        dados.add("QUANTIDADE");
        dados.add("DOMINGO");
        dados.add("" + d);
        dados.add("SEGUNDA-FEIRA");
        dados.add("" + se);
        dados.add("TERA-FEIRA");
        dados.add("" + te);
        dados.add("QUARTA-FEIRA");
        dados.add("" + qa);
        dados.add("QUINTA-FEIRA");
        dados.add("" + qi);
        dados.add("SEXTA-FEIRA");
        dados.add("" + sex);
        dados.add("SABADO");
        dados.add("" + sa);

        for (String s : dados) {
            dadosC.addCell(s);
        }

        dadosC.setWidthPercentage(60f);
        dadosC.setHorizontalAlignment(Element.ALIGN_CENTER);
        documentoPDF.add(dadosC);

    } catch (DocumentException de) {
        de.printStackTrace();
    } finally {
        documentoPDF.close();
        java.awt.Desktop.getDesktop().open(new File(output));
    }
}

From source file:View.TelaRelatorio.java

public void EntregasPorLocalidade() {
    NegocioRelatorio nr = new NegocioRelatorio();

    Document documentoPDF = new Document();
    String output = "C:\\Users\\Marilia Nayara\\Documents\\NetBeansProjects\\SistemaInformao\\Relatorios\\MaisVendidos\\EntregasPorLocalidades.pdf";
    try {/*from w w  w.  j a  va 2  s .  c om*/

        PdfWriter.getInstance(documentoPDF, new FileOutputStream(output));

        documentoPDF.open();

        documentoPDF.setPageSize(PageSize.A4);

        Image imagem = Image.getInstance(
                "C:\\Users\\Marilia Nayara\\Documents\\NetBeansProjects\\SistemaInformao\\src\\View\\image.png");

        imagem.scaleToFit(100, 75);

        imagem.setAlignment(Element.ALIGN_CENTER);

        documentoPDF.add(imagem);

        Font fonte1 = new Font(Font.FontFamily.TIMES_ROMAN, 8, Font.BOLD);

        Paragraph agr = new Paragraph("Aplicao para Gesto de Restaurantes", fonte1);

        agr.setAlignment(Element.ALIGN_CENTER);

        documentoPDF.add(agr);

        Font fonte = new Font(Font.FontFamily.TIMES_ROMAN, 24, Font.BOLD);

        Paragraph cabecalho = new Paragraph("ENTREGAS POR LOCALIDADE", fonte);

        cabecalho.setAlignment(Element.ALIGN_CENTER);

        documentoPDF.add(cabecalho);

        documentoPDF.add(new Paragraph("\n\n"));

        List<Entrega> Entrega = nr.Localidades();

        PdfPTable dadosC = new PdfPTable(new float[] { 0.50f, 0.50f });

        List<String> dados = new ArrayList<String>();

        dados.add("BAIRRO");
        dados.add("TOTAL DE ENTREGAS");

        for (int x = 0; x < Entrega.size(); x++) {
            dados.add(Entrega.get(x).getDia());
            dados.add("" + Entrega.get(x).getQuant());
        }

        for (String s : dados) {
            dadosC.addCell(s);
        }

        dadosC.setWidthPercentage(100f);
        dadosC.setHorizontalAlignment(Element.ALIGN_CENTER);
        documentoPDF.add(dadosC);

    } catch (DocumentException ex) {
        Logger.getLogger(TelaRelatorio.class.getName()).log(Level.SEVERE, null, ex);
    } catch (FileNotFoundException ex) {
        Logger.getLogger(TelaRelatorio.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException ex) {
        Logger.getLogger(TelaRelatorio.class.getName()).log(Level.SEVERE, null, ex);
    } finally {
        documentoPDF.close();
        try {
            java.awt.Desktop.getDesktop().open(new File(output));
        } catch (IOException ex) {
            Logger.getLogger(TelaRelatorio.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}

From source file:Visao.Relatorio.GraficoPerCapta.java

public void create(OutputStream outputStream, JFreeChart chart) throws DocumentException, IOException {
    Document document = null;/*  ww w.  ja  va  2 s.  c o  m*/
    PdfWriter writer = null;

    try {
        //instantiate document and writer
        document = new Document();
        writer = PdfWriter.getInstance(document, outputStream);

        //open document
        document.open();
        Image img = Image.getInstance("src\\Imagens\\logo.png");
        img.setAlignment(Element.ALIGN_CENTER);
        document.add(img);

        //add image
        int width = 500;
        int height = 400;

        BufferedImage bufferedImage = chart.createBufferedImage(width, height);
        Image image = Image.getInstance(writer, bufferedImage, 1.0f);
        document.add(image);

        Font boldFont = new Font(Font.FontFamily.TIMES_ROMAN, 18, Font.BOLD);
        String quebralinha = "\n\nPopulao dos Estados\n\n";
        Paragraph preface = new Paragraph(quebralinha, boldFont);
        preface.setAlignment(Element.ALIGN_CENTER);
        document.add(preface);

        PdfPTable table = new PdfPTable(2);

        PdfPCell pdfWordCell = new PdfPCell();
        PdfPCell pdfWordCell1 = new PdfPCell();
        Phrase firstLine = new Phrase("UF", new Font(Font.FontFamily.TIMES_ROMAN, 14, Font.BOLD));
        Phrase secondLine = new Phrase("Populao", new Font(Font.FontFamily.TIMES_ROMAN, 14, Font.BOLD));

        pdfWordCell.addElement(firstLine);
        pdfWordCell1.addElement(secondLine);

        table.addCell(pdfWordCell);
        table.addCell(pdfWordCell1);

        table.addCell("SP");
        table.addCell(String.valueOf(44396484));

        table.addCell("MG");
        table.addCell(String.valueOf(20869101));

        table.addCell("RJ");
        table.addCell(String.valueOf(16550024));

        table.addCell("BA");
        table.addCell(String.valueOf(15203934));

        table.addCell("RS");
        table.addCell(String.valueOf(11247972));

        table.addCell("PR");
        table.addCell(String.valueOf(11163018));

        table.addCell("PE");
        table.addCell(String.valueOf(9345173));

        table.addCell("CE");
        table.addCell(String.valueOf(8904459));

        table.addCell("PA");
        table.addCell(String.valueOf(8175113));

        table.addCell("MA");
        table.addCell(String.valueOf(6904241));

        table.addCell("SC");
        table.addCell(String.valueOf(6819190));

        table.addCell("GO");
        table.addCell(String.valueOf(6610681));

        table.addCell("PB");
        table.addCell(String.valueOf(3972202));

        table.addCell("AM");
        table.addCell(String.valueOf(3938336));

        table.addCell("ES");
        table.addCell(String.valueOf(3929911));

        table.addCell("RN");
        table.addCell(String.valueOf(3442175));

        table.addCell("AL");
        table.addCell(String.valueOf(3340932));

        table.addCell("MT");
        table.addCell(String.valueOf(3270973));

        table.addCell("PI");
        table.addCell(String.valueOf(3204028));

        table.addCell("DF");
        table.addCell(String.valueOf(2914830));

        table.addCell("MS");
        table.addCell(String.valueOf(2651235));

        table.addCell("SE");
        table.addCell(String.valueOf(2242937));

        table.addCell("RO");
        table.addCell(String.valueOf(1768204));

        table.addCell("TO");
        table.addCell(String.valueOf(1515126));

        table.addCell("AC");
        table.addCell(String.valueOf(803513));

        table.addCell("AP");
        table.addCell(String.valueOf(766679));

        table.addCell("RR");
        table.addCell(String.valueOf(505665));

        document.add(table);

        //release resources
        document.close();
        document = null;

        writer.close();
        writer = null;
    } catch (DocumentException | IOException de) {
        throw de;
    } finally {
        //release resources
        if (null != document) {
            try {
                document.close();
            } catch (Exception ex) {
            }
        }

        if (null != writer) {
            try {
                writer.close();
            } catch (Exception ex) {
            }
        }
    }
}

From source file:Visao.Relatorio.Relatorio_Geral.java

public void create(OutputStream outputStream) throws DocumentException, IOException {
    Document document = null;//from www. j a  va  2 s . co m
    PdfWriter writer = null;

    try {
        //instantiate document and writer
        document = new Document();
        writer = PdfWriter.getInstance(document, outputStream);

        //open document
        document.open();
        Image img = Image.getInstance("src\\Imagens\\logo.png");
        img.setAlignment(Element.ALIGN_CENTER);
        document.add(img);

        Paragraph paragraph = new Paragraph("\n\nRelatrio Geral\n\n",
                new Font(Font.FontFamily.TIMES_ROMAN, 24, Font.BOLD));
        paragraph.setAlignment(Element.ALIGN_CENTER);
        document.add(paragraph);

        document.add(new Paragraph("Quantidade de Reclamaoes Cadastradas: " + quantidadeReclamacao + "\n",
                new Font(Font.FontFamily.TIMES_ROMAN, 14, Font.BOLD)));
        document.add(new Paragraph("Quantidade de Empresas Cadastradas: " + quantidadeEmpresa + "\n",
                new Font(Font.FontFamily.TIMES_ROMAN, 14, Font.BOLD)));
        document.add(new Paragraph("Quantidade de Regies Cadastradas: " + quantidadeRegiao + "\n",
                new Font(Font.FontFamily.TIMES_ROMAN, 14, Font.BOLD)));
        document.add(new Paragraph("Quantidade de UFs Cadastrados: " + quantidadeUF + "\n",
                new Font(Font.FontFamily.TIMES_ROMAN, 14, Font.BOLD)));
        document.add(new Paragraph("Quantidade de Cidades Cadastradas: " + quantidadeCidade + "\n",
                new Font(Font.FontFamily.TIMES_ROMAN, 14, Font.BOLD)));
        document.add(new Paragraph("Tempo Mdio de Resposta: " + decimalFormat.format(tempoMedio) + "\n",
                new Font(Font.FontFamily.TIMES_ROMAN, 14, Font.BOLD)));
        document.add(new Paragraph("Nota Mdia: " + decimalFormat.format(notamedia) + "\n",
                new Font(Font.FontFamily.TIMES_ROMAN, 14, Font.BOLD)));
        document.add(new Paragraph(
                "Quantidade de Reclamaes Resolvidas: " + resolvida + " - " + resolvidaPorcentagem + "%\n",
                new Font(Font.FontFamily.TIMES_ROMAN, 14, Font.BOLD)));
        document.add(new Paragraph("Quantidade de Reclamaes No Resolvidas: " + naoresolvida + " - "
                + naoresolvidaPorcentagem + "%\n", new Font(Font.FontFamily.TIMES_ROMAN, 14, Font.BOLD)));
        document.add(new Paragraph("Quantidade de Reclamaes No Avaliadas: " + naoavaliada + " - "
                + naoavaliadaPorcentagem + "%\n", new Font(Font.FontFamily.TIMES_ROMAN, 14, Font.BOLD)));
        document.close();
        document = null;

        writer.close();
        writer = null;
    } catch (DocumentException | IOException de) {
        throw de;
    } finally {
        //release resources
        if (null != document) {
            try {
                document.close();
            } catch (Exception ex) {
            }
        }

        if (null != writer) {
            try {
                writer.close();
            } catch (Exception ex) {
            }
        }
    }
}

From source file:Visao.Relatorio.Relatorio_QuantidadeReclamacoesCidadeIntervalo.java

public void create(OutputStream outputStream) throws DocumentException, IOException {
    Document document = null;// w  ww. j  a va2  s.co  m
    PdfWriter writer = null;

    try {
        //instantiate document and writer
        document = new Document();
        writer = PdfWriter.getInstance(document, outputStream);

        //open document
        document.open();
        Image img = Image.getInstance("src\\Imagens\\logo.png");
        img.setAlignment(Element.ALIGN_CENTER);
        document.add(img);

        Paragraph paragraph = new Paragraph("\n\nReclamaes\n\nCidade: " + cidade,
                new Font(Font.FontFamily.TIMES_ROMAN, 24, Font.BOLD));
        paragraph.setAlignment(Element.ALIGN_CENTER);
        document.add(paragraph);

        Paragraph paragraph1 = new Paragraph("\nMs Abertura: " + mes + "\nAno Abertura: " + ano,
                new Font(Font.FontFamily.TIMES_ROMAN, 14, Font.BOLD));

        document.add(paragraph1);

        document.add(new Paragraph("\n\n\n"));

        PdfPTable table = new PdfPTable(3);
        PdfPCell pdfWordCell = new PdfPCell();
        PdfPCell pdfWordCell1 = new PdfPCell();
        PdfPCell pdfWordCell2 = new PdfPCell();
        Phrase firstLine = new Phrase("Quantidade de reclamaes",
                new Font(Font.FontFamily.TIMES_ROMAN, 16, Font.BOLD));
        Phrase secondLine = new Phrase("Nota mdia consumidor",
                new Font(Font.FontFamily.TIMES_ROMAN, 16, Font.BOLD));
        Phrase thirdLine = new Phrase("Tempo mdio de resposta",
                new Font(Font.FontFamily.TIMES_ROMAN, 16, Font.BOLD));

        pdfWordCell.addElement(firstLine);
        pdfWordCell1.addElement(secondLine);
        pdfWordCell2.addElement(thirdLine);

        table.addCell(pdfWordCell);
        table.addCell(pdfWordCell1);
        table.addCell(pdfWordCell2);

        table.addCell(String.valueOf(quantidade));
        table.addCell(decimalFormat.format(notamedia));
        table.addCell(decimalFormat.format(tempoResposta) + " dias");

        document.add(table);

        document.add(new Paragraph("\n\n\nEmpresas Reclamadas\n\n",
                new Font(Font.FontFamily.TIMES_ROMAN, 16, Font.BOLD)));

        PdfPTable table1 = new PdfPTable(2);
        PdfPCell pdfWordCel3 = new PdfPCell();
        PdfPCell pdfWordCel4 = new PdfPCell();
        Phrase firstLine1 = new Phrase("Empresa", new Font(Font.FontFamily.TIMES_ROMAN, 16, Font.BOLD));
        Phrase secondLine1 = new Phrase("Quantidade", new Font(Font.FontFamily.TIMES_ROMAN, 16, Font.BOLD));

        pdfWordCel3.addElement(firstLine1);
        pdfWordCel4.addElement(secondLine1);

        table1.addCell(pdfWordCel3);
        table1.addCell(pdfWordCel4);

        String consulta = "Select e.nomefantasia, count(r.codigoreclamacao)" + " from Reclamacao r, Empresa e"
                + " where r.codempresa = e.codigoempresa and" + " r.cidade='" + cidade + "' and r.mesabertura="
                + mes + " and r.anoabertura=" + ano + " group by e.nomefantasia" + " order by e.nomefantasia";

        Iterator i = dao.getSessao().createSQLQuery(consulta).list().iterator();

        while (i.hasNext()) {
            Object[] reclamacaoEmpresa = (Object[]) i.next();
            table1.addCell(reclamacaoEmpresa[0].toString());
            table1.addCell(reclamacaoEmpresa[1].toString());
        }

        document.add(table1);

        document.add(new Paragraph("\n\n\nAssuntos Reclamados\n\n",
                new Font(Font.FontFamily.TIMES_ROMAN, 16, Font.BOLD)));
        PdfPTable table2 = new PdfPTable(2);
        PdfPCell pdfWordCel5 = new PdfPCell();
        PdfPCell pdfWordCel6 = new PdfPCell();
        Phrase firstLine5 = new Phrase("Assunto", new Font(Font.FontFamily.TIMES_ROMAN, 16, Font.BOLD));

        pdfWordCel5.addElement(firstLine5);
        pdfWordCel6.addElement(secondLine1);

        table2.addCell(pdfWordCel5);
        table2.addCell(pdfWordCel6);

        String consulta1 = "select assunto, count(codigoreclamacao)" + " from Reclamacao where cidade='"
                + cidade + "'" + " and mesabertura=" + mes + " and anoabertura=" + ano + " group by assunto "
                + " order by assunto";
        Iterator ii = dao.getSessao().createSQLQuery(consulta1).list().iterator();

        while (ii.hasNext()) {
            Object[] reclamacaoAssunto = (Object[]) ii.next();
            table2.addCell(reclamacaoAssunto[0].toString());
            table2.addCell(reclamacaoAssunto[1].toString());
        }

        document.add(table2);

        document.close();
        document = null;

        writer.close();
        writer = null;
    } catch (DocumentException | IOException de) {
        throw de;
    } finally {
        //release resources
        if (null != document) {
            try {
                document.close();
            } catch (Exception ex) {
            }
        }

        if (null != writer) {
            try {
                writer.close();
            } catch (Exception ex) {
            }
        }
    }
}