Example usage for com.itextpdf.text Font NORMAL

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

Introduction

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

Prototype

int NORMAL

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

Click Source Link

Document

this is a possible style.

Usage

From source file:relatorios.RelatorioCompra.java

public static void gerarRelatorio(String sql) throws ClassNotFoundException { // criao do objeto documento
    Document document = new Document(PageSize.A4, 30, 20, 20, 30);
    Connection conecta; // o objeto que conecta com o banco de dados
    PreparedStatement pst;//ww w . ja  v  a  2 s.  co m
    ResultSet rs;
    conecta = ConectaBd.conectabd();

    OutputStream output;
    try {
        output = new FileOutputStream("relatorios/Relatrio de Compras.pdf");
        try {
            PdfWriter.getInstance(document, output);
            document.open(); // adicionando um pargrafo ao documento 
            document.add(new Paragraph("                                    Relatrio de Compras"));
            document.add(new Paragraph("\n"));
            Font bfBold10 = new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.BOLD, new BaseColor(0, 0, 0));
            Font bfBold12 = new Font(Font.FontFamily.TIMES_ROMAN, 8, Font.NORMAL, new BaseColor(0, 0, 0));
            Font bf8 = new Font(Font.FontFamily.TIMES_ROMAN, 6);
            PdfPTable tabela = new PdfPTable(6);
            PdfPCell cell;
            cell = new PdfPCell(new Phrase("Fornecedor", bfBold10));
            tabela.addCell(cell);
            cell = new PdfPCell(new Phrase("Produto", bfBold10));
            tabela.addCell(cell);
            cell = new PdfPCell(new Phrase("Qtde do Produto", bfBold10));
            tabela.addCell(cell);
            cell = new PdfPCell(new Phrase("Valor por Unidade", bfBold10));
            tabela.addCell(cell);
            cell = new PdfPCell(new Phrase("Valor Total", bfBold10));
            tabela.addCell(cell);
            cell = new PdfPCell(new Phrase("Data", bfBold10));
            tabela.addCell(cell);

            try {
                pst = conecta.prepareStatement(sql);
                rs = pst.executeQuery();
                while (rs.next()) {
                    String fornec = rs.getString("fornecedor");
                    cell = new PdfPCell(new Phrase(fornec, bf8));
                    tabela.addCell(cell);
                    fornec = rs.getString("produto");
                    cell = new PdfPCell(new Phrase(fornec, bf8));
                    tabela.addCell(cell);
                    fornec = rs.getString("quantidade");
                    cell = new PdfPCell(new Phrase(fornec, bf8));
                    tabela.addCell(cell);
                    fornec = rs.getString("valorunitariocompra");
                    cell = new PdfPCell(new Phrase(fornec, bf8));
                    tabela.addCell(cell);
                    fornec = rs.getString("valortotalcompra");
                    cell = new PdfPCell(new Phrase(fornec, bf8));
                    tabela.addCell(cell);
                    fornec = rs.getString("data_compra");
                    cell = new PdfPCell(new Phrase(fornec, bf8));
                    tabela.addCell(cell);
                }
            } catch (SQLException error) {
                JOptionPane.showMessageDialog(null, error);
            }

            document.add(tabela);
            document.close();
        } catch (DocumentException de) {
            System.err.println(de.getMessage());
            document.close();

        }
    } catch (FileNotFoundException ex) {
        Logger.getLogger(RelatorioCompra.class.getName()).log(Level.SEVERE, null, ex);
        System.err.println(ex.getMessage());

    }

}

From source file:relatorios.RelatorioFornecedor.java

public static void gerarRelatorio() throws ClassNotFoundException { // criao do objeto documento
    Document document = new Document(PageSize.A4, 30, 20, 20, 30);
    Connection conecta; // o objeto que conecta com o banco de dados
    PreparedStatement pst;/* ww w .j a v a  2s  .  c  om*/
    ResultSet rs;
    conecta = ConectaBd.conectabd();

    OutputStream output;
    try {
        output = new FileOutputStream("relatorios/Relatrio de Fornecedores.pdf");
        try {
            PdfWriter.getInstance(document, output);
            document.open(); // adicionando um pargrafo ao documento 
            document.add(new Paragraph("                                    Relatrio de Fornecedores"));
            document.add(new Paragraph("\n"));
            Font bfBold10 = new Font(FontFamily.TIMES_ROMAN, 10, Font.BOLD, new BaseColor(0, 0, 0));
            Font bfBold12 = new Font(FontFamily.TIMES_ROMAN, 8, Font.NORMAL, new BaseColor(0, 0, 0));
            Font bf8 = new Font(FontFamily.TIMES_ROMAN, 8);
            PdfPTable tabela = new PdfPTable(7);
            PdfPCell cell;
            cell = new PdfPCell(new Phrase("Fornecedor", bfBold10));
            tabela.addCell(cell);
            cell = new PdfPCell(new Phrase("CPF", bfBold10));
            tabela.addCell(cell);
            cell = new PdfPCell(new Phrase("CNPJ", bfBold10));
            tabela.addCell(cell);
            cell = new PdfPCell(new Phrase("Endereo", bfBold10));
            tabela.addCell(cell);
            cell = new PdfPCell(new Phrase("Cidade", bfBold10));
            tabela.addCell(cell);
            cell = new PdfPCell(new Phrase("Email", bfBold10));
            tabela.addCell(cell);
            cell = new PdfPCell(new Phrase("Telefone", bfBold10));
            tabela.addCell(cell);

            String sql = "Select * from fornecedores order by codigo Asc"; //orderna pelo numero do codigo ascendentemente
            try {
                pst = conecta.prepareStatement(sql);
                rs = pst.executeQuery();
                while (rs.next()) {
                    String fornec = rs.getString("fornecedor");
                    cell = new PdfPCell(new Phrase(fornec, bf8));
                    tabela.addCell(cell);
                    fornec = rs.getString("cpf");
                    cell = new PdfPCell(new Phrase(fornec, bf8));
                    tabela.addCell(cell);
                    fornec = rs.getString("cnpj");
                    cell = new PdfPCell(new Phrase(fornec, bf8));
                    tabela.addCell(cell);
                    fornec = rs.getString("endereco");
                    cell = new PdfPCell(new Phrase(fornec, bf8));
                    tabela.addCell(cell);
                    fornec = rs.getString("cidade");
                    cell = new PdfPCell(new Phrase(fornec, bf8));
                    tabela.addCell(cell);
                    fornec = rs.getString("email");
                    cell = new PdfPCell(new Phrase(fornec, bf8));
                    tabela.addCell(cell);
                    fornec = rs.getString("telefone");
                    cell = new PdfPCell(new Phrase(fornec, bf8));
                    tabela.addCell(cell);

                }
            } catch (SQLException error) {
                JOptionPane.showMessageDialog(null, error);
            }

            document.add(tabela);
            document.close();
        } catch (DocumentException de) {
            System.err.println(de.getMessage());
            document.close();

        }
    } catch (FileNotFoundException ex) {
        Logger.getLogger(RelatorioFornecedor.class.getName()).log(Level.SEVERE, null, ex);
        System.err.println(ex.getMessage());

    }

}

From source file:relatorios.RelatorioFuncionario.java

public static void gerarRelatorio() throws ClassNotFoundException { // criao do objeto documento
    Document document = new Document(PageSize.A4, 30, 20, 20, 30);
    Connection conecta; // o objeto que conecta com o banco de dados
    PreparedStatement pst;//from  w  w w .j  a  v a  2  s  . co  m
    ResultSet rs;
    conecta = ConectaBd.conectabd();

    OutputStream output;
    try {
        output = new FileOutputStream("relatorios/Relatrio de Funcionarios.pdf");
        try {
            PdfWriter.getInstance(document, output);
            document.open(); // adicionando um pargrafo ao documento 
            document.add(new Paragraph("                                    Relatrio de Funcionarios"));
            document.add(new Paragraph("\n"));
            Font bfBold10 = new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.BOLD, new BaseColor(0, 0, 0));
            Font bfBold12 = new Font(Font.FontFamily.TIMES_ROMAN, 8, Font.NORMAL, new BaseColor(0, 0, 0));
            Font bf8 = new Font(Font.FontFamily.TIMES_ROMAN, 8);
            PdfPTable tabela = new PdfPTable(3);
            PdfPCell cell;
            cell = new PdfPCell(new Phrase("Nome", bfBold10));
            tabela.addCell(cell);
            cell = new PdfPCell(new Phrase("Telefone", bfBold10));
            tabela.addCell(cell);
            cell = new PdfPCell(new Phrase("Usuario", bfBold10));
            tabela.addCell(cell);

            String sql = "Select * from funcionarios order by codigo Asc"; //orderna pelo numero do codigo ascendentemente
            try {
                pst = conecta.prepareStatement(sql);
                rs = pst.executeQuery();
                while (rs.next()) {
                    String fornec = rs.getString("nome");
                    cell = new PdfPCell(new Phrase(fornec, bf8));
                    tabela.addCell(cell);
                    fornec = rs.getString("telefone");
                    cell = new PdfPCell(new Phrase(fornec, bf8));
                    tabela.addCell(cell);
                    fornec = rs.getString("usuario");
                    cell = new PdfPCell(new Phrase(fornec, bf8));
                    tabela.addCell(cell);
                }
            } catch (SQLException error) {
                JOptionPane.showMessageDialog(null, error);
            }

            document.add(tabela);
            document.close();
        } catch (DocumentException de) {
            System.err.println(de.getMessage());
            document.close();

        }
    } catch (FileNotFoundException ex) {
        Logger.getLogger(RelatorioFornecedor.class.getName()).log(Level.SEVERE, null, ex);
        System.err.println(ex.getMessage());

    }

}

From source file:relatorios.RelatorioProdutos.java

public static void gerarRelatorio() throws ClassNotFoundException { // criao do objeto documento
    Document document = new Document(PageSize.A4, 30, 20, 20, 30);
    Connection conecta; // o objeto que conecta com o banco de dados
    PreparedStatement pst;/*from ww w  .j a  v  a2s  .  c  o m*/
    ResultSet rs;
    conecta = ConectaBd.conectabd();

    OutputStream output;
    try {
        output = new FileOutputStream("relatorios/Relatrio de Produtos.pdf");

        try {
            PdfWriter.getInstance(document, output);
            document.open(); // adicionando um pargrafo ao documento 
            document.add(new Paragraph("                                    Relatrio de Produtos"));
            document.add(new Paragraph("\n"));
            Font bfBold10 = new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.BOLD, new BaseColor(0, 0, 0));
            Font bfBold12 = new Font(Font.FontFamily.TIMES_ROMAN, 8, Font.NORMAL, new BaseColor(0, 0, 0));
            Font bf8 = new Font(Font.FontFamily.TIMES_ROMAN, 8);
            PdfPTable tabela = new PdfPTable(4);
            PdfPCell cell;
            cell = new PdfPCell(new Phrase("Nome", bfBold10));
            tabela.addCell(cell);
            cell = new PdfPCell(new Phrase("Valor de Compra", bfBold10));
            tabela.addCell(cell);
            cell = new PdfPCell(new Phrase("Valor de Venda", bfBold10));
            tabela.addCell(cell);
            cell = new PdfPCell(new Phrase("Qtde. em Estoque", bfBold10));
            tabela.addCell(cell);

            String sql = "Select * from produtos_float order by codigo Asc"; //orderna pelo numero do codigo ascendentemente
            try {
                pst = conecta.prepareStatement(sql);
                rs = pst.executeQuery();
                while (rs.next()) {
                    String fornec = rs.getString("descricao");
                    cell = new PdfPCell(new Phrase(fornec, bf8));
                    tabela.addCell(cell);
                    fornec = rs.getString("valor_compra");
                    cell = new PdfPCell(new Phrase(fornec, bf8));
                    tabela.addCell(cell);
                    fornec = rs.getString("valor_venda");
                    cell = new PdfPCell(new Phrase(fornec, bf8));
                    tabela.addCell(cell);
                    fornec = rs.getString("estoque");
                    cell = new PdfPCell(new Phrase(fornec, bf8));
                    tabela.addCell(cell);
                }
            } catch (SQLException error) {
                JOptionPane.showMessageDialog(null, error);
            }

            document.add(tabela);
            document.close();
        } catch (DocumentException de) {
            System.err.println(de.getMessage());
            document.close();

        }
    } catch (FileNotFoundException ex) {
        Logger.getLogger(RelatorioProdutos.class.getName()).log(Level.SEVERE, null, ex);
        System.err.println(ex.getMessage());

    }

}

From source file:relatorios.RelatorioVenda.java

public static void gerarRelatorio(String sql) throws ClassNotFoundException { // criao do objeto documento
    Document document = new Document(PageSize.A4, 30, 20, 20, 30);
    Connection conecta; // o objeto que conecta com o banco de dados
    PreparedStatement pst;//w  w w  .  j  a  v a  2s . c o  m
    ResultSet rs;
    conecta = ConectaBd.conectabd();

    OutputStream output;
    try {
        output = new FileOutputStream("relatorios/Relatrio de Venda.pdf");
        try {
            PdfWriter.getInstance(document, output);
            document.open(); // adicionando um pargrafo ao documento 
            document.add(new Paragraph("                                    Relatrio de Venda"));
            document.add(new Paragraph("\n"));
            Font bfBold10 = new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.BOLD, new BaseColor(0, 0, 0));
            Font bfBold12 = new Font(Font.FontFamily.TIMES_ROMAN, 8, Font.NORMAL, new BaseColor(0, 0, 0));
            Font bf8 = new Font(Font.FontFamily.TIMES_ROMAN, 6);
            PdfPTable tabela = new PdfPTable(6);
            PdfPCell cell;
            cell = new PdfPCell(new Phrase("Cliente", bfBold10));
            tabela.addCell(cell);
            cell = new PdfPCell(new Phrase("Produto", bfBold10));
            tabela.addCell(cell);
            cell = new PdfPCell(new Phrase("Qtde do Produto", bfBold10));
            tabela.addCell(cell);
            cell = new PdfPCell(new Phrase("Valor por Unidade", bfBold10));
            tabela.addCell(cell);
            cell = new PdfPCell(new Phrase("Valor Total", bfBold10));
            tabela.addCell(cell);
            cell = new PdfPCell(new Phrase("Data", bfBold10));
            tabela.addCell(cell);

            try {
                pst = conecta.prepareStatement(sql);
                rs = pst.executeQuery();
                while (rs.next()) {
                    String fornec = rs.getString("cliente");
                    cell = new PdfPCell(new Phrase(fornec, bf8));
                    tabela.addCell(cell);
                    fornec = rs.getString("produto");
                    cell = new PdfPCell(new Phrase(fornec, bf8));
                    tabela.addCell(cell);
                    fornec = rs.getString("quantidade");
                    cell = new PdfPCell(new Phrase(fornec, bf8));
                    tabela.addCell(cell);
                    fornec = rs.getString("valorunitariovenda");
                    cell = new PdfPCell(new Phrase(fornec, bf8));
                    tabela.addCell(cell);
                    fornec = rs.getString("valortotalvenda");
                    cell = new PdfPCell(new Phrase(fornec, bf8));
                    tabela.addCell(cell);
                    fornec = rs.getString("data_venda");
                    cell = new PdfPCell(new Phrase(fornec, bf8));
                    tabela.addCell(cell);
                }
            } catch (SQLException error) {
                JOptionPane.showMessageDialog(null, error);
            }

            document.add(tabela);
            document.close();
        } catch (DocumentException de) {
            System.err.println(de.getMessage());
            document.close();

        }
    } catch (FileNotFoundException ex) {
        Logger.getLogger(RelatorioVenda.class.getName()).log(Level.SEVERE, null, ex);
        System.err.println(ex.getMessage());

    }

}

From source file:reporteFertilizacion.ReporteResultadoLaboratorio.java

/**
 * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
 * methods.//  w w w. j  ava2s.c o m
 *
 * @param request servlet request
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    response.setContentType("application/pdf");
    try {
        Font font9BoldWhite = FontFactory.getFont(FontFactory.HELVETICA, 9, Font.BOLD, BaseColor.WHITE);
        Font font7Bold = FontFactory.getFont(FontFactory.HELVETICA, 7, Font.BOLD);
        Font font7Normal = FontFactory.getFont(FontFactory.HELVETICA, 7, Font.NORMAL);
        Font font8Bold = FontFactory.getFont(FontFactory.HELVETICA, 8, Font.BOLD);
        Font font8Normal = FontFactory.getFont(FontFactory.HELVETICA, 8, Font.NORMAL);
        Font font9Bold = FontFactory.getFont(FontFactory.HELVETICA, 9, Font.BOLD);
        Font font9Normal = FontFactory.getFont(FontFactory.HELVETICA, 9, Font.NORMAL);
        Font font10Bold = FontFactory.getFont(FontFactory.HELVETICA, 10, Font.BOLD);
        Font font10Normal = FontFactory.getFont(FontFactory.HELVETICA, 10, Font.NORMAL);
        Font font12Bold = FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD);
        Font font12Normal = FontFactory.getFont(FontFactory.HELVETICA, 12, Font.NORMAL);
        Font font14Bold = FontFactory.getFont(FontFactory.HELVETICA, 14, Font.BOLD);
        Font font14Normal = FontFactory.getFont(FontFactory.HELVETICA, 14, Font.NORMAL);
        Font font18Bold = FontFactory.getFont(FontFactory.HELVETICA, 18, Font.BOLD);
        Font font22Bold = FontFactory.getFont(FontFactory.HELVETICA, 22, Font.BOLD);

        //obtencion parametros *********************************************************
        FacesContext facesContext = FacesContext.getCurrentInstance();
        Map params = facesContext.getExternalContext().getRequestParameterMap();
        ObjectId parametroObtenido = new ObjectId(params.get("idMuestra").toString());

        ResultadoLaboratorio resLab = ResultadoLaboratorio.getResultadoLaboratorioById(parametroObtenido);
        MuestraLaboratorio muestra = MuestraLaboratorio.getMuestraLaboratorioById(resLab.getMuestra());
        Cliente cli = Cliente.getClienteById(
                Hacienda.getHaciendaById(muestra.getSiembraCultivo().getIdHacienda()).getIdCliente());
        Hacienda hac = Hacienda
                .getHaciendaById(Hacienda.getHaciendaById(muestra.getSiembraCultivo().getIdHacienda()).getId());
        //Lote lot = Lote.getLoteById(muestra.getLote());
        //String lot = muestra.getLote();
        Cultivo cul = Cultivo.getCultivoById(muestra.getSiembraCultivo().getIdCultivo());

        String cliente = cli.getNombre().toUpperCase();
        String ubicacion = Canton.getCantonById(cli.getCanton()).getNombre() + " - "
                + Canton.getCantonById(cli.getCanton()).getLeyendaProvincia() + " - "
                + Canton.getCantonById(cli.getCanton()).getLeyendaPais();
        String codigMuestra = muestra.getCodigo();

        String hacienda = hac.getNombre();
        String cultivo = cul.getNombre();
        //String varie = Variedad.getVariedadById(lot.getIdVariedad()).getNombre();
        String varie = muestra.getSiembraCultivo().getLeyendaVariedad();
        //String estacionMonitoreo = lot.getEstacion().get(0).getCodigo();
        String estacionMonitoreo = muestra.getSiembraCultivo().getUnidadManejo();
        //String estacionMonitoreo = muestra.getLoteCompleto().getListadoMonitoreo().get(0).getCodigo();
        String tituloProyecto = "Anlisis" + resLab.getLeyendaMatriz();
        String tipoMuestra = resLab.getLeyendaMatriz();
        String numeroMuestra = Integer.toString(
                MuestraLaboratorio.getNumberMuestraLaboratorio(muestra.getId(), muestra.getIdSiembraCultivo()));
        String numeroMonitoreo = numeroMuestra;
        //String lote = lot.getCodigo();
        String lote = "";
        int nn = muestra.getSiembraCultivo().getListaLotesSiembra().size();
        for (int i = 0; i < nn; i++) {
            lote = lote.concat(muestra.getSiembraCultivo().getListaLotesSiembra().get(i).getLeyendaLote());
        }

        String muestreador = muestra.getMuestreador();
        String fechaMuestreo = muestra.getFechaFormatMuestreo();
        String fechaRecepcionMuestra = muestra.getFechaFormatEnvio();
        String fechaResultado = resLab.getFechaFormatResultado();
        String periodoPrueba = resLab.getFechaFormatRecepcion() + " al " + resLab.getFechaFormatResultado();

        String contenidoHoja1 = TextoReporteResultadoLaboratorio.getByReferencia("HOJA 1 TEXTO INFORME")
                .getDescripcion();
        String responsableTecnico = TextoReporteResultadoLaboratorio.getByReferencia("RESPONSABLE TECNICO")
                .getDescripcion();
        String datosLaboratorio = TextoReporteResultadoLaboratorio.getByReferencia("DATOS LABORATORIO")
                .getDescripcion();
        String piePagina = TextoReporteResultadoLaboratorio.getByReferencia("PIE DE PAGINA").getDescripcion();
        String contenidoHoja2 = TextoReporteResultadoLaboratorio.getByReferencia("HOJA 2 OBSERVACION")
                .getDescripcion();

        //fin obtencion parametros *****************************************************

        /* TODO output your page here. You may use following sample code. */
        float left = 60;
        float right = 30;
        float top = 0;
        float bottom = 0;
        Document document = new Document(PageSize.A4, left, right, top, bottom);
        PdfWriter writer = PdfWriter.getInstance(document, response.getOutputStream());

        //FOOTER TABLE *****************************************************************
        PdfPTable table = new PdfPTable(1);
        table.setTotalWidth(550);
        PdfPCell cell = new PdfPCell(new Phrase(piePagina, font8Normal));
        cell.setBackgroundColor(BaseColor.GREEN);
        cell.setBorder(PdfPCell.NO_BORDER);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase("www.agrorum.com.ec", font9BoldWhite));
        cell.setBackgroundColor(BaseColor.ORANGE);
        cell.setBorder(PdfPCell.NO_BORDER);
        cell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
        table.addCell(cell);

        FooterTable event = new FooterTable(table);
        writer.setPageEvent(event);
        //FIN FOOTER TABLE *****************************************************************

        document.open();

        //HOJA 1 *********************************************************************************************************************************                        
        //IMAGE **********************************************************************************
        String relativeWebPathAg = "/images/agrorum.png";
        String absoluteDiskPathAg = getServletContext().getRealPath(relativeWebPathAg);
        Image logoAg = Image.getInstance(absoluteDiskPathAg);
        logoAg.setAbsolutePosition(10f, 750f);
        logoAg.scalePercent(80f);
        document.add(logoAg);

        String relativeWebPathEu = "/images/eurofins.png";
        String absoluteDiskPathEu = getServletContext().getRealPath(relativeWebPathEu);
        Image logoEu = Image.getInstance(absoluteDiskPathEu);
        logoEu.setAbsolutePosition(500f, 770f);
        logoEu.scalePercent(60f);
        document.add(logoEu);
        //FIN IMAGE ********************************************************************************         

        //CLIENTE UBICACION MUESTRA*****************************************************************
        Paragraph parphRepor = new Paragraph("Reporte de anlisis 1/2", font10Normal);
        parphRepor.setAlignment(Element.ALIGN_RIGHT);
        parphRepor.setSpacingBefore(90f);
        Paragraph parphCli = new Paragraph(cliente, font10Bold);
        parphCli.setAlignment(Element.ALIGN_LEFT);
        parphCli.setSpacingBefore(15f);
        Paragraph parphUbi = new Paragraph(ubicacion, font10Bold);
        parphUbi.setAlignment(Element.ALIGN_LEFT);
        parphUbi.setSpacingBefore(15f);
        //PARRAFO combinado con frases********************************************
        Phrase p1 = new Phrase("Cdigo de la Muestra:     ", font10Normal);
        Phrase p2 = new Phrase(codigMuestra, font10Bold);
        Paragraph parphMue = new Paragraph(p1);
        parphMue.add(p2);
        parphMue.setAlignment(Element.ALIGN_LEFT);
        parphMue.setSpacingBefore(15f);
        //FIN PARRAFO combinado***************************************************

        document.add(parphRepor);
        document.add(parphCli);
        document.add(parphUbi);
        document.add(parphMue);

        //FIN CLIENTE UBICACION MUESTRA*************************************************************
        //TABLA ***********************************************************************************
        PdfPTable tableDatos = new PdfPTable(new float[] { 0.20f, 0.80f });
        tableDatos.setWidthPercentage(100);

        tableDatos.addCell(getCell("Propiedad:", PdfPCell.ALIGN_LEFT, font8Normal));
        tableDatos.addCell(getCell(hacienda, PdfPCell.ALIGN_LEFT, font8Bold));

        tableDatos.addCell(getCell("Cultivo Actual:", PdfPCell.ALIGN_LEFT, font8Normal));
        tableDatos.addCell(getCell(cultivo, PdfPCell.ALIGN_LEFT, font8Bold));

        tableDatos.addCell(getCell("Estacin Monitoreo:", PdfPCell.ALIGN_LEFT, font8Normal));
        tableDatos.addCell(getCell(estacionMonitoreo, PdfPCell.ALIGN_LEFT, font8Bold));

        tableDatos.addCell(getCell("Ttulo Proyecto:", PdfPCell.ALIGN_LEFT, font8Normal));
        tableDatos.addCell(getCell(tituloProyecto, PdfPCell.ALIGN_LEFT, font8Bold));

        tableDatos.addCell(getCell("Tipo Muestra:", PdfPCell.ALIGN_LEFT, font8Normal));
        tableDatos.addCell(getCell(tipoMuestra, PdfPCell.ALIGN_LEFT, font8Bold));

        tableDatos.addCell(getCell("Nmero Muestra:", PdfPCell.ALIGN_LEFT, font8Normal));
        tableDatos.addCell(getCell(numeroMuestra, PdfPCell.ALIGN_LEFT, font8Bold));

        tableDatos.addCell(getCell("Nmero Monitoreo:", PdfPCell.ALIGN_LEFT, font8Normal));
        tableDatos.addCell(getCell(numeroMonitoreo, PdfPCell.ALIGN_LEFT, font8Bold));

        tableDatos.addCell(getCell("Lote:", PdfPCell.ALIGN_LEFT, font8Normal));
        tableDatos.addCell(getCell(lote, PdfPCell.ALIGN_LEFT, font8Bold));

        tableDatos.addCell(getCell("Muestreador:", PdfPCell.ALIGN_LEFT, font8Normal));
        tableDatos.addCell(getCell(muestreador.toUpperCase(), PdfPCell.ALIGN_LEFT, font8Bold));

        tableDatos.addCell(getCell("Fecha Muestreo:", PdfPCell.ALIGN_LEFT, font8Normal));
        tableDatos.addCell(getCell(fechaMuestreo, PdfPCell.ALIGN_LEFT, font8Bold));

        tableDatos.addCell(getCell("Recepcin Muestra:", PdfPCell.ALIGN_LEFT, font8Normal));
        tableDatos.addCell(getCell(fechaRecepcionMuestra, PdfPCell.ALIGN_LEFT, font8Bold));

        tableDatos.addCell(getCell("Perodo de Prueba:", PdfPCell.ALIGN_LEFT, font8Normal));
        tableDatos.addCell(getCell(periodoPrueba, PdfPCell.ALIGN_LEFT, font8Bold));

        tableDatos.setSpacingBefore(20f);
        document.add(tableDatos);
        //FIN TABLA ********************************************************************************

        //CONTENIDO ********************************************************************************
        Paragraph parphCont = new Paragraph(contenidoHoja1, font8Normal);
        parphCont.setAlignment(Element.ALIGN_JUSTIFIED);
        parphCont.setSpacingBefore(20f);

        Paragraph parphLLeida = new Paragraph("LLeida, " + fechaResultado, font8Normal);
        parphLLeida.setAlignment(Element.ALIGN_LEFT);
        parphLLeida.setSpacingBefore(20f);

        Paragraph parphTecnico = new Paragraph(responsableTecnico, font9Bold);
        parphTecnico.setAlignment(Element.ALIGN_LEFT);
        parphTecnico.setSpacingBefore(20f);

        Paragraph parphResponsable = new Paragraph("Responsable Tcnico", font8Normal);
        parphResponsable.setAlignment(Element.ALIGN_LEFT);
        parphResponsable.setSpacingBefore(1f);

        Paragraph parphLaboratorio = new Paragraph(datosLaboratorio, font8Bold);
        parphLaboratorio.setAlignment(Element.ALIGN_LEFT);
        parphLaboratorio.setSpacingBefore(30f);

        document.add(parphCont);
        document.add(parphLLeida);
        document.add(parphTecnico);
        document.add(parphResponsable);
        document.add(parphLaboratorio);
        //FIN CONTENIDO ****************************************************************************

        //FIN HOJA 1 *****************************************************************************************************************************
        document.newPage();

        //HOJA 2 *********************************************************************************************************************************                        
        //IMAGE **********************************************************************************
        String relativeWebPathAg1 = "/images/agrorum.png";
        String absoluteDiskPathAg1 = getServletContext().getRealPath(relativeWebPathAg1);
        Image logoAg1 = Image.getInstance(absoluteDiskPathAg1);
        logoAg1.setAbsolutePosition(10f, 750f);
        logoAg1.scalePercent(80f);
        document.add(logoAg1);

        String relativeWebPathEu1 = "/images/eurofins.png";
        String absoluteDiskPathEu1 = getServletContext().getRealPath(relativeWebPathEu1);
        Image logoEu1 = Image.getInstance(absoluteDiskPathEu1);
        logoEu1.setAbsolutePosition(500f, 770f);
        logoEu1.scalePercent(60f);
        document.add(logoEu1);

        Paragraph ini = new Paragraph("", font12Bold);
        ini.setAlignment(Element.ALIGN_CENTER);
        ini.setSpacingBefore(100f);

        PdfPTable cabT = new PdfPTable(new float[] { 1f });
        cabT.setWidthPercentage(100);
        PdfPCell cellCab = new PdfPCell(new Phrase("Informe de Prueba", font12Bold));
        cellCab.setPadding(2f);
        cellCab.setHorizontalAlignment(Element.ALIGN_CENTER);
        cabT.addCell(cellCab);

        Paragraph parphRep = new Paragraph("Reporte de anlisis 2/2", font10Normal);
        parphRep.setAlignment(Element.ALIGN_RIGHT);

        document.add(ini);
        document.add(cabT);
        document.add(parphRep);

        //TABLA ***********************************************************************************
        PdfPTable tableDatosH2 = new PdfPTable(new float[] { 0.20f, 0.80f });
        tableDatosH2.setWidthPercentage(100);

        tableDatosH2.addCell(getCell("Cliente:", PdfPCell.ALIGN_LEFT, font8Normal));
        tableDatosH2.addCell(getCell(cliente, PdfPCell.ALIGN_LEFT, font8Bold));

        tableDatosH2.addCell(getCell(" ", PdfPCell.ALIGN_LEFT, font8Normal));
        tableDatosH2.addCell(getCell(" ", PdfPCell.ALIGN_LEFT, font8Bold));

        tableDatosH2.addCell(getCell("Propiedad:", PdfPCell.ALIGN_LEFT, font8Normal));
        tableDatosH2.addCell(getCell(hacienda, PdfPCell.ALIGN_LEFT, font8Bold));

        tableDatosH2.addCell(getCell("Estacin Monitoreo:", PdfPCell.ALIGN_LEFT, font8Normal));
        tableDatosH2.addCell(getCell(estacionMonitoreo, PdfPCell.ALIGN_LEFT, font8Bold));

        tableDatosH2.addCell(getCell("Nmero Monitoreo:", PdfPCell.ALIGN_LEFT, font8Normal));
        tableDatosH2.addCell(getCell(numeroMuestra, PdfPCell.ALIGN_LEFT, font8Bold));

        tableDatosH2.addCell(getCell("Codigo Muestra:", PdfPCell.ALIGN_LEFT, font8Normal));
        tableDatosH2.addCell(getCell(codigMuestra, PdfPCell.ALIGN_LEFT, font8Bold));

        tableDatosH2.addCell(getCell("Matriz:", PdfPCell.ALIGN_LEFT, font8Normal));
        tableDatosH2.addCell(getCell(tipoMuestra, PdfPCell.ALIGN_LEFT, font8Bold));

        tableDatosH2.addCell(getCell("Cultivo:", PdfPCell.ALIGN_LEFT, font8Normal));
        tableDatosH2.addCell(getCell(cultivo, PdfPCell.ALIGN_LEFT, font8Bold));

        tableDatosH2.addCell(getCell("Variedad:", PdfPCell.ALIGN_LEFT, font8Normal));
        tableDatosH2.addCell(getCell(varie, PdfPCell.ALIGN_LEFT, font8Bold));

        tableDatosH2.addCell(getCell("Fecha Muestreo:", PdfPCell.ALIGN_LEFT, font8Normal));
        tableDatosH2.addCell(getCell(fechaMuestreo, PdfPCell.ALIGN_LEFT, font8Bold));

        tableDatosH2.addCell(getCell("Recepcin Muestra:", PdfPCell.ALIGN_LEFT, font8Normal));
        tableDatosH2.addCell(getCell(fechaRecepcionMuestra, PdfPCell.ALIGN_LEFT, font8Bold));

        tableDatosH2.addCell(getCell("Perodo de Prueba:", PdfPCell.ALIGN_LEFT, font8Normal));
        tableDatosH2.addCell(getCell(periodoPrueba, PdfPCell.ALIGN_LEFT, font8Bold));

        tableDatosH2.setSpacingBefore(20f);
        document.add(tableDatosH2);
        //FIN TABLA ********************************************************************************

        Paragraph parphCont1 = new Paragraph(contenidoHoja2, font8Normal);
        parphCont1.setAlignment(Element.ALIGN_JUSTIFIED);
        parphCont1.setSpacingBefore(20f);

        PdfPTable tableDatosH3 = new PdfPTable(new float[] { 0.30f, 0.70f });
        tableDatosH3.setWidthPercentage(100);

        tableDatosH3.addCell(getCell(datosLaboratorio, PdfPCell.ALIGN_LEFT, font8Bold));

        PdfPTable subTable = new PdfPTable(new float[] { 1f });
        subTable.setWidthPercentage(100);

        subTable.addCell(getCell("LLeida, " + fechaResultado, PdfPCell.ALIGN_CENTER, font8Normal));
        subTable.addCell(getCell(" ", PdfPCell.ALIGN_CENTER, font8Normal));
        subTable.addCell(getCell(" ", PdfPCell.ALIGN_CENTER, font8Normal));
        subTable.addCell(getCell(" ", PdfPCell.ALIGN_CENTER, font8Normal));

        subTable.addCell(getCell(responsableTecnico, PdfPCell.ALIGN_CENTER, font9Bold));
        subTable.addCell(getCell("Responsable Tcnico", PdfPCell.ALIGN_CENTER, font8Normal));

        PdfPCell cellsub = new PdfPCell(subTable);
        cellsub.setBorder(PdfPCell.NO_BORDER);
        cellsub.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        tableDatosH3.addCell(cellsub);

        tableDatosH3.setSpacingBefore(20f);

        document.add(parphCont1);
        document.add(tableDatosH3);

        //FIN IMAGE ********************************************************************************            
        //FIN HOJA 2 *****************************************************************************************************************************
        document.close();
    } catch (DocumentException de) {
        throw new IOException(de.getMessage());
    }
}

From source file:Reportes.ReportePersonal.java

public PdfPTable tablaDatos() {

    PdfPTable tabla = null;//from  w  w w.ja va 2s. com
    int numeroColumnas;

    String tipoDoc, documento, nombre, correo, perfil;
    String V[] = new String[6];

    PdfPCell celda;
    // Se obtiene el numero de columnas.
    numeroColumnas = 5;
    tabla = new PdfPTable(numeroColumnas);//construye una tabla con el nmero de columnas requeridas

    while (Nodo != null) // recorre cada registro del resultset
    {
        tipoDoc = Nodo.getUsuario().getTipoDoc();
        documento = Nodo.getUsuario().getDocumento();
        nombre = Nodo.getUsuario().getNombre();
        correo = Nodo.getUsuario().getCorreo();
        perfil = Nodo.getUsuario().getPerfil();

        V[0] = tipoDoc;
        V[1] = documento;
        V[2] = nombre;
        V[3] = correo;
        V[4] = perfil;

        for (int i = 0; i < numeroColumnas; i++)//lee cada campo del registro activo
        {
            String fila = V[i];
            celda = new PdfPCell(
                    new Paragraph(fila, FontFactory.getFont("arial", 12, Font.NORMAL, BaseColor.BLACK)));
            celda.setBackgroundColor(BaseColor.WHITE);
            tabla.addCell(celda);
        }
        Nodo = Nodo.getLiga();
    }

    return tabla;
}

From source file:ro.ldir.chartpackage.GarbagePackageBuilder.java

License:Open Source License

public void writePDF(OutputStream out)
        throws DocumentException, MalformedURLException, XPathExpressionException, IOException {
    BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, "Cp1250", BaseFont.NOT_EMBEDDED);
    final Font hfFont = new Font(bf, 8, Font.NORMAL, BaseColor.GRAY);

    Document document = new Document(PageSize.A4, 50, 50, 50, 50);
    PdfWriter writer = PdfWriter.getInstance(document, out);
    writer.setBoxSize("art", new Rectangle(36, 54, 559, 788));

    writer.setPageEvent(new PdfPageEventHelper() {
        private int page = 0;

        @Override/*  w  ww . j a v a 2s. c om*/
        public void onEndPage(PdfWriter writer, Document arg1) {
            page++;
            Rectangle rect = writer.getBoxSize("art");
            ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_CENTER,
                    new Phrase("Pachet mormane - \u00a9 Let's Do It, Romania!", hfFont),
                    (rect.getLeft() + rect.getRight()) / 2, rect.getTop() + 18, 0);
            ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_CENTER,
                    new Phrase("- " + page + " -", hfFont), (rect.getLeft() + rect.getRight()) / 2,
                    rect.getBottom() - 18, 0);
        }
    });

    document.open();
    document.addAuthor("Let's Do It, Romania!");
    document.addTitle("Pachet mormane");
    document.addCreationDate();

    Font titleFont = new Font(bf, 24, Font.BOLD);
    Font noteFont = new Font(bf, 12, Font.NORMAL, BaseColor.RED);
    Font headerFont = new Font(bf, 12, Font.BOLD);
    Font normalFont = new Font(bf, 11);
    Font defFont = new Font(bf, 11, Font.BOLD);
    Paragraph par;
    int page = 0;

    for (Garbage garbage : garbages) {
        par = new Paragraph();
        par.setAlignment(Element.ALIGN_CENTER);
        par.add(new Chunk("Morman " + garbage.getGarbageId() + "\n", titleFont));
        par.add(new Chunk("Citi\u0163i cu aten\u0163ie!", noteFont));
        document.add(par);

        par = new Paragraph();
        par.setSpacingBefore(20);
        par.add(new Chunk("1. Date generale\n", headerFont));
        par.add(new Chunk("Jude\u0163ul: ", defFont));
        par.add(new Chunk(garbage.getCounty().getName() + "\n", normalFont));
        par.add(new Chunk("Comuna: ", defFont));
        par.add(new Chunk(garbage.getTown().getName() + "\n", normalFont));
        if (garbage.getChartedArea() != null) {
            par.add(new Chunk("Zona cartare: ", defFont));
            par.add(new Chunk(garbage.getChartedArea().getName() + "\n", normalFont));
        }
        par.add(new Chunk("Pozi\u0163ie: ", defFont));
        par.add(new Chunk(garbage.getY() + ", " + garbage.getX() + "\n", normalFont));
        par.add(new Chunk("Descriere:\n", defFont));
        par.add(new Phrase(garbage.getDescription() + "\n", normalFont));
        par.add(new Chunk("Componen\u0163\u0103 gunoi:\n", defFont));
        List list = new List();
        list.add(new ListItem(
                new Chunk("Procent plastic: " + garbage.getPercentagePlastic() + "%", normalFont)));
        list.add(new ListItem(
                new Chunk("Procent sticl\u0103: " + garbage.getPercentageGlass() + "%", normalFont)));
        list.add(new ListItem(new Chunk("Procent metale: " + garbage.getPercentageMetal() + "%", normalFont)));
        list.add(new ListItem(
                new Chunk("Procent nereciclabile: " + garbage.getPercentageWaste() + "%", normalFont)));
        par.add(list);
        document.add(par);

        par = new Paragraph();
        par.setSpacingBefore(20);
        par.add(new Chunk("2. Indica\u0163ii rutiere\n", headerFont));
        Image img = Image.getInstance(getImage(garbage));
        img.scaleToFit((float) (PageSize.A4.getWidth() * .75), (float) (PageSize.A4.getHeight() * .75));
        img.setAlignment(Element.ALIGN_CENTER);
        par.add(img);
        document.add(par);

        if (page < garbages.size() - 1)
            document.newPage();
        page++;
    }

    document.close();
}

From source file:ro.nextreports.engine.exporter.PdfExporter.java

License:Apache License

private void updateFont(Map<String, Object> style, Font fnt) {
    if (style.containsKey(StyleFormatConstants.FONT_FAMILY_KEY)) {
        String val = (String) style.get(StyleFormatConstants.FONT_FAMILY_KEY);
        fnt.setFamily(val);
    }//from  w ww  .j a v  a2 s.c o  m
    if (style.containsKey(StyleFormatConstants.FONT_SIZE)) {
        Float val = (Float) style.get(StyleFormatConstants.FONT_SIZE);
        fnt.setSize(val);
    }
    if (style.containsKey(StyleFormatConstants.FONT_COLOR)) {
        Color val = (Color) style.get(StyleFormatConstants.FONT_COLOR);
        fnt.setColor(new BaseColor(val));
    }
    if (style.containsKey(StyleFormatConstants.FONT_STYLE_KEY)) {
        if (StyleFormatConstants.FONT_STYLE_NORMAL.equals(style.get(StyleFormatConstants.FONT_STYLE_KEY))) {
            fnt.setStyle(Font.NORMAL);
        }
        if (StyleFormatConstants.FONT_STYLE_BOLD.equals(style.get(StyleFormatConstants.FONT_STYLE_KEY))) {
            fnt.setStyle(Font.BOLD);
        }
        if (StyleFormatConstants.FONT_STYLE_ITALIC.equals(style.get(StyleFormatConstants.FONT_STYLE_KEY))) {
            fnt.setStyle(Font.ITALIC);
        }
        if (StyleFormatConstants.FONT_STYLE_BOLDITALIC.equals(style.get(StyleFormatConstants.FONT_STYLE_KEY))) {
            fnt.setStyle(Font.BOLDITALIC);
        }
    }
}

From source file:ro.nextreports.engine.exporter.PdfExporter.java

License:Apache License

private Font getFont(int size) {
    if (encoding == null) {
        return FontFactory.getFont(fontName, size);
    } else {//from   w ww . j  av  a  2s.  c o  m
        if (embeddedFont == null) {
            return FontFactory.getFont(fontName, encoding, size);
        } else {
            return FontFactory.getFont(embeddedFont, encoding, true, size, Font.NORMAL);
        }
    }
}