Example usage for com.itextpdf.text PageSize A4

List of usage examples for com.itextpdf.text PageSize A4

Introduction

In this page you can find the example usage for com.itextpdf.text PageSize A4.

Prototype

Rectangle A4

To view the source code for com.itextpdf.text PageSize A4.

Click Source Link

Document

This is the a4 format

Usage

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 {//from w ww .  ja  va 2 s  . com

        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 {// ww w  .  jav  a 2s.  co  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("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:View.ThongKe.java

private void xuatFile(JTable table) {
    String url = "", title = "  Thng K ?c Gi", loaiThongKe = (String) jComboBox2.getSelectedItem();
    ;// w  ww.  ja  v a 2  s.c om
    String[] tenCot = { loaiThongKe, "S Lng" };
    ;

    if (table == jTable1) {
        url = "ThongKeSach";
        title = "  Thng K Sch";
        loaiThongKe = (String) jComboBox1.getSelectedItem();
        tenCot[0] = loaiThongKe;
    }
    if (table == jTable2)
        url = "ThongKeDocGia";

    String bf = "H? v tn         : L Ng?c Long\n" + "MSSV                : 20142659\n"
            + "?? ti               : Xy dng chng trnh qun l th vin";
    bf += "\n\nTr?ng ?i H?c Bch Khoa H Ni          Cng Ha - X Hi - Ch Ngha - Vit Nam\n"
            + "      Th vin T Quang Bu                              ?c Lp - T Do - Hnh Phc";
    bf += "\n\n                                 " + title.toUpperCase() + " THEO ";
    bf += loaiThongKe.toUpperCase();

    String af = "H Ni, Vit Nam Ngy " + Model.ThuVien.getTodayNgayThangNam() + "\n"
            + "Ng?i to bng : L Ng?c Long";

    //Model.ThuVien.xuatFilePDF(url,table,title,PageSize.A3);
    Model.ThuVien.xuatFilePDF2(url, bf, tenCot, af, table, title, PageSize.A4);
}

From source file:visao.FrameListaCliente.java

private void btnImprimirRelatorioClienteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnImprimirRelatorioClienteActionPerformed
    //criamos um documento vazio
    String msg = "";
    String tituloMsg = "Relatrio PDF";
    String passagemTexto = txtCliente.getText();
    Document documento = new Document() {
    };/*from  w  w w  .j  av a 2  s .  co  m*/

    try {
        //criar o documento no diretrio do projeto Netbeans AeroFast
        PdfWriter.getInstance(documento, new FileOutputStream("documentoAeroFastClientes.pdf"));

        //abrir o documento criado.
        documento.open();

        //ajustar o tamanho da pagina
        documento.setPageSize(PageSize.A4);

        //Adicionar um paragrafo
        documento.add(new Paragraph(passagemTexto));

    } catch (DocumentException | FileNotFoundException ex) {
        msg = msg + ex;
        msg = reduzString(msg);
        Logger.getLogger(FrameListaCliente.class.getName()).log(Level.SEVERE, null, ex);

    } finally {
        documento.close();

        if (!"".equals(msg)) {
            JOptionPane.showMessageDialog(this, msg, tituloMsg, JOptionPane.WARNING_MESSAGE);
            msg = "";
        } else {
            msg = "Relatrio criado em PDF com sucesso";
            JOptionPane.showMessageDialog(this, msg, tituloMsg, JOptionPane.WARNING_MESSAGE);
            msg = "";
        }
    }
}

From source file:Visao.grafico.GraficoRelatorioEstoque.java

private void GerarPDF() throws DocumentException, FileNotFoundException {
    try {/*from w  w w  .  j  av  a 2s .  c om*/
        int linha = jTableRelatorioGrafico.getSelectedRow();
        Document document = new Document(PageSize.A4, 10, 10, 10, 10);
        //System.out.println(new File(".").getAbsolutePath());
        String arquivo = new File("RelatorioFaz.").getAbsolutePath() + "pdf";
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(arquivo));
        document.open();
        Font font = new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD);
        //String titulo = jTableRelatorioEstoquePrincipal.getValueAt(linha, 3).toString()+ " "+jTableRelatorioEstoquePrincipal.getValueAt(linha, 2).toString()+"-"+jTableRelatorioEstoquePrincipal.getValueAt(linha, 0).toString();
        String titulo = "Relatorio";
        Paragraph pgt = new Paragraph(titulo, font);
        pgt.setAlignment(Element.ALIGN_CENTER);
        document.add(pgt);
        document.add(new Paragraph(" "));
        PdfPTable table = new PdfPTable(colunas.length);
        // Definindo uma fonte, com tamanho 20 e negrito
        PdfPCell header = new PdfPCell(new Paragraph(titulo, font));
        header.setColspan(colunas.length);
        table.addCell(header);
        table.setWidthPercentage(100.0f);
        table.setHorizontalAlignment(Element.ALIGN_JUSTIFIED_ALL);
        //System.out.println("Tamanho: "+linhas.size());
        font = new Font(Font.FontFamily.TIMES_ROMAN, 4, Font.NORMAL);
        for (String coluna : colunas) {
            table.addCell(new Paragraph(coluna, font));
        }

        //varias linhas
        for (int i = 0; i < linhas.size(); i++) {//linha
            for (int j = 0; j < colunas.length; j++) {//coluna
                table.addCell(new Paragraph(jTableRelatorioGrafico.getValueAt(i, j).toString(), font));
            }
        }

        document.add(table);

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

        font = new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD);
        document.add(new Paragraph("Dados Totais", font));
        font = new Font(Font.FontFamily.TIMES_ROMAN, 8, Font.NORMAL);
        document.close();
        JOptionPane.showMessageDialog(null, "PDF: " + arquivo + " gerado!");
    } catch (FileNotFoundException | DocumentException | HeadlessException ex) {
        Logger.getLogger(GerarRelatorioEstoqueBasico.class.getName()).log(Level.SEVERE, null,
                "Erro ao gerar pdf: " + ex);
        JOptionPane.showMessageDialog(null, "Erro ao gerar pdf: " + ex);
    }
}

From source file:Visao.relatorios.GerarRelatorioCarvao.java

private void GerarPDF() throws DocumentException, FileNotFoundException {
    try {/*from  w  w  w  .j  a va  2  s. c o  m*/
        int linha = jTableRelatorioCarvao.getSelectedRow();
        Document document = new Document(PageSize.A4, 10, 10, 10, 10);
        //System.out.println(new File(".").getAbsolutePath());
        String arquivo = new File("Relatorio Carvo Praa.").getAbsolutePath() + "pdf";
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(arquivo));
        document.open();
        Font font = new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD);
        //String titulo = jTableRelatorioEstoquePrincipal.getValueAt(linha, 3).toString()+ " "+jTableRelatorioEstoquePrincipal.getValueAt(linha, 2).toString()+"-"+jTableRelatorioEstoquePrincipal.getValueAt(linha, 0).toString();
        String titulo = "Relatorio Carvo Praa";
        Paragraph pgt = new Paragraph(titulo, font);
        pgt.setAlignment(Element.ALIGN_CENTER);
        document.add(pgt);
        document.add(new Paragraph(" "));
        /*if(!filtro_matgen.equals("")){
            titulo = "Material genetico "+filtro_matgen;
        }*/
        PdfPTable table = new PdfPTable(colunas.length);
        // Definindo uma fonte, com tamanho 20 e negrito
        PdfPCell header = new PdfPCell(new Paragraph(titulo, font));
        header.setColspan(colunas.length);
        table.addCell(header);
        table.setWidthPercentage(100.0f);
        table.setHorizontalAlignment(Element.ALIGN_JUSTIFIED_ALL);
        //System.out.println("Tamanho: "+linhas.size());
        font = new Font(Font.FontFamily.TIMES_ROMAN, 4, Font.NORMAL);
        for (String coluna : colunas) {
            table.addCell(new Paragraph(coluna, font));
        }

        //varias linhas
        for (int i = 0; i < linhas.size(); i++) {//linha
            for (int j = 0; j < colunas.length; j++) {//coluna
                //table.addCell(jTableRelatorioEstoquePrincipal.getValueAt(i, j).toString());
                table.addCell(new Paragraph(jTableRelatorioCarvao.getValueAt(i, j).toString(), font));
            }
        }

        document.add(table);
        document.add(new Paragraph(" "));

        font = new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD);
        document.add(new Paragraph("Dados Totais", font));
        font = new Font(Font.FontFamily.TIMES_ROMAN, 8, Font.NORMAL);
        document.add(new Paragraph(jLabelInfo1.getText(), font));
        document.add(new Paragraph(jLabelVolumeMadeiraTotal.getText(), font));
        document.add(new Paragraph(jLabelVolumeCarvaoTotal.getText(), font));
        document.close();
        JOptionPane.showMessageDialog(null, "PDF: " + arquivo + " gerado!");
    } catch (FileNotFoundException | DocumentException | HeadlessException ex) {
        Logger.getLogger(GerarRelatorioEstoqueBasico.class.getName()).log(Level.SEVERE, null,
                "Erro ao gerar pdf: " + ex);
        JOptionPane.showMessageDialog(null, "Erro ao gerar pdf: " + ex);
    }

}

From source file:Visao.relatorios.GerarRelatorioCarvaoExpedido.java

private void GerarPDF() throws DocumentException, FileNotFoundException {
    try {//w  ww  .j  ava  2s.c o  m
        int linha = jTableExpedirCarvao.getSelectedRow();
        Document document = new Document(PageSize.A4, 10, 10, 10, 10);
        //System.out.println(new File(".").getAbsolutePath());
        String arquivo = new File("Relatorio Carvo Expedido.").getAbsolutePath() + "pdf";
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(arquivo));
        document.open();
        Font font = new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD);
        //String titulo = jTableRelatorioEstoquePrincipal.getValueAt(linha, 3).toString()+ " "+jTableRelatorioEstoquePrincipal.getValueAt(linha, 2).toString()+"-"+jTableRelatorioEstoquePrincipal.getValueAt(linha, 0).toString();
        String titulo = "Relatorio Carvo Expedido";
        Paragraph pgt = new Paragraph(titulo, font);
        pgt.setAlignment(Element.ALIGN_CENTER);
        document.add(pgt);
        document.add(new Paragraph(" "));
        /*if(!filtro_matgen.equals("")){
            titulo = "Material genetico "+filtro_matgen;
        }*/
        PdfPTable table = new PdfPTable(colunas.length);
        // Definindo uma fonte, com tamanho 20 e negrito
        PdfPCell header = new PdfPCell(new Paragraph(titulo, font));
        header.setColspan(colunas.length);
        table.addCell(header);
        table.setWidthPercentage(100.0f);
        table.setHorizontalAlignment(Element.ALIGN_JUSTIFIED_ALL);
        //System.out.println("Tamanho: "+linhas.size());
        font = new Font(Font.FontFamily.TIMES_ROMAN, 4, Font.NORMAL);
        for (String coluna : colunas) {
            table.addCell(new Paragraph(coluna, font));
        }

        //varias linhas
        for (int i = 0; i < linhas.size(); i++) {//linha
            for (int j = 0; j < colunas.length; j++) {//coluna
                //table.addCell(jTableRelatorioEstoquePrincipal.getValueAt(i, j).toString());
                table.addCell(new Paragraph(jTableExpedirCarvao.getValueAt(i, j).toString(), font));
            }
        }

        document.add(table);
        document.add(new Paragraph(" "));

        font = new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD);
        document.add(new Paragraph("Dados Totais", font));
        font = new Font(Font.FontFamily.TIMES_ROMAN, 8, Font.NORMAL);
        document.add(new Paragraph(jLabelInfo1.getText(), font));
        document.add(new Paragraph(jLabelPesoTotal.getText(), font));
        document.add(new Paragraph(jLabelVolumeTotal.getText(), font));
        document.close();
        JOptionPane.showMessageDialog(null, "PDF: " + arquivo + " gerado!");
    } catch (FileNotFoundException | DocumentException | HeadlessException ex) {
        Logger.getLogger(GerarRelatorioEstoqueBasico.class.getName()).log(Level.SEVERE, null,
                "Erro ao gerar pdf: " + ex);
        JOptionPane.showMessageDialog(null, "Erro ao gerar pdf: " + ex);
    }

}

From source file:Visao.relatorios.GerarRelatorioEstoqueBasico.java

private void GerarPDF() throws DocumentException, FileNotFoundException {
    try {/* w w w.j a v  a  2s.  c  om*/
        /*if(jTableRelatorioEstoquePrincipal.getSelectedRow()>=0) { 
        int linha = jTableRelatorioEstoquePrincipal.getSelectedRow();
        Document document = new Document(PageSize.A4, 10, 10, 10, 10);
        //System.out.println(new File(".").getAbsolutePath());
        String arquivo = new File("RelatorioFaz.").getAbsolutePath()+"pdf";            
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(arquivo));
        document.open();
        Font font = new Font(FontFamily.TIMES_ROMAN, 12, Font.BOLD);
        //String titulo = jTableRelatorioEstoquePrincipal.getValueAt(linha, 3).toString()+ " "+jTableRelatorioEstoquePrincipal.getValueAt(linha, 2).toString()+"-"+jTableRelatorioEstoquePrincipal.getValueAt(linha, 0).toString();
        String titulo = "";
        if(!filtro_matgen.equals("")){
            titulo = "do material genetico "+filtro_matgen;
        }
        Paragraph pgt = new Paragraph("Relatorio "+titulo, font);
        pgt.setAlignment(Element.ALIGN_CENTER);
        document.add(pgt);
        document.add(new Paragraph(" "));
        //System.out.println("Colunas "+colunas.length);
        //for(int i=4; i<colunas.length; i++){
            //document.add(new Paragraph(colunas[i]+": "+jTableRelatorioEstoquePrincipal.getValueAt(linha, i).toString()));
        //}           
        //document.add(new Paragraph("Municipio: "+jTableRelatorioEstoquePrincipal.getValueAt(linha, 3).toString()));
                
        PdfPTable table = new PdfPTable(colunas.length);
        // Definindo uma fonte, com tamanho 20 e negrito
        PdfPCell header = new PdfPCell(new Paragraph("Relatorio "+titulo,font));
        header.setColspan(colunas.length);
        table.addCell(header);
        table.setWidthPercentage(100.0f);
        table.setHorizontalAlignment(Element.ALIGN_JUSTIFIED_ALL);
        //System.out.println("Tamanho: "+linhas.size());
        font = new Font(FontFamily.TIMES_ROMAN, 4, Font.NORMAL);
        for (String coluna : colunas) {
            table.addCell(new Paragraph(coluna,font));
        }
                
        //Linha selecionada
        //for(int j=0;j<colunas.length;j++){//coluna
            //table.addCell(jTableRelatorioEstoquePrincipal.getValueAt(linha, j).toString());
            //table.addCell(new Paragraph(jTableRelatorioEstoquePrincipal.getValueAt(linha, j).toString(),font));
        //}
                
        //varias linhas
        for(int i=0;i<linhas.size();i++){//linha
            for(int j=0;j<colunas.length;j++){//coluna
                //table.addCell(jTableRelatorioEstoquePrincipal.getValueAt(i, j).toString());
                table.addCell(new Paragraph(jTableRelatorioEstoquePrincipal.getValueAt(i, j).toString(),font));
            }
        }
                
        document.add(table);
                
        document.add(new Paragraph("Relatorio Geral"));
        document.add(new Paragraph(" "));
        document.add(new Paragraph(jLabelAreaTotal.getText()));
        document.add(new Paragraph(jLabelM3_ha.getText()));
        document.add(new Paragraph(jLabelMDC_ha.getText()));
                
        document.add(new Paragraph(jLabelVolumeMadeiraEstTotal.getText()));
        document.add(new Paragraph(jLabelVolumeMadeiraTranspTotal.getText()));
        document.add(new Paragraph(jLabelVolumeCarvaoEstTotal.getText()));
        document.add(new Paragraph(jLabelVolumeCarvaoTranspTotal.getText()));
                
        document.add(new Paragraph(jLabelToneladaMadeiraEstTotal.getText()));
        document.add(new Paragraph(jLabelToneladaMadeiraTranspTotal.getText()));
        document.add(new Paragraph(jLabelToneladaCarvaoEstTotal.getText()));
        document.add(new Paragraph(jLabelToneladaCarvaoTranspTotal.getText()));
        document.close();
        JOptionPane.showMessageDialog(null, "PDF: "+arquivo+" gerado!");
        }else {
        //Document document = new Document(PageSize.A4, 72, 72, 72, 72);
        Rectangle rect = new Rectangle(1200, 595);
        Document document = new Document(rect);
        String arquivo = new File("RelatorioGeral.").getAbsolutePath()+"pdf";
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(arquivo));
        document.open();
        document.add(new Paragraph("Relatorio Geral"));
        document.add(new Paragraph(" "));
        document.add(new Paragraph(jLabelAreaTotal.getText()));
        document.add(new Paragraph(jLabelM3_ha.getText()));
        document.add(new Paragraph(jLabelMDC_ha.getText()));
                
        document.add(new Paragraph(jLabelVolumeMadeiraEstTotal.getText()));
        document.add(new Paragraph(jLabelVolumeMadeiraTranspTotal.getText()));
        document.add(new Paragraph(jLabelVolumeCarvaoEstTotal.getText()));
        document.add(new Paragraph(jLabelVolumeCarvaoTranspTotal.getText()));
                
        document.add(new Paragraph(jLabelToneladaMadeiraEstTotal.getText()));
        document.add(new Paragraph(jLabelToneladaMadeiraTranspTotal.getText()));
        document.add(new Paragraph(jLabelToneladaCarvaoEstTotal.getText()));
        document.add(new Paragraph(jLabelToneladaCarvaoTranspTotal.getText()));
                
        document.close();
        JOptionPane.showMessageDialog(null, "PDF: "+arquivo+" gerado!");
        }*/
        int linha = jTableRelatorioEstoquePrincipal.getSelectedRow();
        Document document = new Document(PageSize.A4, 10, 10, 10, 10);
        //System.out.println(new File(".").getAbsolutePath());
        String arquivo = new File("RelatorioFaz.").getAbsolutePath() + "pdf";
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(arquivo));
        document.open();
        Font font = new Font(FontFamily.TIMES_ROMAN, 12, Font.BOLD);
        //String titulo = jTableRelatorioEstoquePrincipal.getValueAt(linha, 3).toString()+ " "+jTableRelatorioEstoquePrincipal.getValueAt(linha, 2).toString()+"-"+jTableRelatorioEstoquePrincipal.getValueAt(linha, 0).toString();
        String titulo = "Relatorio";
        Paragraph pgt = new Paragraph(titulo, font);
        pgt.setAlignment(Element.ALIGN_CENTER);
        document.add(pgt);
        document.add(new Paragraph(" "));
        if (!filtro_matgen.equals("")) {
            titulo = "Material genetico " + filtro_matgen;
        }
        PdfPTable table = new PdfPTable(colunas.length);
        // Definindo uma fonte, com tamanho 20 e negrito
        PdfPCell header = new PdfPCell(new Paragraph(titulo, font));
        header.setColspan(colunas.length);
        table.addCell(header);
        table.setWidthPercentage(100.0f);
        table.setHorizontalAlignment(Element.ALIGN_JUSTIFIED_ALL);
        //System.out.println("Tamanho: "+linhas.size());
        font = new Font(FontFamily.TIMES_ROMAN, 4, Font.NORMAL);
        for (String coluna : colunas) {
            table.addCell(new Paragraph(coluna, font));
        }

        //varias linhas
        for (int i = 0; i < linhas.size(); i++) {//linha
            for (int j = 0; j < colunas.length; j++) {//coluna
                //table.addCell(jTableRelatorioEstoquePrincipal.getValueAt(i, j).toString());
                table.addCell(new Paragraph(jTableRelatorioEstoquePrincipal.getValueAt(i, j).toString(), font));
            }
        }

        document.add(table);

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

        font = new Font(FontFamily.TIMES_ROMAN, 12, Font.BOLD);
        document.add(new Paragraph("Dados Totais", font));
        font = new Font(FontFamily.TIMES_ROMAN, 8, Font.NORMAL);
        document.add(new Paragraph(jLabelInfo1.getText(), font));
        document.add(new Paragraph(jLabelAreaTotal.getText(), font));
        document.add(new Paragraph(jLabelM3_ha.getText(), font));
        document.add(new Paragraph(jLabelMDC_ha.getText(), font));
        document.add(new Paragraph(jLabelTotalMadeiraPraca.getText(), font));
        document.add(new Paragraph(jLabelTotalCarvaoPraca.getText(), font));

        document.add(new Paragraph(jLabelInfo2.getText(), font));
        document.add(new Paragraph(jLabelVolumeMadeiraEstTotal.getText(), font));
        document.add(new Paragraph(jLabelVolumeMadeiraTranspTotal.getText(), font));
        document.add(new Paragraph(jLabelToneladaMadeiraEstTotal.getText(), font));
        document.add(new Paragraph(jLabelToneladaMadeiraTranspTotal.getText(), font));

        document.add(new Paragraph(jLabelInfo3.getText(), font));
        document.add(new Paragraph(jLabelVolumeCarvaoEstTotal.getText(), font));
        document.add(new Paragraph(jLabelVolumeCarvaoProdTotal.getText(), font));
        document.add(new Paragraph(jLabelVolumeCarvaoTranspTotal.getText(), font));
        document.add(new Paragraph(jLabelToneladaCarvaoEstTotal.getText(), font));
        document.add(new Paragraph(jLabelToneladaCarvaoProdTotal.getText(), font));
        document.add(new Paragraph(jLabelToneladaCarvaoTranspTotal.getText(), font));
        document.close();
        JOptionPane.showMessageDialog(null, "PDF: " + arquivo + " gerado!");
    } catch (FileNotFoundException | DocumentException | HeadlessException ex) {
        Logger.getLogger(GerarRelatorioEstoqueBasico.class.getName()).log(Level.SEVERE, null,
                "Erro ao gerar pdf: " + ex);
        JOptionPane.showMessageDialog(null, "Erro ao gerar pdf: " + ex);
    }

}

From source file:Visao.relatorios.GerarRelatorioForno.java

private void GerarPDF() throws DocumentException, FileNotFoundException {
    try {/*from w  w  w  .  j a  v a2s.  com*/
        int linha = jTableForno.getSelectedRow();
        Document document = new Document(PageSize.A4, 10, 10, 10, 10);
        //System.out.println(new File(".").getAbsolutePath());
        String arquivo = new File("Relatorio Carvo Expedido.").getAbsolutePath() + "pdf";
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(arquivo));
        document.open();
        Font font = new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD);
        //String titulo = jTableRelatorioEstoquePrincipal.getValueAt(linha, 3).toString()+ " "+jTableRelatorioEstoquePrincipal.getValueAt(linha, 2).toString()+"-"+jTableRelatorioEstoquePrincipal.getValueAt(linha, 0).toString();
        String titulo = "Relatorio Carvo Expedido";
        Paragraph pgt = new Paragraph(titulo, font);
        pgt.setAlignment(Element.ALIGN_CENTER);
        document.add(pgt);
        document.add(new Paragraph(" "));
        /*if(!filtro_matgen.equals("")){
            titulo = "Material genetico "+filtro_matgen;
        }*/
        PdfPTable table = new PdfPTable(colunas.length);
        // Definindo uma fonte, com tamanho 20 e negrito
        PdfPCell header = new PdfPCell(new Paragraph(titulo, font));
        header.setColspan(colunas.length);
        table.addCell(header);
        table.setWidthPercentage(100.0f);
        table.setHorizontalAlignment(Element.ALIGN_JUSTIFIED_ALL);
        //System.out.println("Tamanho: "+linhas.size());
        font = new Font(Font.FontFamily.TIMES_ROMAN, 4, Font.NORMAL);
        for (String coluna : colunas) {
            table.addCell(new Paragraph(coluna, font));
        }

        //varias linhas
        for (int i = 0; i < linhas.size(); i++) {//linha
            for (int j = 0; j < colunas.length; j++) {//coluna
                //table.addCell(jTableRelatorioEstoquePrincipal.getValueAt(i, j).toString());
                table.addCell(new Paragraph(jTableForno.getValueAt(i, j).toString(), font));
            }
        }

        document.add(table);
        document.add(new Paragraph(" "));

        font = new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD);
        document.add(new Paragraph("Dados Totais", font));
        font = new Font(Font.FontFamily.TIMES_ROMAN, 8, Font.NORMAL);
        document.add(new Paragraph(jLabelInfo1.getText(), font));
        document.add(new Paragraph(jLabelFornosCheios.getText(), font));
        document.add(new Paragraph(jLabelFornosVazios.getText(), font));
        document.add(new Paragraph(jLabelFornosCarbonizando.getText(), font));
        document.add(new Paragraph(jLabelFornosResfriando.getText(), font));
        document.add(new Paragraph(jLabelFornosReforma.getText(), font));
        document.add(new Paragraph(jLabelFornosManutencao.getText(), font));
        document.close();
        JOptionPane.showMessageDialog(null, "PDF: " + arquivo + " gerado!");
    } catch (FileNotFoundException | DocumentException | HeadlessException ex) {
        Logger.getLogger(GerarRelatorioEstoqueBasico.class.getName()).log(Level.SEVERE, null,
                "Erro ao gerar pdf: " + ex);
        JOptionPane.showMessageDialog(null, "Erro ao gerar pdf: " + ex);
    }

}

From source file:Visao.relatorios.GerarRelatorioMadeiraPraca.java

private void GerarPDF() throws DocumentException, FileNotFoundException {
    try {/*  ww  w . j  av a2  s  .c  om*/
        int linha = jTableMadeiraEstoquePraca.getSelectedRow();
        Document document = new Document(PageSize.A4, 10, 10, 10, 10);
        //System.out.println(new File(".").getAbsolutePath());
        String arquivo = new File("Relatorio Madeira Praa.").getAbsolutePath() + "pdf";
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(arquivo));
        document.open();
        Font font = new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD);
        //String titulo = jTableRelatorioEstoquePrincipal.getValueAt(linha, 3).toString()+ " "+jTableRelatorioEstoquePrincipal.getValueAt(linha, 2).toString()+"-"+jTableRelatorioEstoquePrincipal.getValueAt(linha, 0).toString();
        String titulo = "Relatorio Madeira Praa";
        Paragraph pgt = new Paragraph(titulo, font);
        pgt.setAlignment(Element.ALIGN_CENTER);
        document.add(pgt);
        document.add(new Paragraph(" "));
        /*if(!filtro_matgen.equals("")){
            titulo = "Material genetico "+filtro_matgen;
        }*/
        PdfPTable table = new PdfPTable(colunas.length);
        // Definindo uma fonte, com tamanho 20 e negrito
        PdfPCell header = new PdfPCell(new Paragraph(titulo, font));
        header.setColspan(colunas.length);
        table.addCell(header);
        table.setWidthPercentage(100.0f);
        table.setHorizontalAlignment(Element.ALIGN_JUSTIFIED_ALL);
        //System.out.println("Tamanho: "+linhas.size());
        font = new Font(Font.FontFamily.TIMES_ROMAN, 4, Font.NORMAL);
        for (String coluna : colunas) {
            table.addCell(new Paragraph(coluna, font));
        }

        //varias linhas
        for (int i = 0; i < linhas.size(); i++) {//linha
            for (int j = 0; j < colunas.length; j++) {//coluna
                //table.addCell(jTableRelatorioEstoquePrincipal.getValueAt(i, j).toString());
                table.addCell(new Paragraph(jTableMadeiraEstoquePraca.getValueAt(i, j).toString(), font));
            }
        }

        document.add(table);
        document.add(new Paragraph(" "));

        font = new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD);
        document.add(new Paragraph("Dados Totais", font));
        font = new Font(Font.FontFamily.TIMES_ROMAN, 8, Font.NORMAL);
        document.add(new Paragraph(jLabelInfo1.getText(), font));
        document.add(new Paragraph(jLabelMStereoTotal.getText(), font));
        document.add(new Paragraph(jLabelM3Total.getText(), font));
        document.add(new Paragraph(jLabelPesoTotal.getText(), font));

        document.close();
        JOptionPane.showMessageDialog(null, "PDF: " + arquivo + " gerado!");
    } catch (FileNotFoundException | DocumentException | HeadlessException ex) {
        Logger.getLogger(GerarRelatorioEstoqueBasico.class.getName()).log(Level.SEVERE, null,
                "Erro ao gerar pdf: " + ex);
        JOptionPane.showMessageDialog(null, "Erro ao gerar pdf: " + ex);
    }

}