Example usage for com.itextpdf.text.pdf PdfPCell setBorderWidthTop

List of usage examples for com.itextpdf.text.pdf PdfPCell setBorderWidthTop

Introduction

In this page you can find the example usage for com.itextpdf.text.pdf PdfPCell setBorderWidthTop.

Prototype

public void setBorderWidthTop(final float borderWidthTop) 

Source Link

Document

Sets the width of the top border.

Usage

From source file:Export.DocNotaCredito.java

@SuppressWarnings("CallToPrintStackTrace")
private void docSeguros(String nomeSeguro, String interCod, String user, String arquivo, int idResseguro,
        TypeNotaCredito tnc) {//  w  w  w .j  a  v a  2 s  . co m
    String reString;
    try {

        Font fontCabecalhoN = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 9.2f);
        Font fontLinha = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 0.000000358f);
        Font fontCabecalhoS = FontFactory.getFont(Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 9.2f);
        Font fontCorpo = FontFactory.getFont(Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 8f);
        Font fontCorpoN = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 8f);
        Font fontNull = FontFactory.getFont(Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 4f);
        Font fontMenor = FontFactory.getFont(Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 3f);

        PdfPTable pTableEmpresaPricipal = new PdfPTable(new float[] { 80, 20 });
        pTableEmpresaPricipal.setWidthPercentage(95);
        PdfPTable pTableEmpresaInforImpres1 = new PdfPTable(1);
        PdfPTable pTableEmpresaInforImpres2 = new PdfPTable(1);
        PdfPTable pTableEmpresaInforImpres3 = new PdfPTable(2);
        PdfPTable pTableEmpresaInforImpres4 = new PdfPTable(2);
        PdfPTable pTableEmpresaInforImpres5 = new PdfPTable(1);

        DataResseguro resS = new DataResseguro();
        HashMap<String, Object> map = new LinkedHashMap<>();
        if (tnc == TypeNotaCredito.RESEGURO) {
            resS = DataReseguro.getDadosReseguro(idResseguro);
        } else {
            map = loadNotaConta();
        }

        PdfPTable pTableFatura = new PdfPTable(new float[] { 80, 20 });

        PdfPCell pCellNomeEmpresa = new PdfPCell(new Phrase(Empresa.NOME, fontCabecalhoN));
        pCellNomeEmpresa.setBorder(0);

        PdfPCell pCellNomeEndereco = new PdfPCell(new Phrase(Empresa.ENDERECO, fontCabecalhoN));
        pCellNomeEndereco.setBorder(0);

        PdfPCell pCellCaixaPostal = new PdfPCell(new Phrase(Empresa.CAIXAPOSTAL, fontCabecalhoN));
        pCellCaixaPostal.setBorder(0);

        PdfPCell pCellTeleFax = new PdfPCell(
                new Phrase(Empresa.TELEFAX + " " + ConfigDoc.Empresa.EMAIL, fontCabecalhoN));
        pCellTeleFax.setBorder(0);

        PdfPCell pCellSociedade = new PdfPCell(new Phrase(Empresa.SOCIEDADE, fontCabecalhoN));
        pCellSociedade.setBorder(0);

        PdfPCell pCellCapital = new PdfPCell(new Phrase(Empresa.CAPITALSOCIAL, fontCabecalhoN));
        pCellCapital.setBorder(0);

        PdfPCell pCellPolice = new PdfPCell(new Phrase(
                Empresa.APOLICE + ((TypeNotaCredito.RESEGURO == tnc) ? resS.getAPOLICE() : map.get(APOLICE)),
                fontCabecalhoN));
        pCellPolice.setBorder(0);

        PdfPCell pCellDebNF = new PdfPCell(new Phrase("Cre. N", fontCabecalhoS));
        pCellDebNF.setHorizontalAlignment(Element.ALIGN_RIGHT);
        pCellDebNF.setBorder(0);

        PdfPCell pCellDebN = new PdfPCell(new Phrase(
                ((TypeNotaCredito.RESEGURO == tnc) ? resS.getIDSEGURO() : map.get(ID) + ""), fontCabecalhoS));
        pCellDebN.setHorizontalAlignment(Element.ALIGN_CENTER);
        pCellDebN.setBorder(0);

        PdfPCell pCellInterCoF = new PdfPCell(new Phrase("Inter COD:", fontCabecalhoS));
        pCellInterCoF.setHorizontalAlignment(Element.ALIGN_RIGHT);
        pCellInterCoF.setBorder(0);

        PdfPCell pCellInterCo = new PdfPCell(new Phrase(interCod, fontCabecalhoS));
        pCellInterCo.setHorizontalAlignment(Element.ALIGN_CENTER);
        pCellInterCo.setBorder(0);

        Image imageEmpresa = Image.getInstance("logo.png");
        imageEmpresa.scaleToFit(120f, 100f);

        pTableEmpresaInforImpres1.addCell(pCellNomeEmpresa);
        pTableEmpresaInforImpres1.addCell(pCellNomeEndereco);
        pTableEmpresaInforImpres1.addCell(pCellCaixaPostal);
        pTableEmpresaInforImpres1.addCell(pCellTeleFax);
        pTableEmpresaInforImpres1.addCell(pCellSociedade);

        pTableEmpresaInforImpres2.addCell(pCellCapital);
        pTableEmpresaInforImpres2.addCell(pCellPolice);

        pTableEmpresaInforImpres3.addCell(pCellDebNF);
        pTableEmpresaInforImpres3.addCell(pCellDebN);
        pTableEmpresaInforImpres3.addCell(pCellInterCoF);
        pTableEmpresaInforImpres3.addCell(pCellInterCo);

        PdfPCell cellTabela1 = new PdfPCell(pTableEmpresaInforImpres2);
        cellTabela1.setBorder(0);

        pTableEmpresaInforImpres4.addCell(cellTabela1);

        PdfPCell cellTabela2 = new PdfPCell(pTableEmpresaInforImpres3);
        cellTabela2.setBorder(0);

        pTableEmpresaInforImpres4.addCell(cellTabela2);

        PdfPCell cellTabela3 = new PdfPCell(pTableEmpresaInforImpres1);
        cellTabela3.setBorder(0);

        pTableEmpresaInforImpres5.addCell(cellTabela3);

        PdfPCell cellTabela4 = new PdfPCell(pTableEmpresaInforImpres4);
        cellTabela4.setBorder(0);

        pTableEmpresaInforImpres5.addCell(cellTabela4);

        PdfPCell cellTabela5 = new PdfPCell(pTableEmpresaInforImpres5);
        cellTabela5.setBorder(0);

        pTableEmpresaPricipal.addCell(cellTabela5);

        PdfPCell cellTabela6 = new PdfPCell(imageEmpresa);
        cellTabela6.setBorder(0);
        cellTabela6.setHorizontalAlignment(Element.ALIGN_RIGHT);

        pTableEmpresaPricipal.addCell(cellTabela6);

        //
        PdfPTable pTableLinha = new PdfPTable(1);
        pTableLinha.setWidthPercentage(95);
        PdfPCell linha = new PdfPCell(new Phrase(" ", fontLinha));
        linha.setBorderWidthTop(0.5f);
        linha.setBorderWidthBottom(0);
        linha.setBorderWidthLeft(0);
        linha.setBorderWidthRight(0);
        pTableLinha.addCell(linha);

        PdfPTable pTableCorpoEndTitile = new PdfPTable(new float[] { 100 });
        pTableCorpoEndTitile.setWidthPercentage(95);
        PdfPCell cellCorpoEndTitile = new PdfPCell();
        Paragraph paragraphCorpoEndTitile = new Paragraph();

        Paragraph titile = new Paragraph("NOTA DE CREDITO", fontCabecalhoN);
        titile.setAlignment(Paragraph.ALIGN_CENTER);

        PdfPTable pTableNumNota = new PdfPTable(new float[] { 100f });

        Paragraph titileSub = new Paragraph(nomeSeguro, fontCabecalhoN);
        titileSub.setAlignment(Paragraph.ALIGN_CENTER);
        paragraphCorpoEndTitile.add(titile);

        if (tnc == TypeNotaCredito.ANULACAO) {
            PdfPCell titileNum = new PdfPCell(new Paragraph("Deb. N " + map.get(NOTADEBITO), fontCabecalhoN));
            titileNum.setBorder(PdfPCell.NO_BORDER);
            titileNum.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);

            pTableNumNota.addCell(titileNum);
            paragraphCorpoEndTitile.add(pTableNumNota);
        }

        paragraphCorpoEndTitile.add(titileSub);

        paragraphCorpoEndTitile.add(new Paragraph(" ", fontCorpo));
        paragraphCorpoEndTitile.add(new Paragraph(" ", fontCorpo));

        ArrayList<DataReseguro.DataEmpresa> listaDataEmpresas = new ArrayList<>();

        ClienteI ci = null;
        if (tnc == TypeNotaCredito.RESEGURO) {
            listaDataEmpresas = DataReseguro.getDadosEmpresa(idResseguro);
        } else {
            ci = new ClienteI(map.get(IDCLIENTE) + "");
        }

        Phrase pCr = new Phrase("BENEFICI?RIO: ", fontCabecalhoN);
        paragraphCorpoEndTitile.add(pCr);
        @SuppressWarnings("null")
        Phrase pCrTex = new Phrase(
                ((tnc == TypeNotaCredito.RESEGURO) ? resS.getCLIENTE() : map.get(BENEFICIARIO) + "\n"),
                fontCabecalhoS);
        paragraphCorpoEndTitile.add(pCrTex);

        Phrase pEndereco = new Phrase("Endereo: ".toUpperCase(), fontCabecalhoN);
        paragraphCorpoEndTitile.add(pEndereco);
        Phrase pEnderecoTex = new Phrase(
                ((tnc == TypeNotaCredito.RESEGURO) ? ConfigDoc.Empresa.ENDERECO : ci.getENDERECO_()) + "\n",
                fontCabecalhoS);
        paragraphCorpoEndTitile.add(pEnderecoTex);

        Phrase pPolice = new Phrase("Apolice: ".toUpperCase(), fontCabecalhoN);
        paragraphCorpoEndTitile.add(pPolice);
        Phrase pPoliceTex = new Phrase(
                ((tnc == TypeNotaCredito.RESEGURO) ? resS.getAPOLICE() : map.get(APOLICE)) + "\n",
                fontCabecalhoS);
        paragraphCorpoEndTitile.add(pPoliceTex);

        //                Phrase pInterCod = new Phrase("intermediry Code".toUpperCase(), fontCabecalhoN);
        //                paragraphCorpoEndTitile.add(pInterCod);
        //                Phrase pInterCodTex = new Phrase(/*SessionUtil.getUserlogado().getResidencia()*/"In ----\n", fontCabecalhoS);
        //                paragraphCorpoEndTitile.add(pInterCodTex);

        Phrase pDate = new Phrase("DATA: ".toUpperCase(), fontCabecalhoN);
        paragraphCorpoEndTitile.add(pDate);
        Phrase pDateTex = new Phrase(((TypeNotaCredito.ANULACAO != tnc) ? resS.getINICIO() + " " + resS.getFIM()
                : map.get(DATAINICIO) + " " + map.get(DATAFIM)) + "\n", fontCabecalhoS);
        paragraphCorpoEndTitile.add(pDateTex);

        Phrase pSegurado = new Phrase("Segurado: ".toUpperCase(), fontCabecalhoN);
        paragraphCorpoEndTitile.add(pSegurado);
        Phrase pSeguradoTex = new Phrase(
                ((tnc == TypeNotaCredito.RESEGURO) ? ConfigDoc.Empresa.NOME + "(" + resS.getCLIENTE() + ")"
                        : ci.getNOME_()),
                fontCabecalhoS);
        paragraphCorpoEndTitile.add(pSeguradoTex);

        paragraphCorpoEndTitile.add(new Paragraph(" ", fontCorpo));
        paragraphCorpoEndTitile.add(new Paragraph(" ", fontCorpo));

        //Tabela Principal
        PdfPTable pTableNotaCredito = new PdfPTable(new float[] { 21.5f, 21.5f, 22f, 27f, 7f });
        //            PdfPTable pTableNotaCreditos = new PdfPTable(new float[]{70f, 30f});
        pTableNotaCredito.setWidthPercentage(100f);
        //            pTableNotaCreditos.setWidthPercentage(100f);

        PdfPCell cellParticular = new PdfPCell(new Phrase("Particular".toUpperCase(), fontCorpoN));
        cellParticular.setBorderWidth(1);
        pTableNotaCredito.addCell(cellParticular);

        PdfPCell cellPremioGrosso = new PdfPCell(new Phrase("Prmio Grosso".toUpperCase(), fontCorpoN));
        cellPremioGrosso.setBorderWidth(1);
        pTableNotaCredito.addCell(cellPremioGrosso);

        PdfPCell cellComissaoDedutivel = new PdfPCell(
                new Phrase("Comisso Dedutvel".toUpperCase(), fontCorpoN));
        cellComissaoDedutivel.setBorderWidth(1);
        pTableNotaCredito.addCell(cellComissaoDedutivel);

        PdfPCell cellValorLiquidoD = new PdfPCell(new Phrase("Valor Liqudo Devido", fontCorpoN));
        cellValorLiquidoD.setBorderWidth(1);
        cellValorLiquidoD.setBorderWidthRight(0);
        pTableNotaCredito.addCell(cellValorLiquidoD);

        PdfPCell cellNull = new PdfPCell(new Phrase(" ", fontCorpoN));
        PdfPCell cellNull1 = new PdfPCell(new Phrase("(NET)", fontCorpoN));
        cellNull.setBorder(0);

        cellNull1.setBorderWidthTop(1);
        cellNull1.setBorderWidthRight(1);
        cellNull1.setBorderWidthLeft(0);
        cellNull1.setBorderWidthBottom(1);
        cellNull1.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);

        pTableNotaCredito.addCell(cellNull1);

        cellParticular = new PdfPCell(
                new Phrase(((TypeNotaCredito.RESEGURO == tnc) ? resS.getDESCRICAO().toUpperCase()
                        : map.get(DESCRICAO) + ""), fontCorpo));
        cellParticular.setBorderWidth(1);
        pTableNotaCredito.addCell(cellParticular);

        cellPremioGrosso = new PdfPCell(new Phrase(
                ((TypeNotaCredito.RESEGURO == tnc) ? Moeda.format(Double.valueOf(resS.getPREMIOGROSSO()))
                        : Moeda.format(Double.valueOf(map.get(PREMIOGROSSO) + ""))),
                fontCorpo));
        cellPremioGrosso.setBorderWidth(1);
        cellPremioGrosso.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cellPremioGrosso.setPaddingTop(30f);
        pTableNotaCredito.addCell(cellPremioGrosso);

        cellComissaoDedutivel = new PdfPCell(new Phrase(
                ((TypeNotaCredito.RESEGURO == tnc) ? resS.getDEDUCAO() + "%" : map.get(DECUCAO) + "%"),
                fontCorpo));
        cellComissaoDedutivel.setBorderWidth(1);
        cellComissaoDedutivel.setPaddingTop(30f);
        cellComissaoDedutivel.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        pTableNotaCredito.addCell(cellComissaoDedutivel);

        cellValorLiquidoD = new PdfPCell(new Phrase(
                Moeda.format(Double
                        .valueOf(((TypeNotaCredito.RESEGURO == tnc) ? resS.getTOTAL() : map.get(TOTAL) + ""))),
                fontCorpo));
        cellValorLiquidoD.setBorderWidth(1);
        cellValorLiquidoD.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cellValorLiquidoD.setPaddingTop(30f);
        cellValorLiquidoD.setPaddingBottom(75f);
        pTableNotaCredito.addCell(cellValorLiquidoD);

        pTableNotaCredito.addCell(cellNull);

        PdfPCell cellTotalDebito = new PdfPCell(new Phrase("TOTAL ", fontCorpoN));
        cellTotalDebito.setBorder(PdfPCell.NO_BORDER);
        cellTotalDebito.setColspan(3);
        pTableNotaCredito.addCell(cellTotalDebito);

        PdfPCell cellTotalDebitoV = new PdfPCell(new Phrase(
                Moeda.format(Double
                        .valueOf(((TypeNotaCredito.RESEGURO == tnc) ? resS.getTOTAL() : map.get(TOTAL) + ""))),
                fontCorpo));
        cellTotalDebitoV.setBorderWidth(1);
        cellTotalDebitoV.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        pTableNotaCredito.addCell(cellTotalDebitoV);

        pTableNotaCredito.addCell(cellNull);

        double cambio;
        double totalSTD = 0;
        if (!((TypeNotaCredito.RESEGURO == tnc) ? resS.getMOEDA() : map.get(SIGLADAMOEDA)).equals("STD")) {
            PdfPCell cellCambio = new PdfPCell(new Phrase(
                    "CAMBIO " + ((TypeNotaCredito.RESEGURO == tnc) ? resS.getMOEDA() : map.get(SIGLADAMOEDA)),
                    fontCorpoN));
            cellCambio.setBorder(PdfPCell.NO_BORDER);
            cellCambio.setColspan(3);
            pTableNotaCredito.addCell(cellCambio);

            cambio = valorCompra(
                    ((TypeNotaCredito.RESEGURO == tnc) ? resS.getMOEDA() : map.get(SIGLADAMOEDA) + ""),
                    ((TypeNotaCredito.RESEGURO == tnc) ? new Date() : map.get(CTT_DTREG)));

            PdfPCell cellCambioV = new PdfPCell(new Phrase(Moeda.format(cambio), fontCorpo));
            cellCambioV.setBorderWidth(1);
            cellCambioV.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
            pTableNotaCredito.addCell(cellCambioV);

            pTableNotaCredito.addCell(cellNull);

            PdfPCell cellValorDobras = new PdfPCell(new Phrase("VALOR EM DOBRAS", fontCorpoN));
            cellValorDobras.setBorder(PdfPCell.NO_BORDER);
            cellValorDobras.setColspan(3);
            pTableNotaCredito.addCell(cellValorDobras);

            totalSTD = cambio
                    * Double.valueOf((TypeNotaCredito.RESEGURO == tnc) ? resS.getTOTAL() : map.get(TOTAL) + "");
            PdfPCell cellValorDobrasV = new PdfPCell(new Phrase(Moeda.format(totalSTD), fontCorpo));
            cellValorDobrasV.setBorderWidth(1);
            cellValorDobrasV.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
            pTableNotaCredito.addCell(cellValorDobrasV);

            pTableNotaCredito.addCell(cellNull);
        }

        paragraphCorpoEndTitile.add(pTableNotaCredito);
        JTextPane jtp = new JTextPane();
        Moeda.EscreverEstenso(totalSTD, jtp, "Dobras");
        paragraphCorpoEndTitile.add(new Phrase("POR EXTENSO: ", fontCorpoN));
        paragraphCorpoEndTitile.add(new Phrase(jtp.getText().toUpperCase().trim() + "\n", fontCorpo));

        paragraphCorpoEndTitile.add(new Paragraph(" ", fontCorpoN));
        paragraphCorpoEndTitile.add(new Paragraph(" ", fontCorpoN));

        paragraphCorpoEndTitile.add(new Phrase("NOTA: ZERO PRMIO, ZERO COBERTURA", fontCorpoN));

        paragraphCorpoEndTitile.add(new Paragraph(" ", fontCorpoN));
        paragraphCorpoEndTitile.add(new Paragraph(" ", fontCorpoN));

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

        PdfPCell cellRodapeData = new PdfPCell(
                new Phrase(".......................................................", fontCorpo));
        cellRodapeData.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cellRodapeData.setBorder(PdfPCell.NO_BORDER);
        pTableRodape.addCell(cellRodapeData);

        PdfPCell cellRodapeVerificado = new PdfPCell(
                new Phrase(".......................................................", fontCorpoN));
        cellRodapeVerificado.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cellRodapeVerificado.setBorder(PdfPCell.NO_BORDER);
        pTableRodape.addCell(cellRodapeVerificado);

        PdfPCell cellAssinatura = new PdfPCell(
                new Phrase(".......................................................", fontCorpo));
        cellAssinatura.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cellAssinatura.setBorder(PdfPCell.NO_BORDER);
        pTableRodape.addCell(cellAssinatura);

        cellRodapeData = new PdfPCell(new Phrase(" ", fontCorpo));
        cellRodapeData.setBorder(PdfPCell.NO_BORDER);
        pTableRodape.addCell(cellRodapeData);

        cellRodapeVerificado = new PdfPCell(new Phrase("VERIFICADO POR", fontCorpoN));
        cellRodapeVerificado.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cellRodapeVerificado.setBorder(PdfPCell.NO_BORDER);
        pTableRodape.addCell(cellRodapeVerificado);

        cellAssinatura = new PdfPCell(new Phrase("ASSINATURA", fontCorpo));
        cellAssinatura.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cellAssinatura.setBorder(PdfPCell.NO_BORDER);
        pTableRodape.addCell(cellAssinatura);

        paragraphCorpoEndTitile.add(pTableRodape);

        cellCorpoEndTitile.addElement(paragraphCorpoEndTitile);

        cellCorpoEndTitile.setBorder(PdfPCell.NO_BORDER);

        pTableCorpoEndTitile.addCell(cellCorpoEndTitile);

        SimpleDateFormat sdf1 = new SimpleDateFormat("dd-MM-yyyy hh'.'mm'.'ss");

        Document documento = new Document();
        documento.setPageSize(PageSize.A4);
        documento.setMargins(20f, 20f, 70f, 5f);

        String f1 = (arquivo + "/" + interCod + "/Seguro " + nomeSeguro + "/");
        File f = new File(f1);
        String Ddata = sdf1.format(new Date());
        f.mkdirs();
        f = new File(f.getAbsoluteFile() + "/" + "Nota de Credito " + Ddata + ".pdf");

        reString = "../Documentos/" + interCod + "/Seguro " + nomeSeguro + "/" + "Nota de Credito " + Ddata
                + ".pdf";
        OutputStream outputStraem = new FileOutputStream(f);
        PdfWriter writer = PdfWriter.getInstance(documento, outputStraem);

        documento.open();
        documento.add(pTableEmpresaPricipal);
        documento.add(pTableLinha);
        documento.add(pTableLinha);
        documento.add(pTableCorpoEndTitile);
        documento.close();

        RequestContext.getCurrentInstance().execute("openAllDocument('" + reString + "')");
    } catch (FileNotFoundException | DocumentException e) {
        e.printStackTrace();
    } catch (IOException ex) {
        Logger.getLogger(DocNotaCredito.class.getName()).log(Level.SEVERE, null, ex);
    }

}

From source file:Export.DocNotaDebito.java

@SuppressWarnings({ "CallToPrintStackTrace", "null", "UnusedAssignment" })
public String docSeguros(String nomeSeguro, String numApolice, String interCodVendedor, String idCliente,
        String fundoContrato, ArrayList<String[]> listaValores, Contrato contrato, String user, String moeda,
        String arquivo, String numeroRegistro) {
    String reString;//  w  ww. ja va2s . c o  m
    try {

        Font fontCabecalhoN = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 9.2f);
        Font fontLinha = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 0.000000358f);
        Font fontCabecalhoS = FontFactory.getFont(Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 9.2f);
        Font fontCorpo = FontFactory.getFont(Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 8f);
        Font fontCorpoN = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 8f);
        Font fontNull = FontFactory.getFont(Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 4f);
        Font fontMenor = FontFactory.getFont(Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 3f);

        PdfPTable pTableEmpresaPricipal = new PdfPTable(new float[] { 80, 20 });
        pTableEmpresaPricipal.setWidthPercentage(95);
        PdfPTable pTableEmpresaInforImpres1 = new PdfPTable(1);
        PdfPTable pTableEmpresaInforImpres2 = new PdfPTable(1);
        PdfPTable pTableEmpresaInforImpres3 = new PdfPTable(2);
        PdfPTable pTableEmpresaInforImpres4 = new PdfPTable(2);
        PdfPTable pTableEmpresaInforImpres5 = new PdfPTable(1);

        PdfPTable pTableFatura = new PdfPTable(new float[] { 80, 20 });
        pTableFatura.setWidthPercentage(95);

        PdfPCell pCellNomeEmpresa = new PdfPCell(new Phrase(Empresa.NOME, fontCabecalhoN));
        pCellNomeEmpresa.setBorder(0);

        PdfPCell pCellNomeEndereco = new PdfPCell(new Phrase(Empresa.ENDERECO, fontCabecalhoN));
        pCellNomeEndereco.setBorder(0);

        PdfPCell pCellCaixaPostal = new PdfPCell(new Phrase(Empresa.CAIXAPOSTAL, fontCabecalhoN));
        pCellCaixaPostal.setBorder(0);

        PdfPCell pCellTeleFax = new PdfPCell(
                new Phrase(Empresa.TELEFAX + " " + ConfigDoc.Empresa.EMAIL, fontCabecalhoN));
        pCellTeleFax.setBorder(0);

        PdfPCell pCellSociedade = new PdfPCell(new Phrase(Empresa.SOCIEDADE, fontCabecalhoN));
        pCellSociedade.setBorder(0);

        PdfPCell pCellCapital = new PdfPCell(new Phrase(Empresa.CAPITALSOCIAL, fontCabecalhoN));
        pCellCapital.setBorder(0);

        PdfPCell pCellPolice = new PdfPCell(new Phrase(Empresa.APOLICE + numApolice, fontCabecalhoN));
        pCellPolice.setBorder(0);

        PdfPCell pCellDebNF = new PdfPCell(new Phrase("Deb. N", fontCabecalhoS));
        pCellDebNF.setHorizontalAlignment(Element.ALIGN_RIGHT);
        pCellDebNF.setBorder(0);

        PdfPCell pCellDebN = new PdfPCell(new Phrase(numeroRegistro, fontCabecalhoS));
        pCellDebN.setHorizontalAlignment(Element.ALIGN_CENTER);
        pCellDebN.setBorder(0);

        PdfPCell pCellInterCoF = new PdfPCell(new Phrase("Inter COD:", fontCabecalhoS));
        pCellInterCoF.setHorizontalAlignment(Element.ALIGN_RIGHT);
        pCellInterCoF.setBorder(0);

        PdfPCell pCellInterCo = new PdfPCell(new Phrase(interCodVendedor, fontCabecalhoS));
        pCellInterCo.setHorizontalAlignment(Element.ALIGN_CENTER);
        pCellInterCo.setBorder(0);

        Image imageEmpresa = Image.getInstance("logo.png");
        imageEmpresa.scaleToFit(120f, 100f);

        pTableEmpresaInforImpres1.addCell(pCellNomeEmpresa);
        pTableEmpresaInforImpres1.addCell(pCellNomeEndereco);
        pTableEmpresaInforImpres1.addCell(pCellCaixaPostal);
        pTableEmpresaInforImpres1.addCell(pCellTeleFax);
        pTableEmpresaInforImpres1.addCell(pCellSociedade);

        pTableEmpresaInforImpres2.addCell(pCellCapital);
        pTableEmpresaInforImpres2.addCell(pCellPolice);

        pTableEmpresaInforImpres3.addCell(pCellDebNF);
        pTableEmpresaInforImpres3.addCell(pCellDebN);
        pTableEmpresaInforImpres3.addCell(pCellInterCoF);
        pTableEmpresaInforImpres3.addCell(pCellInterCo);

        PdfPCell cellTabela1 = new PdfPCell(pTableEmpresaInforImpres2);
        cellTabela1.setBorder(0);

        pTableEmpresaInforImpres4.addCell(cellTabela1);

        PdfPCell cellTabela2 = new PdfPCell(pTableEmpresaInforImpres3);
        cellTabela2.setBorder(0);

        pTableEmpresaInforImpres4.addCell(cellTabela2);

        PdfPCell cellTabela3 = new PdfPCell(pTableEmpresaInforImpres1);
        cellTabela3.setBorder(0);

        pTableEmpresaInforImpres5.addCell(cellTabela3);

        PdfPCell cellTabela4 = new PdfPCell(pTableEmpresaInforImpres4);
        cellTabela4.setBorder(0);

        pTableEmpresaInforImpres5.addCell(cellTabela4);

        PdfPCell cellTabela5 = new PdfPCell(pTableEmpresaInforImpres5);
        cellTabela5.setBorder(0);

        pTableEmpresaPricipal.addCell(cellTabela5);

        PdfPCell cellTabela6 = new PdfPCell(imageEmpresa);
        cellTabela6.setBorder(0);
        cellTabela6.setHorizontalAlignment(Element.ALIGN_RIGHT);

        pTableEmpresaPricipal.addCell(cellTabela6);

        PdfPCell cellFaturaTitulo = new PdfPCell(new Phrase("FACTURA", fontCabecalhoN));
        cellFaturaTitulo.setBorder(0);
        cellFaturaTitulo.setHorizontalAlignment(Element.ALIGN_RIGHT);

        PdfPCell cellFaturaTipo = new PdfPCell(new Phrase(nomeSeguro, fontCabecalhoN));
        cellFaturaTipo.setHorizontalAlignment(Element.ALIGN_CENTER);
        cellFaturaTipo.setBorder(0);

        PdfPTable pTableLinha = new PdfPTable(1);
        pTableLinha.setWidthPercentage(95);
        PdfPCell linha = new PdfPCell(new Phrase(" ", fontLinha));
        linha.setBorderWidthTop(0.5f);
        linha.setBorderWidthBottom(0);
        linha.setBorderWidthLeft(0);
        linha.setBorderWidthRight(0);
        pTableLinha.addCell(linha);

        pTableFatura.addCell(cellFaturaTitulo);
        pTableFatura.addCell(cellFaturaTipo);

        PdfPTable pTableClientePrincipal = new PdfPTable(new float[] { 60, 10, 30 });
        pTableClientePrincipal.setWidthPercentage(95);
        PdfPTable pTableClienteDescisao = new PdfPTable(1);
        PdfPTable pTableDataEVenda = new PdfPTable(1);
        PdfPTable pTableTitulo = new PdfPTable(1);
        pTableTitulo.setWidthPercentage(95);

        ClienteI ci = null;
        ArrayList<DataReseguro.DataEmpresa> listaDataEmpresas = new ArrayList<>();
        if (!isReseguro) {
            ci = new ClienteI(idCliente);
        } else {
            listaDataEmpresas = DataReseguro.getDadosEmpresa(Integer.valueOf(idCliente));
        }

        Paragraph pCl = new Paragraph();
        pCl.add(new Phrase((isReseguro) ? "NOME: " : ci.getNOMEL_(), fontCorpo));
        pCl.add(new Phrase(
                (isReseguro) ? listaDataEmpresas.get(0).getEMPRESA().toUpperCase() + " (" + segurado + ")"
                        : ci.getNOME_(),
                fontCorpoN));
        PdfPCell cellNomeCliente = new PdfPCell(pCl);
        cellNomeCliente.setBorder(0);

        pCl = new Paragraph();
        pCl.add(new Phrase((isReseguro) ? "ENDEREO: " : ci.getENDERECOL_(), fontCorpo));
        pCl.add(new Phrase((isReseguro) ? listaDataEmpresas.get(0).getENDERECO() : ci.getENDERECO_(),
                fontCorpoN));
        if (!isReseguro) {
            pCl.add(new Phrase("       ", fontCorpoN));
            pCl.add(new Phrase((isReseguro) ? "" : ci.getCODPOSTALL_(), fontCorpo));
            pCl.add(new Phrase((isReseguro) ? "" : ci.getCODPOSTAL_(), fontCorpoN));
        }
        PdfPCell cellClienteMorada = new PdfPCell(pCl);
        cellClienteMorada.setBorder(0);

        PdfPCell cellNomeLocalidade = null;
        PdfPCell cellNomeTelefone = null;
        if (!isReseguro) {
            pCl = new Paragraph();
            pCl.add(new Phrase(ci.getLOCALTRABALHOL_(), fontCorpo));
            pCl.add(new Phrase(ci.getLOCALTRABALHO_(), fontCorpoN));
            cellNomeLocalidade = new PdfPCell(pCl);
            cellNomeLocalidade.setBorder(0);

            pCl = new Paragraph();
            pCl.add(new Phrase(ci.getTELEFONEL_(), fontCorpo));
            pCl.add(new Phrase(ci.getTELEFONE_(), fontCorpoN));
            cellNomeTelefone = new PdfPCell(pCl);
            cellNomeTelefone.setBorder(0);
        }

        SimpleDateFormat sdf = new SimpleDateFormat("dd 'de' MMMM 'de' yyyy", new Locale("pt", "BR"));
        SimpleDateFormat sdfContr = new SimpleDateFormat("dd-MM-yyyy");
        SimpleDateFormat sdf1 = new SimpleDateFormat("dd-MM-yyyy hh'.'mm'.'ss");
        PdfPCell cellDataContrato = new PdfPCell(new Phrase(
                "Data: " + (contrato.getDataInicio() != null ? sdfContr.format(contrato.getDataInicio()) : "")
                        + " - " + (contrato.getDataFim() != null ? sdfContr.format(contrato.getDataFim()) : ""),
                fontCorpo));
        cellDataContrato.setHorizontalAlignment(Element.ALIGN_CENTER);
        cellDataContrato.setVerticalAlignment(Element.ALIGN_BOTTOM);
        cellDataContrato.setBorderWidthTop(1f);
        cellDataContrato.setBorderWidthBottom(0f);
        cellDataContrato.setBorderWidthLeft(1f);
        cellDataContrato.setBorderWidthRight(1f);

        PdfPCell cellVendetor = new PdfPCell(new Phrase("Vendedor: "
                + ((!isReseguro) ? "NICON SEGUROS" : listaDataEmpresas.get(0).getEMPRESA().toUpperCase()),
                fontCorpo));
        cellVendetor.setHorizontalAlignment(Element.ALIGN_CENTER);
        cellVendetor.setVerticalAlignment(Element.ALIGN_TOP);
        cellVendetor.setBorderWidthTop(0f);
        cellVendetor.setBorderWidthBottom(1f);
        cellVendetor.setBorderWidthLeft(1f);
        cellVendetor.setBorderWidthRight(1f);

        pTableClienteDescisao.addCell(cellNomeCliente);
        pTableClienteDescisao.addCell(cellClienteMorada);
        if (!isReseguro) {
            pTableClienteDescisao.addCell(cellNomeLocalidade);
            pTableClienteDescisao.addCell(cellNomeTelefone);
        }

        PdfPCell cellZerro = new PdfPCell(new Phrase(" ", fontNull));
        cellZerro.setBorder(0);
        PdfPCell cellZerro2 = new PdfPCell(new Phrase(" "));
        cellZerro2.setBorderWidthTop(0f);
        cellZerro2.setBorderWidthBottom(0f);
        cellZerro2.setBorderWidthLeft(1f);
        cellZerro2.setBorderWidthRight(1f);

        PdfPTable pTableNull = new PdfPTable(1);
        pTableNull.setWidthPercentage(95);
        pTableNull.addCell(cellZerro);

        pTableDataEVenda.addCell(cellDataContrato);
        pTableDataEVenda.addCell(cellZerro2);
        pTableDataEVenda.addCell(cellVendetor);

        PdfPCell cellTitulo = new PdfPCell(new Phrase("Cliente", fontCabecalhoN));
        cellTitulo.setBorder(0);

        pTableTitulo.addCell(cellZerro);
        pTableTitulo.addCell(cellTitulo);

        PdfPCell cellCliente = new PdfPCell(pTableClienteDescisao);
        cellCliente.setBorder(0);

        PdfPCell cellCliente1 = new PdfPCell(pTableDataEVenda);
        cellCliente1.setBorder(0);

        pTableClientePrincipal.addCell(cellCliente);
        pTableClientePrincipal.addCell(cellZerro);
        pTableClientePrincipal.addCell(cellCliente1);

        PdfPCell cellQuan = new PdfPCell(new Phrase("QTD", fontCorpo));
        PdfPCell cellDescricao = new PdfPCell(new Phrase("Descrio", fontCorpo));
        PdfPCell cellValorUnitatio = new PdfPCell(new Phrase("Valor Unitrio", fontCorpo));
        PdfPCell cellTotal = new PdfPCell(new Phrase("Total", fontCorpo));
        PdfPTable TableRegistro = new PdfPTable(new float[] { 10, 45, 28, 17 });
        TableRegistro.setWidthPercentage(95);

        cellQuan.setBorderWidthBottom(1f);
        cellQuan.setBorderWidthTop(1f);
        cellQuan.setBorderWidthLeft(1f);
        cellQuan.setBorderWidthRight(1f);
        cellQuan.setHorizontalAlignment(Element.ALIGN_CENTER);
        cellQuan.setVerticalAlignment(Element.ALIGN_CENTER);

        cellDescricao.setBorderWidthBottom(1f);
        cellDescricao.setBorderWidthTop(1f);
        cellDescricao.setBorderWidthLeft(0.5f);
        cellDescricao.setBorderWidthRight(1f);
        cellDescricao.setHorizontalAlignment(Element.ALIGN_CENTER);
        cellDescricao.setVerticalAlignment(Element.ALIGN_CENTER);

        cellValorUnitatio.setBorderWidthBottom(1f);
        cellValorUnitatio.setBorderWidthTop(1f);
        cellValorUnitatio.setBorderWidthLeft(0.5f);
        cellValorUnitatio.setBorderWidthRight(1f);
        cellValorUnitatio.setHorizontalAlignment(Element.ALIGN_CENTER);
        cellValorUnitatio.setVerticalAlignment(Element.ALIGN_CENTER);

        cellTotal.setBorderWidthBottom(1f);
        cellTotal.setBorderWidthTop(1f);
        cellTotal.setBorderWidthLeft(0.5f);
        cellTotal.setBorderWidthRight(1f);
        cellTotal.setHorizontalAlignment(Element.ALIGN_CENTER);
        cellTotal.setVerticalAlignment(Element.ALIGN_CENTER);

        TableRegistro.addCell(cellQuan);
        TableRegistro.addCell(cellDescricao);
        TableRegistro.addCell(cellValorUnitatio);
        TableRegistro.addCell(cellTotal);

        int total = (listaValores.size() > 21) ? listaValores.size() : 18;

        boolean rulpas = false;
        for (int i = 0; i < total + 1; i++) {
            /**
             * Serve para add linha a Table <TableRegistro> e testa caso o ArrayList tenha
             * Menos linha que o <total> a Table <TableRegistro> continua recebendo dados Com String Vazios
             */
            if (listaValores.size() - 1 >= i || (listaValores.size() - 1 == i)) {
                //                    System.err.println(i);
                cellQuan = new PdfPCell(new Phrase(listaValores.get(i)[0], fontCorpo));
                cellDescricao = new PdfPCell(new Phrase(listaValores.get(i)[1], fontCorpo));
                cellValorUnitatio = new PdfPCell(new Phrase(listaValores.get(i)[2] + " "
                        + ((!nomeSeguro.equals("Viagem")) ? contrato.getSigla() : ""), fontCorpo));
                cellTotal = new PdfPCell(new Phrase(listaValores.get(i)[3] + " "
                        + ((!nomeSeguro.equals("Viagem") || listaValores.size() - 1 == i) ? contrato.getSigla()
                                : ""),
                        fontCorpo));

                cellQuan.setPaddingTop(2.5f);
                cellDescricao.setPaddingTop(2.5f);
                cellValorUnitatio.setPaddingTop(2.5f);
                cellTotal.setPaddingTop(2.5f);

                cellQuan.setPaddingBottom(2.5f);
                cellDescricao.setPaddingBottom(2.5f);
                cellValorUnitatio.setPaddingBottom(2.5f);
                cellTotal.setPaddingBottom(2.5f);

                cellQuan.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
                cellDescricao.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
                cellValorUnitatio.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
                cellTotal.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);

            } else {
                cellQuan = new PdfPCell(new Phrase(" ", fontCorpo));
                cellDescricao = new PdfPCell(new Phrase(" ", fontCorpo));
                cellValorUnitatio = new PdfPCell(new Phrase(" ", fontCorpo));
                cellTotal = new PdfPCell(new Phrase(" ", fontCorpo));
            }

            if (listaValores.size() - 1 == i && !rulpas) {
                cellDescricao.setRowspan(total - i);
                rulpas = true;
            }

            cellQuan.setBorderWidthBottom(0f);
            cellQuan.setBorderWidthTop((listaValores.size() - 1 == i) ? 1f : 0f);
            cellQuan.setHorizontalAlignment(Element.ALIGN_CENTER);

            cellDescricao.setBorderWidthBottom((listaValores.size() - 1 == i) ? 1f : 0f);
            cellDescricao.setBorderWidthTop((listaValores.size() - 1 == i) ? 1f : 0f);
            cellDescricao.setHorizontalAlignment(Element.ALIGN_CENTER);

            cellValorUnitatio.setBorderWidthBottom(0f);
            cellValorUnitatio.setBorderWidthTop((listaValores.size() - 1 == i) ? 1f : 0f);
            cellValorUnitatio.setHorizontalAlignment(Element.ALIGN_CENTER);

            cellTotal.setBorderWidthBottom(0f);
            cellTotal.setBorderWidthTop((listaValores.size() - 1 == i) ? 1f : 0f);
            cellTotal.setHorizontalAlignment(Element.ALIGN_CENTER);

            if (i + 1 == total) {
                cellQuan.setBorderWidthBottom(1f);
                cellDescricao.setBorderWidthBottom(1f);
                cellValorUnitatio.setBorderWidthBottom(1f);
                cellTotal.setBorderWidthBottom(1f);
            }

            TableRegistro.addCell(cellQuan);
            if (listaValores.size() - 1 >= i || listaValores.size() - 1 == i) {
                TableRegistro.addCell(cellDescricao);
            }

            TableRegistro.addCell(cellValorUnitatio);
            TableRegistro.addCell(cellTotal);
        }
        PdfPTable pTablePrincipalPagamento = new PdfPTable(new float[] { 55, 45 });
        pTablePrincipalPagamento.setWidthPercentage(95);
        PdfPTable pTableFomaPagamentoPricipal = new PdfPTable(1);
        PdfPTable pTableFomaPagamento = new PdfPTable(new float[] { 15, 50, 10 });
        PdfPTable pTableFomaValoresPricipal = new PdfPTable(1);
        PdfPTable pTableFomaValores = new PdfPTable(new float[] { 15, 47, 38 });

        PdfPCell cellvazio = new PdfPCell(new Phrase(" ", fontCorpo));
        PdfPCell cellTituloFormaPagamento = new PdfPCell(new Phrase("Forma de Pagamento", fontCorpoN));
        cellTituloFormaPagamento.setBorderWidthBottom(0f);
        cellTituloFormaPagamento.setBorderWidthTop(1f);
        cellTituloFormaPagamento.setBorderWidthRight(0f);
        cellTituloFormaPagamento.setBorderWidthLeft(0f);

        PdfPCell cellTituloForma1 = new PdfPCell(new Phrase(" Cheque", fontCorpo));
        cellTituloForma1.setBorderWidthBottom(0f);
        cellTituloForma1.setBorderWidthTop(0f);
        cellTituloForma1.setBorderWidthRight(0f);
        cellTituloForma1.setBorderWidthLeft(0f);

        PdfPCell cellTituloForma2 = new PdfPCell(new Phrase(" Dinheiro", fontCorpo));
        cellTituloForma2.setBorderWidthBottom(0f);
        cellTituloForma2.setBorderWidthTop(0f);
        cellTituloForma2.setBorderWidthRight(0f);
        cellTituloForma2.setBorderWidthLeft(0f);

        PdfPCell cellTituloForma3 = new PdfPCell(new Phrase(" Outros", fontCorpo));
        cellTituloForma3.setBorderWidthBottom(1f);
        cellTituloForma3.setBorderWidthTop(0f);
        cellTituloForma3.setBorderWidthRight(0f);
        cellTituloForma3.setBorderWidthLeft(0f);

        cellvazio.setBorderWidthBottom(0f);
        cellvazio.setBorderWidthTop(1f);
        cellvazio.setBorderWidthRight(0f);
        cellvazio.setBorderWidthLeft(1f);
        pTableFomaPagamento.addCell(cellvazio);
        pTableFomaPagamento.addCell(cellTituloFormaPagamento);
        cellvazio.setBorderWidthBottom(0f);
        cellvazio.setBorderWidthTop(1f);
        cellvazio.setBorderWidthRight(1f);
        cellvazio.setBorderWidthLeft(0f);
        pTableFomaPagamento.addCell(cellvazio);

        cellvazio.setBorderWidthBottom(0f);
        cellvazio.setBorderWidthTop(0f);
        cellvazio.setBorderWidthRight(0f);
        cellvazio.setBorderWidthLeft(1f);
        pTableFomaPagamento.addCell(cellvazio);
        pTableFomaPagamento.addCell(cellTituloForma1);
        cellvazio.setBorderWidthBottom(0f);
        cellvazio.setBorderWidthTop(0f);
        cellvazio.setBorderWidthRight(1f);
        cellvazio.setBorderWidthLeft(0f);
        pTableFomaPagamento.addCell(cellvazio);

        cellvazio.setBorderWidthBottom(0f);
        cellvazio.setBorderWidthTop(0f);
        cellvazio.setBorderWidthRight(0f);
        cellvazio.setBorderWidthLeft(1f);
        pTableFomaPagamento.addCell(cellvazio);
        pTableFomaPagamento.addCell(cellTituloForma2);
        cellvazio.setBorderWidthBottom(0f);
        cellvazio.setBorderWidthTop(0f);
        cellvazio.setBorderWidthRight(1f);
        cellvazio.setBorderWidthLeft(0f);
        pTableFomaPagamento.addCell(cellvazio);

        cellvazio.setBorderWidthBottom(1f);
        cellvazio.setBorderWidthTop(0f);
        cellvazio.setBorderWidthRight(0f);
        cellvazio.setBorderWidthLeft(1f);
        pTableFomaPagamento.addCell(cellvazio);
        pTableFomaPagamento.addCell(cellTituloForma3);
        cellvazio.setBorderWidthBottom(1f);
        cellvazio.setBorderWidthTop(0f);
        cellvazio.setBorderWidthRight(1f);
        cellvazio.setBorderWidthLeft(0f);
        pTableFomaPagamento.addCell(cellvazio);

        PdfPCell cellNull = new PdfPCell(new Phrase(" ", fontMenor));
        cellNull.setBorderWidthBottom(0f);
        cellNull.setBorderWidthTop(0f);
        cellNull.setBorderWidthRight(0f);
        cellNull.setBorderWidthLeft(0f);

        pTableFomaPagamentoPricipal.addCell(cellNull);
        PdfPCell cellPagamento = new PdfPCell(pTableFomaPagamento);
        cellPagamento.setBorder(0);
        pTableFomaPagamentoPricipal.addCell(cellPagamento);

        PdfPCell cellPecentage1 = new PdfPCell(new Phrase(((nomeSeguro.equals("Viagem") || isReseguro) ? " "
                : ((nomeSeguro.equals("Acidente Para Grupo")) ? " " : "2.50%")), fontCorpo));
        cellPecentage1.setHorizontalAlignment(Element.ALIGN_CENTER);
        cellPecentage1.setBorderWidthBottom(0f);
        cellPecentage1.setBorderWidthTop(1f);
        cellPecentage1.setBorderWidthRight(0f);
        cellPecentage1.setBorderWidthLeft(1f);

        PdfPCell cellPecentage2 = new PdfPCell(new Phrase((isReseguro) ? " " : "5%", fontCorpo));
        cellPecentage2.setHorizontalAlignment(Element.ALIGN_CENTER);
        cellPecentage2.setBorderWidthBottom(0f);
        cellPecentage2.setBorderWidthTop(0f);
        cellPecentage2.setBorderWidthRight(0f);
        cellPecentage2.setBorderWidthLeft(1f);

        PdfPCell cellPecentage3 = new PdfPCell(new Phrase(" ", fontCorpo));
        cellPecentage3.setHorizontalAlignment(Element.ALIGN_CENTER);
        cellPecentage3.setBorderWidthBottom(0f);
        cellPecentage3.setBorderWidthTop(0f);
        cellPecentage3.setBorderWidthRight(0f);
        cellPecentage3.setBorderWidthLeft(1f);

        PdfPCell cellFundo = new PdfPCell(new Phrase(fundoContrato, fontCorpo));
        cellFundo.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cellFundo.setBorderWidthBottom(0f);
        cellFundo.setBorderWidthTop(1f);
        cellFundo.setBorderWidthRight(0f);
        cellFundo.setBorderWidthLeft(0f);

        PdfPCell cellImposto = new PdfPCell(new Phrase((isReseguro) ? " " : "IMPOSTO", fontCorpo));
        cellImposto.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cellImposto.setBorderWidthBottom(0f);
        cellImposto.setBorderWidthTop(0f);
        cellImposto.setBorderWidthRight(0f);
        cellImposto.setBorderWidthLeft(0f);

        PdfPCell cellSelo = new PdfPCell(new Phrase((isReseguro) ? " " : "ACESSORIOS", fontCorpo));
        cellSelo.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cellSelo.setBorderWidthBottom(0f);
        cellSelo.setBorderWidthTop(0f);
        cellSelo.setBorderWidthRight(0f);
        cellSelo.setBorderWidthLeft(0f);

        PdfPCell cellvazio1;
        if (!isReseguro) {
            cellvazio1 = new PdfPCell(
                    new Phrase(
                            ((nomeSeguro.equals("Viagem"))
                                    ? ((contrato.getValorNC() == null || contrato.getValorNC().isEmpty())
                                            ? " "
                                            : Moeda.format(
                                                    Double.valueOf(contrato.getValorNC().replace(',', '.')))
                                                    + " EUR")
                                    : ((nomeSeguro.equals("Acidente Para Grupo")) ? " "
                                            : ((nomeSeguro.equals("Automovel")) ? Moeda.format(
                                                    (Double.valueOf(contrato.getPremioLiquido()) * 0.025)) + " "
                                                    + contrato.getSigla() : "2.50%"))),
                            fontCorpo));
        } else {
            cellvazio1 = new PdfPCell(new Phrase(" ", fontCorpo));
        }
        pTableFomaValores.addCell(cellPecentage1);
        pTableFomaValores.addCell(cellFundo);
        cellvazio1.setBorderWidthTop(1);
        cellvazio1.setBorderWidthRight(1);
        cellvazio1.setHorizontalAlignment(Element.ALIGN_RIGHT);
        pTableFomaValores.addCell(cellvazio1);

        double i05 = 0;//imposto 0.05%
        double i25 = 0;//imposto 2.5%
        try {
            if (nomeSeguro.equals("Viagem")) {
                i05 = 0.05 * Moeda.arrendodamento(contrato.getValorNC().replace(',', '.'));
                i25 = 0.006 * Moeda.arrendodamento(contrato.getValorNC().replace(',', '.'));
            } else if (!isReseguro) {
                i05 = 0.05 * Moeda.arrendodamento(contrato.getPremioLiquido());
                i25 = 0.006 * Moeda.arrendodamento(contrato.getPremioLiquido());
            }
        } catch (Exception e) {
        }
        PdfPCell cellvazio2 = new PdfPCell(
                new Phrase((isReseguro) ? " " : (Moeda.format(i05) + " " + contrato.getSigla()), fontCorpo));
        pTableFomaValores.addCell(cellPecentage2);
        pTableFomaValores.addCell(cellImposto);
        cellvazio2.setBorderWidthRight(1);
        cellvazio2.setBottom(10000);
        cellvazio2.setHorizontalAlignment(Element.ALIGN_RIGHT);
        pTableFomaValores.addCell(cellvazio2);

        PdfPCell cellvazio3 = new PdfPCell(
                new Phrase((isReseguro) ? " " : (Moeda.format(i25) + " " + contrato.getSigla()), fontCorpo));
        pTableFomaValores.addCell(cellPecentage3);
        pTableFomaValores.addCell(cellSelo);
        cellvazio3.setBorderWidthRight(1);
        cellvazio3.setHorizontalAlignment(Element.ALIGN_RIGHT);
        pTableFomaValores.addCell(cellvazio3);

        PdfPTable pTableTotalPagar = new PdfPTable(2);
        PdfPCell cellTituloTotalPagar = new PdfPCell(
                new Phrase("TOTAL A PAGAR " + contrato.getSigla(), fontCorpoN));
        cellTituloTotalPagar.setBorderWidthBottom(1f);
        cellTituloTotalPagar.setBorderWidthTop(0f);
        cellTituloTotalPagar.setBorderWidthRight(0f);
        cellTituloTotalPagar.setBorderWidthLeft(1f);

        PdfPCell cellValorPagar = new PdfPCell(
                new Phrase(contrato.getPremioLiquidoMoeda() + " " + contrato.getSigla(), fontCorpo));
        cellValorPagar.setBorderWidthBottom(1f);
        cellValorPagar.setBorderWidthTop(0f);
        cellValorPagar.setBorderWidthRight(1f);
        cellValorPagar.setBorderWidthLeft(0f);
        cellValorPagar.setHorizontalAlignment(Element.ALIGN_RIGHT);

        pTableTotalPagar.addCell(cellTituloTotalPagar);
        pTableTotalPagar.addCell(cellValorPagar);

        PdfPTable pTableSubTotal = new PdfPTable(new float[] { 62, 38 });
        PdfPCell cellTituloSubTotal = new PdfPCell(new Phrase("SubTotal", fontCorpoN));
        cellTituloSubTotal.setBorder(0);
        cellTituloSubTotal.setHorizontalAlignment(Element.ALIGN_RIGHT);
        PdfPCell cellValorSubTotal = new PdfPCell(
                new Phrase(contrato.getPremioBrutoMoeda() + " " + contrato.getSigla(), fontCorpo));
        cellValorSubTotal.setBorderWidthBottom(0.5f);
        cellValorSubTotal.setBorderWidthTop(1f);
        cellValorSubTotal.setBorderWidthRight(0.5f);
        cellValorSubTotal.setBorderWidthLeft(0.5f);
        cellValorSubTotal.setHorizontalAlignment(Element.ALIGN_RIGHT);

        pTableSubTotal.addCell(cellTituloSubTotal);
        pTableSubTotal.addCell(cellValorSubTotal);

        PdfPCell cellPagament1 = new PdfPCell(pTableSubTotal);
        cellPagament1.setBorder(0);
        PdfPCell cellPagament2 = new PdfPCell(pTableFomaValores);
        cellPagament2.setBorder(0);
        PdfPCell cellPagament3 = new PdfPCell(pTableTotalPagar);
        cellPagament3.setBorder(0);

        pTableFomaValoresPricipal.addCell(cellPagament1);
        pTableFomaValoresPricipal.addCell(cellPagament2);
        pTableFomaValoresPricipal.addCell(cellPagament3);

        PdfPCell cellPagamentPricipal1 = new PdfPCell(pTableFomaPagamentoPricipal);
        cellPagamentPricipal1.setBorder(0);
        PdfPCell cellPagamentPricipal2 = new PdfPCell(pTableFomaValoresPricipal);
        cellPagamentPricipal2.setBorder(0);

        pTablePrincipalPagamento.addCell(cellPagamentPricipal1);
        pTablePrincipalPagamento.addCell(cellPagamentPricipal2);

        PdfPTable pTableCambio = new PdfPTable(2);
        pTableCambio.setWidthPercentage(95);
        PdfPCell cellTituloCambio1 = new PdfPCell(new Phrase("Cambio", fontCorpoN));
        cellTituloCambio1.setBorder(0);
        cellTituloCambio1.setHorizontalAlignment(Element.ALIGN_CENTER);

        PdfPCell cellTituloCambio2 = new PdfPCell(new Phrase("Total Em Dobras", fontCorpoN));
        cellTituloCambio2.setBorder(0);
        cellTituloCambio2.setHorizontalAlignment(Element.ALIGN_CENTER);

        PdfPCell cellValorCambio = new PdfPCell(new Phrase(
                "1 " + contrato.getSigla() + "= "
                        + Moeda.format(valorCompra(contrato.getDataRegistro(), contrato)) + " " + "STD",
                fontCorpo));
        cellValorCambio.setBorder(0);
        cellValorCambio.setHorizontalAlignment(Element.ALIGN_CENTER);

        DecimalFormat formato = new DecimalFormat("#.##");
        String numero = formato.format(Double.valueOf(contrato.getPremioLiquido()));
        double premioLiquido = Double.valueOf((numero).replace(',', '.'));

        //            System.err.println(taxa + "Taxa * Premio Liquido" + Double.valueOf(contrato.getPremioLiquido()));
        //            System.err.println(taxa + "Taxa * Premio Liquido" + Double.toString(premioLiquido));

        PdfPCell cellValorDobras = new PdfPCell(
                new Phrase(Moeda.format((taxa * premioLiquido)) + " STD", fontCorpo));
        cellValorDobras.setBorder(0);
        cellValorDobras.setHorizontalAlignment(Element.ALIGN_CENTER);

        pTableCambio.addCell(cellTituloCambio1);
        pTableCambio.addCell(cellTituloCambio2);
        pTableCambio.addCell(cellValorCambio);
        pTableCambio.addCell(cellValorDobras);

        PdfPTable pTableData = new PdfPTable(1);
        pTableData.setWidthPercentage(95);
        Paragraph pData = new Paragraph();
        pData.add(new Phrase("Elaborado por ", fontCorpo));
        pData.add(new Phrase(interCodVendedor, fontCorpoN));
        pData.add(new Phrase(" Data ".toUpperCase() + sdf.format(new Date()), fontCorpo));
        PdfPCell cellData = new PdfPCell(pData);
        cellData.setBorder(0);
        cellData.setBorderWidthBottom(0.1f);
        cellData.setHorizontalAlignment(Element.ALIGN_CENTER);

        pTableData.addCell(cellData);

        Document documento = new Document();
        documento.setPageSize(PageSize.A4);
        documento.setMargins(20f, 20f, 70f, 5f);

        String f1 = (arquivo + "/" + user + "/Seguro " + nomeSeguro + "/");
        File f = new File(f1);
        String Ddata = sdf1.format(new Date());
        f.mkdirs();
        f = new File(f.getAbsoluteFile() + "/" + "Nota de Debito " + Ddata + ".pdf");

        reString = "../Documentos/" + user + "/Seguro " + nomeSeguro + "/" + "Nota de Debito " + Ddata + ".pdf";
        OutputStream outputStraem = new FileOutputStream(f);
        PdfWriter writer = PdfWriter.getInstance(documento, outputStraem);

        if (MarcaDAgua.isSimulation) {
            MarcaDAgua.SimulacaoVertical v = new MarcaDAgua.SimulacaoVertical();
            writer.setPageEvent(v);
        }

        if (MarcaDAgua.isCanceled) {
            MarcaDAgua.AnulacaoVertical v = new MarcaDAgua.AnulacaoVertical();
            writer.setPageEvent(v);
        }

        documento.open();
        documento.add(pTableEmpresaPricipal);
        documento.add(pTableFatura);
        documento.add(pTableLinha);
        documento.add(pTableLinha);
        documento.add(pTableTitulo);
        documento.add(pTableClientePrincipal);
        documento.add(pTableNull);
        documento.add(TableRegistro);
        documento.add(pTablePrincipalPagamento);
        documento.add(pTableNull);
        documento.add(pTableNull);
        documento.add(pTableCambio);
        documento.add(pTableNull);
        documento.add(pTableNull);
        documento.add(pTableNull);
        documento.add(pTableData);
        documento.add(pTableNull);
        documento.add(pTableNull);
        documento.add(pTableNull);
        documento.add(pTableLinha);
        documento.add(pTableLinha);
        documento.close();

        isReseguro = false;
        //            PrintPdf printPdf = new PrintPdf(f.getAbsolutePath(), f.getAbsolutePath(), 0, 595f,842f,"\\\\JIGASOFTPC\\Hewlett-Packard HP LaserJet P2035",1); 
        //            PrintPdf printPdf = new PrintPdf(f.getAbsolutePath(), f.getAbsolutePath(), 1, 595f,842f,"Enviar Para o OneNote 2013",1); 
        //            printPdf.print();
        return reString;
    } catch (FileNotFoundException | DocumentException e) {
        e.printStackTrace();
    } catch (IOException ex) {
        Logger.getLogger(DocNotaDebito.class.getName()).log(Level.SEVERE, null, ex);
    }

    return "";
}

From source file:Export.DocOfReCoSeguro.java

public static void docSeguros(String nomeSeguro, String user, String arquivo, String numDebito, String tileDoc,
        int idReseguro, boolean isReseguroOfNICON) {
    String reString;//from w  w w  .  j a v  a2 s  .  c om
    try {

        Font fontCabecalhoN = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED,
                9.2f);
        Font fontLinha = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED,
                0.000000358f);
        Font fontCabecalhoS = FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED,
                9.2f);
        Font fontCorpo = FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 8f);
        Font fontCorpoS = FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 8f,
                Font.UNDERLINE);
        Font fontCorpoN = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 8f);
        Font fontNull = FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 4f);
        Font fontMenor = FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 3f);

        DataResseguro reS = DataReseguro.getDadosReseguro(idReseguro);

        PdfPTable pTableEmpresaPricipal = new PdfPTable(new float[] { 80, 20 });
        pTableEmpresaPricipal.setWidthPercentage(90);
        PdfPTable pTableEmpresaInforImpres1 = new PdfPTable(1);
        PdfPTable pTableEmpresaInforImpres2 = new PdfPTable(1);
        PdfPTable pTableEmpresaInforImpres4 = new PdfPTable(1);
        PdfPTable pTableEmpresaInforImpres5 = new PdfPTable(1);

        PdfPTable pTableFatura = new PdfPTable(new float[] { 80, 20 });

        PdfPCell pCellNomeEmpresa = new PdfPCell(new Phrase(ConfigDoc.Empresa.NOME, fontCabecalhoN));
        pCellNomeEmpresa.setBorder(0);

        PdfPCell pCellNomeEndereco = new PdfPCell(new Phrase(ConfigDoc.Empresa.ENDERECO, fontCabecalhoN));
        pCellNomeEndereco.setBorder(0);

        PdfPCell pCellCaixaPostal = new PdfPCell(new Phrase(ConfigDoc.Empresa.CAIXAPOSTAL, fontCabecalhoN));
        pCellCaixaPostal.setBorder(0);

        PdfPCell pCellTeleFax = new PdfPCell(
                new Phrase(ConfigDoc.Empresa.TELEFAX + " " + ConfigDoc.Empresa.EMAIL, fontCabecalhoN));
        pCellTeleFax.setBorder(0);

        PdfPCell pCellSociedade = new PdfPCell(new Phrase(ConfigDoc.Empresa.SOCIEDADE, fontCabecalhoN));
        pCellSociedade.setBorder(0);

        PdfPCell pCellCapital = new PdfPCell(new Phrase(ConfigDoc.Empresa.CAPITALSOCIAL, fontCabecalhoN));
        pCellCapital.setBorder(0);

        PdfPCell pCellPolice = new PdfPCell(
                new Phrase(ConfigDoc.Empresa.APOLICE + reS.getAPOLICE(), fontCabecalhoN));
        pCellPolice.setBorder(0);

        Image imageEmpresa = Image.getInstance("logo.png");
        imageEmpresa.scaleToFit(120f, 100f);

        pTableEmpresaInforImpres1.addCell(pCellNomeEmpresa);
        pTableEmpresaInforImpres1.addCell(pCellNomeEndereco);
        pTableEmpresaInforImpres1.addCell(pCellCaixaPostal);
        pTableEmpresaInforImpres1.addCell(pCellTeleFax);
        pTableEmpresaInforImpres1.addCell(pCellSociedade);

        pTableEmpresaInforImpres2.addCell(pCellCapital);
        pTableEmpresaInforImpres2.addCell(pCellPolice);

        PdfPCell cellTabela1 = new PdfPCell(pTableEmpresaInforImpres2);
        cellTabela1.setBorder(0);

        pTableEmpresaInforImpres4.addCell(cellTabela1);

        PdfPCell cellTabela3 = new PdfPCell(pTableEmpresaInforImpres1);
        cellTabela3.setBorder(0);

        pTableEmpresaInforImpres5.addCell(cellTabela3);

        PdfPCell cellTabela4 = new PdfPCell(pTableEmpresaInforImpres4);
        cellTabela4.setBorder(0);

        pTableEmpresaInforImpres5.addCell(cellTabela4);

        PdfPCell cellTabela5 = new PdfPCell(pTableEmpresaInforImpres5);
        cellTabela5.setBorder(0);

        pTableEmpresaPricipal.addCell(cellTabela5);

        PdfPCell cellTabela6 = new PdfPCell(imageEmpresa);
        cellTabela6.setBorder(0);
        cellTabela6.setHorizontalAlignment(Element.ALIGN_RIGHT);

        pTableEmpresaPricipal.addCell(cellTabela6);

        PdfPTable pTableLinha = new PdfPTable(1);
        pTableLinha.setWidthPercentage(90);
        PdfPCell linha = new PdfPCell(new Phrase(" ", fontLinha));
        linha.setBorderWidthTop(0.5f);
        linha.setBorderWidthBottom(0);
        linha.setBorderWidthLeft(0);
        linha.setBorderWidthRight(0);
        pTableLinha.addCell(linha);

        /**
         * Tile Doc start
         */
        /*
        PdfPTable pTableTileDoc = new PdfPTable(new float[]{50, 50});
                
        PdfPCell cellTileDoc = new PdfPCell(new Phrase(tileDoc, fontCabecalhoS));
        cellTileDoc.setColspan(2);
        cellTileDoc.setPaddingTop(10f);
        cellTileDoc.setPaddingBottom(20f);
        cellTileDoc.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cellTileDoc.setBorder(PdfPCell.NO_BORDER);
        pTableTileDoc.addCell(cellTileDoc);
                
        Paragraph pTile = new Paragraph();
        pTile.add(new Phrase("DEBIT:  ", fontCorpoN));
        pTile.add(new Phrase("NiCON Seguros STP", fontCorpoN));
        PdfPCell cellDebit = new PdfPCell(pTile);
        cellDebit.setBorder(PdfPCell.NO_BORDER);
        pTableTileDoc.addCell(cellDebit);
                
        Paragraph pNotaNum = new Paragraph();
        pNotaNum.add(new Phrase("DEBIT NOTE NO: ", fontCorpoN));
        pNotaNum.add(new Phrase("05525", fontCorpo));
        cellDebit = new PdfPCell(pNotaNum);
        cellDebit.setPaddingLeft(20f);
        cellDebit.setBorder(PdfPCell.NO_BORDER);
        pTableTileDoc.addCell(cellDebit);
                
        cellDebit = new PdfPCell(new Phrase("             Avenida Marginal 12 de Junlho, 977", fontCorpo));
        cellDebit.setBorder(PdfPCell.NO_BORDER);
        pTableTileDoc.addCell(cellDebit);
                
        Paragraph pDate = new Paragraph();
        pDate.add(new Phrase("Date: ", fontCorpoN));
        SimpleDateFormat format = new SimpleDateFormat("dd MMMM',' yyyy",new Locale("pt", "BR"));
        pDate.add(new Phrase(format.format(new Date()), fontCorpo));
        cellDebit = new PdfPCell(pDate);
        cellDebit.setBorder(PdfPCell.NO_BORDER);
        cellDebit.setPaddingLeft(20f);
        pTableTileDoc.addCell(cellDebit);
                
        cellDebit = new PdfPCell(new Phrase("             Cx Postal 556-So Tom", fontCorpo));
        cellDebit.setBorder(PdfPCell.NO_BORDER);
        pTableTileDoc.addCell(cellDebit);
        cellDebit = new PdfPCell(new Phrase(" "));
        cellDebit.setBorder(PdfPCell.NO_BORDER);
        pTableTileDoc.addCell(cellDebit);
        */
        /**
         * Tile Doc end
         */

        ArrayList<DataEmpresa> listaDataEmpresas = DataReseguro.getDadosEmpresa(idReseguro);

        /**
         * Data Parte 1 Start
         */
        PdfPTable pTableDataPart1 = new PdfPTable(new float[] { 18f, 82f });
        pTableDataPart1.setWidthPercentage(90);

        PdfPCell cellDataPart1 = new PdfPCell(new Phrase("EMPRESA LIDER:", fontCorpoN));
        cellDataPart1.setBorder(PdfPCell.NO_BORDER);
        cellDataPart1.setPaddingTop(10f);
        cellDataPart1.setPaddingBottom(5f);
        pTableDataPart1.addCell(cellDataPart1);
        cellDataPart1 = new PdfPCell(
                new Phrase(((!isReseguroOfNICON) ? listaDataEmpresas.get(0).getEMPRESA().toUpperCase()
                        : ConfigDoc.Empresa.NOME), fontCorpo));
        cellDataPart1.setPaddingTop(10f);
        cellDataPart1.setPaddingBottom(5f);
        cellDataPart1.setBorder(PdfPCell.NO_BORDER);
        pTableDataPart1.addCell(cellDataPart1);

        cellDataPart1 = new PdfPCell(new Phrase("CONTRATO N:", fontCorpoN));
        cellDataPart1.setBorder(PdfPCell.NO_BORDER);
        cellDataPart1.setPaddingTop(5f);
        cellDataPart1.setPaddingBottom(5f);
        pTableDataPart1.addCell(cellDataPart1);
        cellDataPart1 = new PdfPCell(new Phrase(reS.getAPOLICE(), fontCorpo));
        cellDataPart1.setPaddingTop(5f);
        cellDataPart1.setPaddingBottom(5f);
        cellDataPart1.setBorder(PdfPCell.NO_BORDER);
        pTableDataPart1.addCell(cellDataPart1);

        cellDataPart1 = new PdfPCell(new Phrase("DESCRIO:", fontCorpoN));
        cellDataPart1.setPaddingTop(5f);
        cellDataPart1.setPaddingBottom(5f);
        cellDataPart1.setBorder(PdfPCell.NO_BORDER);
        pTableDataPart1.addCell(cellDataPart1);
        cellDataPart1 = new PdfPCell(new Phrase(reS.getDESCRICAO(), fontCorpo));
        cellDataPart1.setPaddingTop(5f);
        cellDataPart1.setPaddingBottom(5f);
        cellDataPart1.setBorder(PdfPCell.NO_BORDER);
        pTableDataPart1.addCell(cellDataPart1);

        cellDataPart1 = new PdfPCell(new Phrase("PERIODO:", fontCorpoN));
        cellDataPart1.setBorder(PdfPCell.NO_BORDER);
        cellDataPart1.setPaddingTop(5f);
        cellDataPart1.setPaddingBottom(5f);
        pTableDataPart1.addCell(cellDataPart1);
        cellDataPart1 = new PdfPCell(new Phrase(reS.getINICIO() + " - " + reS.getFIM(), fontCorpo));
        cellDataPart1.setBorder(PdfPCell.NO_BORDER);
        cellDataPart1.setPaddingTop(5f);
        cellDataPart1.setPaddingBottom(5f);
        pTableDataPart1.addCell(cellDataPart1);

        cellDataPart1 = new PdfPCell(new Phrase("LIMITE:", fontCorpoN));
        cellDataPart1.setBorder(PdfPCell.NO_BORDER);
        cellDataPart1.setPaddingTop(5f);
        cellDataPart1.setPaddingBottom(5f);
        pTableDataPart1.addCell(cellDataPart1);
        cellDataPart1 = new PdfPCell(new Phrase((covertDouble(reS.getLIMITE()) == null) ? reS.getLIMITE()
                : Moeda.format(covertDouble(reS.getLIMITE())), fontCorpo));
        cellDataPart1.setBorder(PdfPCell.NO_BORDER);
        cellDataPart1.setPaddingTop(5f);
        cellDataPart1.setPaddingBottom(5f);
        pTableDataPart1.addCell(cellDataPart1);

        cellDataPart1 = new PdfPCell(new Phrase("MOEDA:", fontCorpoN));
        cellDataPart1.setPaddingTop(5f);
        cellDataPart1.setPaddingBottom(10f);
        cellDataPart1.setBorder(PdfPCell.NO_BORDER);
        pTableDataPart1.addCell(cellDataPart1);

        cellDataPart1 = new PdfPCell(new Phrase(reS.getMOEDA(), fontCorpo));
        cellDataPart1.setPaddingTop(5f);
        cellDataPart1.setPaddingBottom(10f);
        cellDataPart1.setBorder(PdfPCell.NO_BORDER);
        pTableDataPart1.addCell(cellDataPart1);
        /**
         * Data Part 1 end
         */

        /**
         * Data Part 2 start
         */
        PdfPTable pTableDataPart2 = new PdfPTable(new float[] { 33.333333333f, 33.333333333f, 33.333333333f });
        pTableDataPart2.setWidthPercentage(90);

        PdfPCell cellDataPart2 = new PdfPCell(new Phrase("PREMIO GROSSO:", fontCorpoN));
        cellDataPart2.setColspan(2);
        cellDataPart2.setBorder(PdfPCell.NO_BORDER);
        cellDataPart2.setPaddingTop(10f);
        cellDataPart2.setPaddingBottom(5f);
        pTableDataPart2.addCell(cellDataPart2);
        cellDataPart2 = new PdfPCell(new Phrase(
                Moeda.format(Double.valueOf(reS.getPREMIOGROSSO().replace(',', '.'))) + " " + reS.getMOEDA(),
                fontCorpo));
        cellDataPart2.setPaddingTop(10f);
        cellDataPart2.setPaddingBottom(5f);
        cellDataPart2.setBorder(PdfPCell.NO_BORDER);
        pTableDataPart2.addCell(cellDataPart2);

        cellDataPart2 = new PdfPCell(new Phrase("DEDUO:", fontCorpoN));
        cellDataPart2.setBorder(PdfPCell.NO_BORDER);
        cellDataPart2.setColspan(2);
        cellDataPart2.setPaddingTop(5f);
        cellDataPart2.setPaddingBottom(5f);
        pTableDataPart2.addCell(cellDataPart2);
        cellDataPart2 = new PdfPCell(new Phrase(reS.getDEDUCAO() + "%", fontCorpo));
        cellDataPart2.setPaddingTop(5f);
        cellDataPart2.setPaddingBottom(5f);
        cellDataPart2.setBorder(PdfPCell.NO_BORDER);
        pTableDataPart2.addCell(cellDataPart2);

        cellDataPart2 = new PdfPCell(new Phrase("LIQUIDO:", fontCorpoN));
        cellDataPart2.setBorder(PdfPCell.NO_BORDER);
        cellDataPart2.setColspan(2);
        cellDataPart2.setPaddingTop(5f);
        cellDataPart2.setPaddingBottom(5f);
        pTableDataPart2.addCell(cellDataPart2);
        cellDataPart2 = new PdfPCell(new Phrase(
                Moeda.format(Double.valueOf(reS.getPREMIOGROSSO().replace(',', '.'))) + " " + reS.getMOEDA(),
                fontCorpo));
        cellDataPart2.setPaddingTop(5f);
        cellDataPart2.setPaddingBottom(5f);
        cellDataPart2.setBorder(PdfPCell.NO_BORDER);
        pTableDataPart2.addCell(cellDataPart2);

        cellDataPart2 = new PdfPCell(new Phrase("TOTAL:", fontCorpoN));
        cellDataPart2.setBorder(PdfPCell.NO_BORDER);
        cellDataPart2.setPaddingTop(5f);
        cellDataPart2.setPaddingBottom(10f);
        pTableDataPart2.addCell(cellDataPart2);
        cellDataPart2 = new PdfPCell(new Phrase("100%", fontCorpo));
        cellDataPart2.setPaddingTop(5f);
        cellDataPart2.setPaddingBottom(10f);
        cellDataPart2.setBorder(PdfPCell.NO_BORDER);
        pTableDataPart2.addCell(cellDataPart2);
        cellDataPart2 = new PdfPCell(new Phrase(
                Moeda.format(Double.valueOf(reS.getTOTAL().replace(',', '.'))) + " " + reS.getMOEDA(),
                fontCorpo));
        cellDataPart2.setPaddingTop(5f);
        cellDataPart2.setPaddingBottom(10f);
        cellDataPart2.setBorder(PdfPCell.NO_BORDER);
        pTableDataPart2.addCell(cellDataPart2);

        //            cellDataPart2 = new PdfPCell(new Phrase("Your faithfully", fontCorpo));
        //            cellDataPart2.setColspan(3);
        //            cellDataPart2.setPaddingTop(5f);
        //            cellDataPart2.setPaddingBottom(0.7f);
        //            cellDataPart2.setBorder(PdfPCell.NO_BORDER);
        //            pTableDataPart2.addCell(cellDataPart2);
        //            cellDataPart2 = new PdfPCell(new Phrase("THE UNITED AFRICAN INSURANCE BROKERS LTD", fontCorpo));
        //            cellDataPart2.setColspan(3);
        //            cellDataPart2.setPaddingTop(0.7f);
        //            cellDataPart2.setPaddingBottom(10F);
        //            cellDataPart2.setBorder(PdfPCell.NO_BORDER);
        //            pTableDataPart2.addCell(cellDataPart2);
        /**
         * Data Part 2 end
         */
        PdfPTable pTableSecureter = new PdfPTable(new float[] { 30f, 30f, 40f });

        PdfPCell cellSecureterNull = new PdfPCell(new Phrase(" ", fontCorpoN));
        cellSecureterNull.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cellSecureterNull.setPaddingTop(2f);
        cellSecureterNull.setPaddingBottom(2f);
        cellSecureterNull.setColspan(3);
        cellSecureterNull.setBorder(PdfPCell.NO_BORDER);
        pTableSecureter.addCell(cellSecureterNull);

        cellSecureterNull.setColspan(0);

        if (isReseguroOfNICON) {
            PdfPCell cellSecureter = new PdfPCell(new Phrase("RESSEGURADORA USADA", fontCorpoN));
            cellSecureter.setColspan(2);
            cellSecureter.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
            cellSecureter.setPaddingTop(8f);
            cellSecureter.setPaddingBottom(8f);
            cellSecureter.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
            pTableSecureter.addCell(cellSecureter);
            pTableSecureter.addCell(cellSecureterNull);

            cellSecureter = new PdfPCell(new Phrase("RESSEGURA", fontCorpoN));
            cellSecureter.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
            cellSecureter.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
            cellSecureter.setPaddingTop(5f);
            cellSecureter.setPaddingBottom(5);
            pTableSecureter.addCell(cellSecureter);
            cellSecureter = new PdfPCell(new Phrase("%PERCENTAGEM", fontCorpoN));
            cellSecureter.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
            cellSecureter.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
            cellSecureter.setPaddingTop(5f);
            cellSecureter.setPaddingBottom(5);
            pTableSecureter.addCell(cellSecureter);
            pTableSecureter.addCell(cellSecureterNull);

            int total = listaDataEmpresas.size();
            for (int i = 0; (i < total); i++) {
                cellSecureter = new PdfPCell(new Phrase(listaDataEmpresas.get(i).getEMPRESA(), fontCorpo));
                cellSecureter.setPaddingTop(5f);
                cellSecureter.setPaddingBottom(5);
                cellSecureter.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
                pTableSecureter.addCell(cellSecureter);
                cellSecureter = new PdfPCell(new Phrase(
                        listaDataEmpresas.get(i).getPERCENTAGEM() + "% -- "
                                + Moeda.format(((covertDouble(listaDataEmpresas.get(i).getPERCENTAGEM()) / 100)
                                        * covertDouble(reS.getPREMIOGROSSO())))
                                + " " + reS.getMOEDA(),
                        fontCorpo));
                cellSecureter.setPaddingTop(5f);
                cellSecureter.setPaddingBottom(5);
                cellSecureter.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
                cellSecureter.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
                pTableSecureter.addCell(cellSecureter);
                pTableSecureter.addCell(cellSecureterNull);
            }
        }
        PdfPTable pTablePocessed = new PdfPTable(new float[] { 100 });
        PdfPCell cellPocessed = new PdfPCell(new Phrase("_____________________________", fontCorpoN));
        cellPocessed.setBorder(PdfPCell.NO_BORDER);
        cellPocessed.setVerticalAlignment(PdfPCell.ALIGN_BOTTOM);
        cellPocessed.setPaddingTop(50f);
        cellPocessed.setPaddingBottom(1f);
        pTablePocessed.addCell(cellPocessed);
        cellPocessed = new PdfPCell(new Phrase("PROCESSED BY", fontCorpoN));
        cellPocessed.setPaddingTop(1f);
        cellPocessed.setVerticalAlignment(PdfPCell.ALIGN_TOP);
        cellPocessed.setBorder(PdfPCell.NO_BORDER);
        pTablePocessed.addCell(cellPocessed);

        SimpleDateFormat sdf1 = new SimpleDateFormat("dd-MM-yyyy hh'.'mm'.'ss");

        Document documento = new Document();
        documento.setPageSize(PageSize.A4);
        documento.setMargins(20f, 20f, 70f, 5f);

        String f1 = (arquivo + "/" + user + "/Seguro " + nomeSeguro + "/");
        File f = new File(f1);
        String Ddata = sdf1.format(new Date());
        f.mkdirs();
        f = new File(f.getAbsoluteFile() + "/" + "Doc Nota CO-ReSSEGURO " + Ddata + ".pdf");

        reString = "../Documentos/" + user + "/Seguro " + nomeSeguro + "/" + "Doc Nota CO-ReSSEGURO " + Ddata
                + ".pdf";
        OutputStream outputStraem = new FileOutputStream(f);
        PdfWriter writer = PdfWriter.getInstance(documento, outputStraem);

        documento.open();
        documento.add(pTableEmpresaPricipal);
        documento.add(pTableLinha);
        documento.add(pTableLinha);
        /*
        documento.add(pTableTileDoc);
        documento.add(pTableLinha);
         */
        documento.add(pTableDataPart1);
        documento.add(pTableLinha);
        documento.add(pTableDataPart2);
        documento.add(pTableLinha);
        documento.add(pTableLinha);
        documento.add(pTableSecureter);
        //            documento.add(pTablePocessed);
        pTablePocessed.setTotalWidth(200);
        pTablePocessed.writeSelectedRows(-1, 100, 100f, 175f, writer.getDirectContent());
        documento.close();

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

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

}

From source file:Export.FaturaCoReSeguro__.java

public String docSeguros(String nomeSeguro, String numApolice, String fundoContrato, String user, String moeda,
        String arquivo, String numeroRegistro) {
    String reString;//from   w  ww .j a  v a 2s  .  co  m
    try {

        Font fontCabecalhoN = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED,
                9.2f);
        Font fontLinha = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED,
                0.000000358f);
        Font fontCabecalhoS = FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED,
                9.2f);
        Font fontCorpo = FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 8f);
        Font fontCorpoN = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 8f);
        Font fontNull = FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 4f);
        Font fontMenor = FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 6f);
        Font fontMenorN = FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 6f);

        PdfPTable pTableEmpresaPricipal = new PdfPTable(new float[] { 80, 20 });
        PdfPTable pTableEmpresaInforImpres1 = new PdfPTable(1);
        PdfPTable pTableEmpresaInforImpres2 = new PdfPTable(1);
        PdfPTable pTableEmpresaInforImpres4 = new PdfPTable(1);
        PdfPTable pTableEmpresaInforImpres5 = new PdfPTable(1);

        PdfPCell pCellNomeEmpresa = new PdfPCell(new Phrase(ConfigDoc.Empresa.NOME, fontCabecalhoN));
        pCellNomeEmpresa.setBorder(0);

        PdfPCell pCellNomeEndereco = new PdfPCell(new Phrase(ConfigDoc.Empresa.ENDERECO, fontCabecalhoN));
        pCellNomeEndereco.setBorder(0);

        PdfPCell pCellCaixaPostal = new PdfPCell(new Phrase(ConfigDoc.Empresa.CAIXAPOSTAL, fontCabecalhoN));
        pCellCaixaPostal.setBorder(0);

        PdfPCell pCellTeleFax = new PdfPCell(
                new Phrase(ConfigDoc.Empresa.TELEFAX + " " + ConfigDoc.Empresa.EMAIL, fontCabecalhoN));
        pCellTeleFax.setBorder(0);

        PdfPCell pCellSociedade = new PdfPCell(new Phrase(ConfigDoc.Empresa.SOCIEDADE, fontCabecalhoN));
        pCellSociedade.setBorder(0);

        PdfPCell pCellCapital = new PdfPCell(new Phrase(ConfigDoc.Empresa.CAPITALSOCIAL, fontCabecalhoN));
        pCellCapital.setBorder(0);

        PdfPCell pCellPolice = new PdfPCell(new Phrase(ConfigDoc.Empresa.APOLICE + numApolice, fontCabecalhoN));
        pCellPolice.setBorder(0);

        Image imageEmpresa = Image.getInstance("logo.png");
        imageEmpresa.scaleToFit(120f, 100f);

        pTableEmpresaInforImpres1.addCell(pCellNomeEmpresa);
        pTableEmpresaInforImpres1.addCell(pCellNomeEndereco);
        pTableEmpresaInforImpres1.addCell(pCellCaixaPostal);
        pTableEmpresaInforImpres1.addCell(pCellTeleFax);
        pTableEmpresaInforImpres1.addCell(pCellSociedade);

        pTableEmpresaInforImpres2.addCell(pCellCapital);
        pTableEmpresaInforImpres2.addCell(pCellPolice);

        PdfPCell cellTabela1 = new PdfPCell(pTableEmpresaInforImpres2);
        cellTabela1.setBorder(0);

        pTableEmpresaInforImpres4.addCell(cellTabela1);

        PdfPCell cellTabela3 = new PdfPCell(pTableEmpresaInforImpres1);
        cellTabela3.setBorder(0);

        pTableEmpresaInforImpres5.addCell(cellTabela3);

        PdfPCell cellTabela4 = new PdfPCell(pTableEmpresaInforImpres4);
        cellTabela4.setBorder(0);

        pTableEmpresaInforImpres5.addCell(cellTabela4);

        PdfPCell cellTabela5 = new PdfPCell(pTableEmpresaInforImpres5);
        cellTabela5.setBorder(0);

        pTableEmpresaPricipal.addCell(cellTabela5);

        PdfPCell cellTabela6 = new PdfPCell(imageEmpresa);
        cellTabela6.setBorder(0);
        cellTabela6.setHorizontalAlignment(Element.ALIGN_RIGHT);

        pTableEmpresaPricipal.addCell(cellTabela6);

        PdfPTable pTableLinha = new PdfPTable(1);
        PdfPCell linha = new PdfPCell(new Phrase(" ", fontLinha));
        linha.setBorderWidthTop(0.5f);
        linha.setBorderWidthBottom(0);
        linha.setBorderWidthLeft(0);
        linha.setBorderWidthRight(0);
        pTableLinha.addCell(linha);

        /**
         * Tile Doc
         */
        PdfPTable pTableTileDoc = new PdfPTable(new float[] { 65f, 35f });

        PdfPCell cellTileDoc = new PdfPCell(new Phrase("FACTURA", fontCabecalhoS));
        cellTileDoc.setColspan(2);
        cellTileDoc.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
        cellTileDoc.setBorder(PdfPCell.NO_BORDER);

        pTableTileDoc.addCell(cellTileDoc);

        Paragraph pNumFatura = new Paragraph();
        pNumFatura.add(new Phrase("Factura N ", fontMenorN));
        pNumFatura.add(new Phrase("0019528/16 ", fontMenor));
        cellTileDoc = new PdfPCell(pNumFatura);
        cellTileDoc.setColspan(2);
        cellTileDoc.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
        cellTileDoc.setBorder(PdfPCell.NO_BORDER);
        cellTileDoc.setPaddingBottom(10f);

        pTableTileDoc.addCell(cellTileDoc);

        PdfPTable pTableCliente = new PdfPTable(new float[] { 100 });

        Paragraph pCliente = new Paragraph();
        pCliente.add(new Phrase("Nome: ", fontCorpo));
        pCliente.add(new Phrase(" ", fontCorpoN));
        PdfPCell cellCliente = new PdfPCell(pCliente);
        cellCliente.setBorder(PdfPCell.NO_BORDER);
        pTableCliente.addCell(cellCliente);

        pCliente = new Paragraph();
        pCliente.add(new Phrase("Morada: ", fontCorpo));
        pCliente.add(new Phrase(" ", fontCorpoN));
        cellCliente = new PdfPCell(pCliente);
        cellCliente.setBorder(PdfPCell.NO_BORDER);
        pTableCliente.addCell(cellCliente);

        pCliente = new Paragraph();
        pCliente.add(new Phrase("Localidade: ", fontCorpo));
        pCliente.add(new Phrase(" ", fontCorpoN));
        pCliente.add(new Phrase("  ?rea: ", fontCorpo));
        pCliente.add(new Phrase(" ", fontCorpoN));
        pCliente.add(new Phrase("  CP: ", fontCorpo));
        pCliente.add(new Phrase(" ", fontCorpoN));
        cellCliente = new PdfPCell(pCliente);
        cellCliente.setBorder(PdfPCell.NO_BORDER);
        pTableCliente.addCell(cellCliente);

        pCliente = new Paragraph();
        pCliente.add(new Phrase("Telefone: ", fontCorpo));
        pCliente.add(new Phrase(" ", fontCorpoN));
        cellCliente = new PdfPCell(pCliente);
        cellCliente.setBorder(PdfPCell.NO_BORDER);
        pTableCliente.addCell(cellCliente);

        cellCliente = new PdfPCell(pTableCliente);
        cellCliente.setBorder(PdfPCell.NO_BORDER);
        pTableTileDoc.addCell(cellCliente);

        PdfPTable pTableContrato = new PdfPTable(new float[] { 40, 60 });

        PdfPCell cellContrato = new PdfPCell(new Phrase("Data", fontCorpo));
        cellContrato.setBorder(PdfPCell.NO_BORDER);
        pTableContrato.addCell(cellContrato);

        cellContrato = new PdfPCell(new Phrase("09-12-2016", fontCorpo));
        cellContrato.setBorder(PdfPCell.NO_BORDER);
        pTableContrato.addCell(cellContrato);

        cellContrato = new PdfPCell(new Phrase("Vendedor", fontCorpo));
        cellContrato.setBorder(PdfPCell.NO_BORDER);
        pTableContrato.addCell(cellContrato);

        cellContrato = new PdfPCell(new Phrase("SAT ISURANCE", fontCorpoN));
        cellContrato.setBorder(PdfPCell.NO_BORDER);
        pTableContrato.addCell(cellContrato);

        cellContrato = new PdfPCell(new Phrase(" ", fontCorpoN));
        cellContrato.setBorder(PdfPCell.NO_BORDER);
        pTableContrato.addCell(cellContrato);

        Paragraph pNIF = new Paragraph();
        pNIF.add(new Phrase("NIF: ", fontCorpoN));
        pNIF.add(new Phrase(" 517255068", fontCorpoN));
        cellContrato = new PdfPCell(pNIF);
        cellContrato.setBorder(PdfPCell.NO_BORDER);
        pTableContrato.addCell(cellContrato);

        cellContrato = new PdfPCell(pTableContrato);
        cellContrato.setBorder(PdfPCell.BOX);
        cellContrato.setPadding(5f);
        pTableTileDoc.addCell(cellContrato);

        PdfPTable pTableDados = new PdfPTable(new float[] { 10, 50, 18, 22 });

        PdfPCell cellDados = new PdfPCell(new Phrase("Qtde.", fontCorpoN));
        pTableDados.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("Descrio.", fontCorpoN));
        pTableDados.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("Preo unitrio", fontCorpoN));
        pTableDados.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("Total", fontCorpoN));
        pTableDados.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("Qtde.", fontCorpo));
        cellDados.setRowspan(13);
        pTableDados.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("Descrio.", fontCorpo));
        cellDados.setRowspan(13);
        pTableDados.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("Preo unitrio", fontCorpo));
        cellDados.setRowspan(13);
        pTableDados.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("Total", fontCorpo));
        cellDados.setBorderWidthTop(0);
        cellDados.setBorderWidthBottom(0);
        cellDados.setBorderWidthLeft(0);
        cellDados.setBorderWidthRight(0.5f);
        pTableDados.addCell(cellDados);

        for (int i = 0; i < 12; i++) {
            cellDados = new PdfPCell(new Phrase(" ", fontCorpo));
            cellDados.setBorderWidthTop(0f);
            if ((i != (12 - 1))) {
                cellDados.setBorderWidthBottom(0f);
            }
            cellDados.setBorderWidthLeft(0f);
            cellDados.setBorderWidthRight(0.5f);
            pTableDados.addCell(cellDados);
        }

        cellDados = new PdfPCell(new Phrase("Total", fontCorpo));
        cellDados.setColspan(2);
        cellDados.setRowspan(8);
        pTableDados.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("SubTotal", fontCorpo));
        cellDados.setBorder(PdfPCell.NO_BORDER);
        cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
        pTableDados.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("46.666.790,01 STD", fontCorpo));
        cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
        pTableDados.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("Acessrios", fontCorpo));
        cellDados.setBorder(PdfPCell.NO_BORDER);
        cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
        pTableDados.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("1.000.000,00 STD", fontCorpo));
        cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
        pTableDados.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("Imposto", fontCorpo));
        cellDados.setBorder(PdfPCell.NO_BORDER);
        cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
        pTableDados.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("2.680.669,75 STD", fontCorpo));
        cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
        pTableDados.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("FGA", fontCorpo));
        cellDados.setBorder(PdfPCell.NO_BORDER);
        cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
        pTableDados.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("1.196.669,75 STD", fontCorpo));
        cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
        pTableDados.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("TOTAL", fontCorpoN));
        cellDados.setBorder(PdfPCell.NO_BORDER);
        pTableDados.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("51.744.000,00 STD", fontCorpoN));
        cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
        pTableDados.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("Cambio", fontCorpo));
        cellDados.setBorder(PdfPCell.NO_BORDER);
        pTableDados.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("24.500,00 STD", fontCorpo));
        cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
        cellDados.setBorder(PdfPCell.NO_BORDER);
        pTableDados.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("Total a pagar Euros", fontCorpo));
        cellDados.setBorderWidthRight(0);
        pTableDados.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("2.112,00 EUR", fontCorpo));
        cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
        cellDados.setBorderWidthLeft(0);
        pTableDados.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("Total a Pagar USD", fontCorpo));
        cellDados.setBorderWidthRight(0);
        pTableDados.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("2.282.78 USD", fontCorpo));
        cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
        cellDados.setBorderWidthLeft(0);
        pTableDados.addCell(cellDados);

        SimpleDateFormat sdf1 = new SimpleDateFormat("dd-MM-yyyy hh'.'mm'.'ss");

        Document documento = new Document();
        documento.setPageSize(PageSize.A4);
        documento.setMargins(20f, 20f, 70f, 5f);

        String f1 = (arquivo + "/" + user + "/Seguro " + nomeSeguro + "/");
        File f = new File(f1);
        String Ddata = sdf1.format(new Date());
        f.mkdirs();
        f = new File(f.getAbsoluteFile() + "/" + "Fatura CO-Re SEGURO " + Ddata + ".pdf");

        reString = "../Documentos/" + user + "/Seguro " + nomeSeguro + "/" + "Fatura CO-Re SEGURO " + Ddata
                + ".pdf";
        OutputStream outputStraem = new FileOutputStream(f);
        PdfWriter writer = PdfWriter.getInstance(documento, outputStraem);

        documento.open();
        documento.add(pTableEmpresaPricipal);
        documento.add(pTableLinha);
        documento.add(pTableLinha);
        documento.add(pTableTileDoc);
        documento.add(pTableDados);
        documento.close();

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

    return "";
}

From source file:fll.web.playoff.ScoresheetGenerator.java

License:Open Source License

/**
 * Stores the goal cells that are inserted into the output after the team name
 * headers and before the scoring/initials blanks at the bottom of the
 * scoresheet.//from   w ww  . j a v a 2s.  co m
 */
private void setChallengeInfo(final ChallengeDescription description) {
    setPageTitle(description.getTitle());

    if (null != description.getRevision()) {
        setRevisionInfo(description.getRevision());
    }

    if (null != description.getCopyright()) {
        m_copyright = description.getCopyright();
    } else {
        m_copyright = null;
    }

    final PerformanceScoreCategory performanceElement = description.getPerformance();
    // use ArrayList as we will be doing indexed access in the loop
    final List<AbstractGoal> goals = new ArrayList<>(performanceElement.getGoals());

    final float[] relativeWidths = new float[3];
    relativeWidths[0] = 4;
    relativeWidths[1] = 48;
    relativeWidths[2] = 48;
    m_goalsTable = new PdfPTable(relativeWidths);

    String prevCategory = null;
    for (int goalIndex = 0; goalIndex < goals.size(); ++goalIndex) {
        final AbstractGoal goal = goals.get(goalIndex);
        if (!goal.isComputed()) {
            final String category = goal.getCategory();

            // add category cell if needed
            boolean firstRowInCategory = false;
            if (!StringUtils.equals(prevCategory, category)) {
                if (!StringUtils.isEmpty(category)) {

                    // find out how many future goals have the same category
                    int categoryRowSpan = 1;
                    for (int otherIndex = goalIndex + 1; otherIndex < goals.size(); ++otherIndex) {
                        final AbstractGoal otherGoal = goals.get(otherIndex);
                        if (!otherGoal.isComputed()) {
                            if (StringUtils.equals(category, otherGoal.getCategory())) {
                                ++categoryRowSpan;
                            } else {
                                break;
                            }
                        }
                    }

                    final Paragraph catPara = new Paragraph(category, ARIAL_10PT_NORMAL);
                    final PdfPCell categoryCell = new PdfPCell(catPara);
                    categoryCell.setBorderWidthTop(1);
                    categoryCell.setBorderWidthBottom(0);
                    categoryCell.setBorderWidthLeft(0);
                    categoryCell.setBorderWidthRight(0);
                    categoryCell.setVerticalAlignment(Element.ALIGN_CENTER);
                    categoryCell.setHorizontalAlignment(Element.ALIGN_CENTER);
                    categoryCell.setRotation(90);
                    categoryCell.setRowspan(categoryRowSpan);
                    m_goalsTable.addCell(categoryCell);
                }

                // first row in a new category, which may be empty
                firstRowInCategory = true;
            }

            // This is the text for the left hand "label" cell
            final String title = goal.getTitle();
            final Paragraph p = new Paragraph(title, ARIAL_10PT_NORMAL);
            final PdfPCell goalLabel = new PdfPCell(p);
            goalLabel.setHorizontalAlignment(Element.ALIGN_RIGHT);
            goalLabel.setVerticalAlignment(Element.ALIGN_CENTER);
            if (firstRowInCategory) {
                goalLabel.setBorderWidthTop(1);
                goalLabel.setBorderWidthBottom(0);
                goalLabel.setBorderWidthLeft(0);
                goalLabel.setBorderWidthRight(0);
            } else {
                goalLabel.setBorder(0);
            }
            goalLabel.setPaddingRight(9);
            goalLabel.setVerticalAlignment(Element.ALIGN_TOP);
            if (StringUtils.isEmpty(category)) {
                // category column and goal label column
                goalLabel.setColspan(2);
            }
            m_goalsTable.addCell(goalLabel);

            // define the value cell
            final double min = goal.getMin();
            final String minStr = FP.equals(min, Math.round(min), 1E-6) ? String.valueOf((int) min)
                    : String.valueOf(min);
            final double max = goal.getMax();
            final String maxStr = FP.equals(max, Math.round(max), 1E-6) ? String.valueOf((int) max)
                    : String.valueOf(max);

            // If element has child nodes, then we have an enumerated list
            // of choices. Otherwise it is either yes/no or a numeric field.
            final PdfPCell goalValue = new PdfPCell();
            final Chunk choices = new Chunk("", COURIER_10PT_NORMAL);
            if (goal.isEnumerated()) {
                // replace spaces with "no-break" spaces
                boolean first = true;
                final List<EnumeratedValue> values = goal.getSortedValues();
                for (final EnumeratedValue value : values) {
                    if (!first) {
                        choices.append(" /" + Utilities.NON_BREAKING_SPACE);
                    } else {
                        first = false;
                    }
                    choices.append(value.getTitle().toUpperCase().replace(' ', Utilities.NON_BREAKING_SPACE));
                }
                goalValue.addElement(choices);

            } else {
                if (goal.isYesNo()) {
                    // order of yes/no needs to match ScoreEntry.generateYesNoButtons
                    final Paragraph q = new Paragraph("NO / YES", COURIER_10PT_NORMAL);
                    goalValue.addElement(q);

                } else {
                    final String range = "(" + minStr + " - " + maxStr + ")";
                    final PdfPTable t = new PdfPTable(2);
                    t.setHorizontalAlignment(Element.ALIGN_LEFT);
                    t.setTotalWidth(1 * POINTS_PER_INCH);
                    t.setLockedWidth(true);
                    final Phrase r = new Phrase("", ARIAL_8PT_NORMAL);
                    t.addCell(new PdfPCell(r));
                    final Phrase q = new Phrase(range, ARIAL_8PT_NORMAL);
                    t.addCell(new PdfPCell(q));
                    goalValue.setPaddingTop(9);
                    goalValue.addElement(t);
                }
            }

            if (firstRowInCategory) {
                goalValue.setBorderWidthTop(1);
                goalValue.setBorderWidthBottom(0);
                goalValue.setBorderWidthLeft(0);
                goalValue.setBorderWidthRight(0);
            } else {
                goalValue.setBorder(0);
            }
            goalValue.setVerticalAlignment(Element.ALIGN_MIDDLE);

            m_goalsTable.addCell(goalValue);

            // setup for next loop
            prevCategory = category;
        } // if not computed goal

    } // foreach goal

}

From source file:fll.web.report.ReportPageEventHandler.java

License:Open Source License

@Override
// initialization of the header table
public void onEndPage(final PdfWriter writer, final Document document) {
    final PdfPTable header = new PdfPTable(2);
    final Phrase p = new Phrase();
    final Chunk ck = new Chunk(_challengeTitle + "\n" + _reportTitle, _font);
    p.add(ck);//from  w  w w .j a  v  a  2s .co  m
    header.getDefaultCell().setBorderWidth(0);
    header.addCell(p);
    header.getDefaultCell().setHorizontalAlignment(com.itextpdf.text.Element.ALIGN_RIGHT);
    header.addCell(new Phrase(new Chunk("Tournament: " + _tournament + "\nDate: " + _formattedDate, _font)));
    final PdfPCell blankCell = new PdfPCell();
    blankCell.setBorder(0);
    blankCell.setBorderWidthTop(1.0f);
    blankCell.setColspan(2);
    header.addCell(blankCell);

    final PdfContentByte cb = writer.getDirectContent();
    cb.saveState();
    header.setTotalWidth(document.right() - document.left());
    header.writeSelectedRows(0, -1, document.left(), document.getPageSize().getHeight() - 10, cb);
    cb.restoreState();
}

From source file:gov.utah.dts.det.ccl.documents.reporting.reports.CaseloadReport.java

@Override
public void render(Map<String, Object> context, OutputStream outputStream, FileDescriptor descriptor)
        throws TemplateException {
    List<Object[]> results = getResults(context);

    ColumnType columnType = ColumnType.valueOf((String) context.get(COLUMN_TYPE_KEY));
    RoleType roleType = RoleType.valueOf((String) context.get(SPECIALIST_TYPE_KEY));

    ReportTable<Integer> reportTable = new ReportTable<Integer>();

    for (Object[] res : results) {
        String column = null;/*ww w.  j a v a2 s.  c  om*/
        switch (columnType) {
        case LICENSE_TYPE:
            column = (String) res[3];
            break;
        case CITY:
            column = (String) res[3];
            break;
        case COUNTY:
            column = locationService.getCounty((String) res[3], (String) res[4], (String) res[5]);
            break;
        case ZIP_CODE:
            String zip = (String) res[5];
            if (zip.length() > 5) {
                zip = zip.substring(0, 5);
            }
            column = zip;
            break;
        }

        if (StringUtils.isBlank(column)) {
            column = "Unknown";
        }

        reportTable.addColumn(column);

        String specRow = null;
        String specFnm = (String) res[1];
        String specLnm = (String) res[2];
        if (StringUtils.isNotBlank(specFnm) || StringUtils.isNotBlank(specLnm)) {
            PersonalName name = new PersonalName(specFnm, specLnm);
            specRow = name.getFirstAndLastName();
        } else {
            specRow = "Unknown";
        }

        reportTable.addRow(specRow);

        Integer val = reportTable.getTableDataItem(specRow, column);
        if (val == null) {
            val = new Integer(1);
        } else {
            val = new Integer(val.intValue() + 1);
        }
        reportTable.addTableDataItem(specRow, column, val);
    }

    setFileName(context, descriptor);

    Document document = new Document(PAGE_SIZE, MARGIN, MARGIN, MARGIN, MARGIN);
    try {
        PdfWriter canvas = PdfWriter.getInstance(document, outputStream);
        document.open();

        ColumnText text = new ColumnText(canvas.getDirectContent());
        text.setSimpleColumn(document.getPageSize().getLeft(MARGIN), document.getPageSize().getBottom(MARGIN),
                document.getPageSize().getRight(MARGIN), document.getPageSize().getTop(MARGIN));

        StringBuilder sb = new StringBuilder(roleType.getDisplayName());
        sb.append(" Caseloads");
        Paragraph heading = new Paragraph(sb.toString(), REPORT_HEADING_FONT);
        heading.setAlignment(Element.ALIGN_CENTER);
        text.addElement(heading);
        text.go();
        float yLine = text.getYLine();
        yLine -= FONT_SIZE;

        int columns = reportTable.getColumns().size() + 2;

        String[][] totTab = new String[reportTable.getRows().size()][columns];
        float maxLicWidth = 0f;
        float maxTotWidth = FONT_SIZE;
        int rowIdx = 0;
        for (Iterator<String> rowItr = reportTable.getRows().iterator(); rowItr.hasNext();) {
            String row = rowItr.next();
            totTab[rowIdx][0] = row;
            float licWidth = getTextWidth(row, FONT);
            if (licWidth > maxLicWidth) {
                maxLicWidth = licWidth;
            }

            int rowTotal = 0;
            int colIdx = 1;
            for (Iterator<String> colItr = reportTable.getColumns().iterator(); colItr.hasNext();) {
                String col = colItr.next();
                Integer val = reportTable.getTableDataItem(row, col);
                if (val != null) {
                    totTab[rowIdx][colIdx] = val.toString();
                    rowTotal += val.intValue();
                }
                colIdx++;
            }
            String rowTotalStr = Integer.toString(rowTotal);
            float totWidth = getTextWidth(rowTotalStr, TABLE_HEADER_FONT);
            if (totWidth > maxTotWidth) {
                maxTotWidth = totWidth;
            }
            totTab[rowIdx][columns - 1] = rowTotalStr;
            rowIdx++;
        }

        //add border and cell padding to licensor width
        maxLicWidth += (TABLE_CELL_PADDING * 2) + (TABLE_BORDER_SIZE * 2);
        maxTotWidth += (TABLE_CELL_PADDING * 2) + (TABLE_BORDER_SIZE * 2);

        float width = PAGE_SIZE.getWidth() - (2 * MARGIN);
        width -= maxLicWidth;

        float[] colWidths = new float[columns];
        colWidths[0] = maxLicWidth;
        for (int i = 1; i < columns; i++) {
            colWidths[i] = maxTotWidth;
        }

        PdfPTable table = new PdfPTable(reportTable.getColumns().size() + 2);
        table.setHeaderRows(1);
        table.setLockedWidth(true);
        table.setTotalWidth(colWidths);
        table.setSpacingBefore(FONT_SIZE);
        setDefaultCellAttributes(table.getDefaultCell());

        PdfPCell cell = null;

        cell = new PdfPCell(new Phrase(""));
        cell.setBorderWidthTop(0);
        cell.setBorderWidthLeft(0);
        table.addCell(cell);
        for (Iterator<String> itr = reportTable.getColumns().iterator(); itr.hasNext();) {
            cell = getRotatedHeaderCell(itr.next());
            table.addCell(cell);
        }
        cell = getRotatedHeaderCell("Total");
        table.addCell(cell);

        for (String[] row : totTab) {
            for (int i = 0; i < row.length; i++) {
                if (row[i] == null) {
                    table.addCell(getNumberCell(""));
                } else {
                    table.addCell(getCell(new Phrase(row[i], i == row.length - 1 ? TABLE_HEADER_FONT : FONT),
                            i == 0 ? Element.ALIGN_LEFT : Element.ALIGN_CENTER));
                }

            }
        }

        writeTable(table, document, canvas.getDirectContent(), colWidths, yLine, true);
    } catch (DocumentException de) {
        throw new TemplateException(de);
    }
    document.close();
}

From source file:gov.va.cem.eoas.business.FaxArchivesPDF.java

public InputStream generatePDF(FaxRecord data) {
    SimpleDateFormat newFormat = new SimpleDateFormat("MM/dd/yyyy");

    Date curDate = new Date();
    String caseIdData = (data.getCaseId() != null) ? data.getCaseId() : "";
    String currentDate = new String(newFormat.format(curDate));
    String sepDocs = (data.getSepDocs()) ? "X" : "";
    String marLicense = (data.getMarLicense()) ? "X" : "";
    String adminDecision = (data.getAdminDecision()) ? "X" : "";
    String deathCert = (data.getDeathCert()) ? "X" : "";
    String divorceDecree = (data.getDivorceDecree()) ? "X" : "";
    String otherCheck = (data.getOtherCheck()) ? "X" : "";
    String transDate = (data.getTransDate() != null) ? new String(newFormat.format(data.getTransDate())) : "";
    String priorLoc = (data.getPriorLoc() != null) ? data.getPriorLoc() : "";
    String otherComments = (data.getOtherComments() != null) ? data.getOtherComments() : "";
    String remarks = (data.getRemarks() != null) ? data.getRemarks() : "";
    String to = data.getTo().getDisplayName();
    String fileNo = (data.getFileNo() != null) ? data.getFileNo() : "";
    String vetName = (data.getVetName() != null) ? data.getVetName() : "";
    String ssnData = (data.getSSN() != null) ? data.getSSN() : "";
    String snData = (data.getSN() != null) ? data.getSN() : "";
    String farcNo = (data.getFarcNo() != null) ? data.getFarcNo() : "";
    String boxNoData = (data.getBoxNo() != null) ? data.getBoxNo() : "";
    String faxPages = (data.getFaxPages() != null) ? data.getFaxPages() : "";

    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    Document document = new Document(PageSize.A4, 50, 50, 50, 50);
    try {/*from  w  w  w .j a v  a2s  .  co m*/
        PdfWriter.getInstance(document, outputStream);
        //Font font1 = new Font(Font.FontFamily.TIMES_ROMAN, 9);
        Font font2 = new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.BOLD);
        Font font3 = new Font(Font.FontFamily.TIMES_ROMAN, 11);
        Font fontBold = new Font(Font.FontFamily.TIMES_ROMAN, 11, Font.BOLD);
        //Font fontUnderline = new Font(Font.FontFamily.TIMES_ROMAN, 11, Font.UNDERLINE);
        Font fontHeader = new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD);

        document.open();

        String dirPath = FacesContext.getCurrentInstance().getExternalContext()
                .getInitParameter("image_file_path");
        // Check servlet context for invalid character
        if (dirPath.contains(".."))
            throw new IllegalArgumentException(
                    "Servlet context contains invalid character(s).  Security may have been compromised.");
        File dir = new File(dirPath);

        Image image = Image.getInstance(dir + "/ArchiveFaxHeader.jpg");
        image.scalePercent(69, 66);
        document.add(image);

        // Create first table
        float[] colsWidthTo = { .3f, 2f, .4f, 2f };
        PdfPTable addressTable = new PdfPTable(colsWidthTo);
        addressTable.setWidthPercentage(100);
        PdfPCell toLabel = new PdfPCell(new Phrase("TO:", fontBold));
        toLabel.setRowspan(3);
        toLabel.setBorderWidthRight(0);
        addressTable.addCell(toLabel);
        PdfPCell toName = new PdfPCell(new Phrase(to, fontBold));
        toName.setBorderWidthLeft(0);
        toName.setBorderWidthBottom(0);
        addressTable.addCell(toName);
        PdfPCell fromLabel = new PdfPCell(new Phrase("FROM:", fontBold));
        fromLabel.setBorderWidthRight(0);
        fromLabel.setBorderWidthBottom(0);
        addressTable.addCell(fromLabel);
        PdfPCell fromName = new PdfPCell(new Phrase("Eligibility Case Manager", fontBold));
        fromName.setBorderWidthBottom(0);
        fromName.setBorderWidthLeft(0);
        addressTable.addCell(fromName);
        PdfPCell toAddress = new PdfPCell(new Phrase("", fontBold));
        toAddress.setBorderWidthLeft(0);
        toAddress.setBorderWidthTop(0);
        addressTable.addCell(toAddress);
        PdfPCell fromDateLabel = new PdfPCell(new Phrase("DATE:", fontBold));
        fromDateLabel.setBorderWidthRight(0);
        fromDateLabel.setBorderWidthTop(0);
        //toLabel.setRowspan(2);
        addressTable.addCell(fromDateLabel);
        PdfPCell dateFrom = new PdfPCell(new Phrase(currentDate, fontBold));
        dateFrom.setBorderWidthTop(0);
        dateFrom.setBorderWidthLeft(0);
        addressTable.addCell(dateFrom);
        addressTable.setSpacingBefore(15);
        addressTable.setSpacingAfter(15);
        document.add(addressTable);

        float[] colsWidthCaseId = { .7f, 3f };
        PdfPTable caseTable = new PdfPTable(colsWidthCaseId);
        caseTable.setWidthPercentage(100);
        PdfPCell caseIdLabel = new PdfPCell(new Phrase("Eligibility Case Id:", font3));
        caseIdLabel.setBorderWidth(0);
        caseTable.addCell(caseIdLabel);
        PdfPCell caseIdInput = new PdfPCell(new Phrase(caseIdData, font3));
        caseIdInput.setBorderWidth(0);
        caseTable.addCell(caseIdInput);
        caseTable.setSpacingAfter(8);
        document.add(caseTable);

        float[] colsWidthFolder = { .5f, 3f };
        PdfPTable folderTable = new PdfPTable(colsWidthFolder);
        folderTable.setWidthPercentage(100);
        PdfPCell folderLabel = new PdfPCell(new Phrase("VA file No:", font3));
        folderLabel.setBorderWidth(0);
        folderTable.addCell(folderLabel);
        PdfPCell folder = new PdfPCell(new Phrase(fileNo, font3));
        folder.setBorderWidth(0);
        folderTable.addCell(folder);
        folderTable.setSpacingAfter(8);
        document.add(folderTable);

        float[] colsWidthRef = { .7f, 3f };
        PdfPTable refTable = new PdfPTable(colsWidthRef);
        refTable.setWidthPercentage(100);
        PdfPCell ref = new PdfPCell(new Phrase("Veteran's Name:", font3));
        ref.setBorderWidth(0);
        refTable.addCell(ref);
        PdfPCell refName = new PdfPCell(new Phrase(vetName, font3));
        refName.setBorderWidth(0);
        refTable.addCell(refName);
        refTable.setSpacingAfter(8);
        document.add(refTable);

        float[] colsWidthSSN = { .3f, 2f, .25f, 2f };
        PdfPTable ssnTable = new PdfPTable(colsWidthSSN);
        ssnTable.setWidthPercentage(100);
        PdfPCell ssnLabel = new PdfPCell(new Phrase("SSN:", font3));
        ssnLabel.setBorderWidth(0);
        ssnTable.addCell(ssnLabel);
        PdfPCell ssn = new PdfPCell(new Phrase(ssnData, font3));
        ssn.setBorderWidth(0);
        ssnTable.addCell(ssn);
        PdfPCell snLabel = new PdfPCell(new Phrase("SN:", font3));
        snLabel.setBorderWidth(0);
        ssnTable.addCell(snLabel);
        PdfPCell sn = new PdfPCell(new Phrase(snData, font3));
        sn.setBorderWidth(0);
        ssnTable.addCell(sn);
        ssnTable.setSpacingAfter(8);
        document.add(ssnTable);

        float[] colsWidthFARC = { .6f, 2f, .8f, 2f };
        PdfPTable farcTable = new PdfPTable(colsWidthFARC);
        farcTable.setWidthPercentage(100);
        PdfPCell farcLabel = new PdfPCell(new Phrase("FARC No:", font3));
        farcLabel.setBorderWidth(0);
        farcTable.addCell(farcLabel);
        PdfPCell farc = new PdfPCell(new Phrase(farcNo, font3));
        farc.setBorderWidth(0);
        farcTable.addCell(farc);
        PdfPCell farcDateLabel = new PdfPCell(new Phrase("Transfer Date:", font3));
        farcDateLabel.setBorderWidth(0);
        farcTable.addCell(farcDateLabel);
        PdfPCell farcDate = new PdfPCell(new Phrase(transDate, font3));
        farcDate.setBorderWidth(0);
        farcTable.addCell(farcDate);
        farcTable.setSpacingAfter(8);
        document.add(farcTable);

        float[] colsWidthLoc = { .8f, 2f, .6f, 2f };
        PdfPTable locTable = new PdfPTable(colsWidthLoc);
        locTable.setWidthPercentage(100);
        PdfPCell locLabel = new PdfPCell(new Phrase("Prior Location:", font3));
        locLabel.setBorderWidth(0);
        locTable.addCell(locLabel);
        PdfPCell location = new PdfPCell(new Phrase(priorLoc, font3));
        location.setBorderWidth(0);
        locTable.addCell(location);
        PdfPCell boxNoLabel = new PdfPCell(new Phrase("Box No:", font3));
        boxNoLabel.setBorderWidth(0);
        locTable.addCell(boxNoLabel);
        PdfPCell boxNo = new PdfPCell(new Phrase(boxNoData, font3));
        boxNo.setBorderWidth(0);
        locTable.addCell(boxNo);
        locTable.setSpacingAfter(8);
        document.add(locTable);

        float[] colsWidthRemarks = { .6f, 5f };
        PdfPTable remarks1Table = new PdfPTable(colsWidthRemarks);
        remarks1Table.setWidthPercentage(100);
        PdfPCell remark1Label = new PdfPCell(new Phrase("Remarks:", font3));
        remark1Label.setBorderWidth(0);
        remarks1Table.addCell(remark1Label);
        PdfPCell remarks1Input = new PdfPCell(new Phrase(
                "Please provide copy(ies) of the following document(s) to establish eligibility for burial in a national cemetery.",
                font3));
        remarks1Input.setBorderWidth(0);
        remarks1Table.addCell(remarks1Input);
        remarks1Table.setSpacingAfter(8);
        document.add(remarks1Table);

        float[] colsWidthDocs = { .4f, 2f, .4f, 2f };
        PdfPTable docsTable = new PdfPTable(colsWidthDocs);
        docsTable.setWidthPercentage(100);
        PdfPCell docsLabel = new PdfPCell(new Phrase(sepDocs, font3));
        docsLabel.setHorizontalAlignment(Element.ALIGN_CENTER);
        docsLabel.setBorderWidth(0);
        docsLabel.setBorderWidthBottom(1);
        docsTable.addCell(docsLabel);
        PdfPCell docs1 = new PdfPCell(new Phrase("Separation Document(s)", font3));
        docs1.setBorderWidth(0);
        docsTable.addCell(docs1);
        PdfPCell docs2 = new PdfPCell(new Phrase(deathCert, font3));
        docs2.setHorizontalAlignment(Element.ALIGN_CENTER);
        docs2.setBorderWidth(0);
        docs2.setBorderWidthBottom(1);
        docsTable.addCell(docs2);
        PdfPCell docs3 = new PdfPCell(new Phrase("Death Certificate", font3));
        docs3.setBorderWidth(0);
        docsTable.addCell(docs3);
        PdfPCell docs4 = new PdfPCell(new Phrase(marLicense, font3));
        docs4.setHorizontalAlignment(Element.ALIGN_CENTER);
        docs4.setBorderWidth(0);
        docs4.setBorderWidthBottom(1);
        docsTable.addCell(docs4);
        PdfPCell docs5 = new PdfPCell(new Phrase("Marriage License", font3));
        docs5.setBorderWidth(0);
        docsTable.addCell(docs5);
        PdfPCell docs6 = new PdfPCell(new Phrase(divorceDecree, font3));
        docs6.setHorizontalAlignment(Element.ALIGN_CENTER);
        docs6.setBorderWidth(0);
        docs6.setBorderWidthBottom(1);
        docsTable.addCell(docs6);
        PdfPCell docs7 = new PdfPCell(new Phrase("Divorce Decree", font3));
        docs7.setBorderWidth(0);
        docsTable.addCell(docs7);
        PdfPCell docs8 = new PdfPCell(new Phrase(adminDecision, font3));
        docs8.setHorizontalAlignment(Element.ALIGN_CENTER);
        docs8.setBorderWidth(0);
        docs8.setBorderWidthBottom(1);
        docsTable.addCell(docs8);
        PdfPCell docs9 = new PdfPCell(new Phrase("VA Admin Decision", font3));
        docs9.setBorderWidth(0);
        docsTable.addCell(docs9);
        PdfPCell docs10 = new PdfPCell(new Phrase("", font3));
        docs10.setBorderWidth(0);
        docsTable.addCell(docs10);
        PdfPCell docs11 = new PdfPCell(new Phrase("", font3));
        docs11.setBorderWidth(0);
        docsTable.addCell(docs11);
        document.add(docsTable);

        float[] colsWidthOther = { .4f, .4f, 4f };
        PdfPTable otherDocTable = new PdfPTable(colsWidthOther);
        otherDocTable.setWidthPercentage(100);
        PdfPCell otherDoc1 = new PdfPCell(new Phrase(otherCheck, font3));
        otherDoc1.setHorizontalAlignment(Element.ALIGN_CENTER);
        otherDoc1.setBorderWidth(0);
        otherDoc1.setBorderWidthBottom(1);
        otherDocTable.addCell(otherDoc1);
        PdfPCell otherDoc2 = new PdfPCell(new Phrase("Other", font3));
        otherDoc2.setBorderWidth(0);
        otherDocTable.addCell(otherDoc2);
        PdfPCell otherDoc3 = new PdfPCell(new Phrase("", font3));
        otherDoc3.setBorderWidth(0);
        otherDocTable.addCell(otherDoc3);
        otherDocTable.setSpacingAfter(8);
        document.add(otherDocTable);

        if (!otherComments.equals("")) {
            float[] colsWidthOtherComments = { 1.1f, 5f };
            PdfPTable otherCommentsTable = new PdfPTable(colsWidthOtherComments);
            otherCommentsTable.setWidthPercentage(100);
            PdfPCell otherCommentLabel = new PdfPCell(new Phrase("Other Comments:", font3));
            otherCommentLabel.setBorderWidth(0);
            otherCommentsTable.addCell(otherCommentLabel);
            PdfPCell otherCommentsInput = new PdfPCell(new Phrase(otherComments, font3));
            otherCommentsInput.setBorderWidth(0);
            otherCommentsTable.addCell(otherCommentsInput);
            otherCommentsTable.setSpacingAfter(8);
            document.add(otherCommentsTable);
        }

        PdfPTable remarksTable = new PdfPTable(colsWidthRemarks);
        remarksTable.setWidthPercentage(100);
        PdfPCell remarkLabel = new PdfPCell(new Phrase("Remarks:", font3));
        remarkLabel.setBorderWidth(0);
        remarksTable.addCell(remarkLabel);
        PdfPCell remarksInput = new PdfPCell(new Phrase(remarks, font3));
        remarksInput.setBorderWidth(0);
        remarksTable.addCell(remarksInput);
        remarksTable.setSpacingAfter(8);
        document.add(remarksTable);

        Paragraph expediteOne = new Paragraph("-- PLEASE EXPEDITE --", font3);
        expediteOne.setSpacingBefore(5);
        expediteOne.setSpacingAfter(10);
        document.add(expediteOne);

        Paragraph disclosure = new Paragraph(
                "This fax is intended only for the use of the person or office to which it is addressed and may contain information that is privileged, confidential, or protected by law.  All others are hereby notified that the receipt of this fax does not waive any applicable privilege or exemption for disclosure and that any dissemination, distribution, or copying of this communication is prohibited.  If you have received this fax in error, please notify this office immediately at the telephone number listed above.",
                font2);
        disclosure.setAlignment(Element.ALIGN_JUSTIFIED);
        disclosure.setSpacingBefore(5);
        disclosure.setSpacingAfter(10);
        document.add(disclosure);

        float[] colsWidthPages = { 5f, .5f, 2f };
        PdfPTable pagesTable = new PdfPTable(colsWidthPages);
        pagesTable.setWidthPercentage(71);
        PdfPCell pageOneLabel = new PdfPCell(
                new Phrase("This fax sheet consists of the cover page and ", fontHeader));
        pageOneLabel.setBorderWidth(0);
        pageOneLabel.setHorizontalAlignment(Element.ALIGN_RIGHT);
        pagesTable.addCell(pageOneLabel);
        PdfPCell pages = new PdfPCell(new Phrase(faxPages, fontHeader));
        pages.setBorderWidth(0);
        pages.setHorizontalAlignment(Element.ALIGN_CENTER);
        pages.setBorderWidthBottom(1);
        pagesTable.addCell(pages);
        PdfPCell pageTwoLabel = new PdfPCell(new Phrase(" additional pages", fontHeader));
        pageTwoLabel.setBorderWidth(0);
        pagesTable.addCell(pageTwoLabel);
        pagesTable.setSpacingAfter(8);
        document.add(pagesTable);

        Paragraph expediteTwo = new Paragraph("FAX:  816-268-8163  ***** BURIAL  PLEASE EXPEDITE   *****",
                fontBold);
        expediteTwo.setSpacingBefore(5);
        expediteTwo.setSpacingAfter(10);
        document.add(expediteTwo);

        document.close();
    } catch (Exception ex) {
        System.err.println(ex.getMessage());
    }
    return new ByteArrayInputStream(outputStream.toByteArray());

}

From source file:ics4u.ics4u_final_project.Recipe.java

License:Open Source License

private void addData(Document doc) {
    //create the format for the % Daily Value
    DecimalFormat onePer = new DecimalFormat("#,##0%");
    try {/*w w  w  .  ja v  a2s.c  o  m*/
        //add the title of the recipe
        doc.add(new Paragraph(title, TITLE_FONT));
        //add each of the ingredients
        for (int i = 0; i < ingredients.size(); i++) {
            doc.add(new Paragraph(ingredients.get(i).getFormattedName(), LABEL_NORMAL));
        }
        //add the instructions
        Paragraph p = new Paragraph();
        if (!instructions.equals("")) {
            p = new Paragraph(new Phrase("Instructions:\n", LABEL_FONT));
            doc.add(p);
            p = new Paragraph();
            p.add(new Phrase(instructions + "\n", LABEL_NORMAL));
        } else {
            p.add(new Phrase("\n"));
        }
        //create the nutrient value table
        PdfPTable label = new PdfPTable(10);
        label.setWidthPercentage(30);
        //Top
        PdfPCell c = new PdfPCell(new Phrase("Nutrition Facts", LABEL_FONT));
        c.setColspan(10);
        c.setBorderWidthBottom(0);
        label.addCell(c);
        c = new PdfPCell(new Phrase("Per " + servingName, LABEL_BOLD));
        c.setColspan(10);
        c.setBorderWidthTop(0);
        label.addCell(c);
        //Amount
        PdfPCell c2a = new PdfPCell(new Phrase("Amount", LABEL_SMALL));
        c2a.setColspan(3);
        c2a.setBorderWidthRight(0);
        PdfPCell c2b = new PdfPCell(new Phrase("% Daily Value", LABEL_SMALL));
        c2b.setColspan(10);
        c2b.setHorizontalAlignment(Element.ALIGN_RIGHT);
        c2b.setBorderWidthLeft(0);
        label.addCell(c2a);
        label.addCell(c2b);
        //Calories
        c = new PdfPCell(new Phrase("Calories " + (int) (nutrients[208] / servings), LABEL_BOLD));
        c.setColspan(10);
        c.setBorderWidthTop(2);
        label.addCell(c);
        //Fat
        PdfPCell ca = new PdfPCell(new Phrase("Fat " + (int) (nutrients[204] / servings) + "g", LABEL_BOLD));
        ca.setColspan(6);
        ca.setBorderWidthRight(0);
        PdfPCell cb = new PdfPCell(new Phrase(onePer.format((nutrients[204] / servings) / 60.0), LABEL_BOLD));
        cb.setColspan(10);
        cb.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cb.setBorderWidthLeft(0);
        label.addCell(ca);
        label.addCell(cb);
        //fat 2
        ca = new PdfPCell(new Phrase("Saturated " + ((int) (nutrients[606] / servings)) + "g\n\t+ Trans "
                + ((int) (nutrients[605] / servings)) + "g", LABEL_NORMAL));
        ca.setColspan(6);
        ca.setIndent(16);
        ca.setBorderWidthRight(0);
        cb = new PdfPCell(new Phrase(onePer.format((nutrients[606] / servings) / 20.0), LABEL_BOLD));
        cb.setColspan(10);
        cb.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cb.setBorderWidthLeft(0);
        label.addCell(ca);
        label.addCell(cb);
        //Cholesterol
        c = new PdfPCell(new Phrase("Cholesterol " + ((int) (nutrients[601] / servings)) + "mg", LABEL_BOLD));
        c.setColspan(10);
        label.addCell(c);
        //Sodium
        ca = new PdfPCell(new Phrase("Sodium " + (int) (nutrients[307] / servings) + "mg", LABEL_BOLD));
        ca.setColspan(6);
        ca.setBorderWidthRight(0);
        cb = new PdfPCell(new Phrase(onePer.format((nutrients[307] / servings) / 2400.0), LABEL_BOLD));
        cb.setColspan(10);
        cb.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cb.setBorderWidthLeft(0);
        label.addCell(ca);
        label.addCell(cb);
        //Carbs
        ca = new PdfPCell(new Phrase("Carbohydrate " + (int) (nutrients[205] / servings) + "g", LABEL_BOLD));
        ca.setColspan(7);
        ca.setBorderWidthRight(0);
        cb = new PdfPCell(new Phrase(onePer.format((nutrients[205] / servings) / 300.0), LABEL_BOLD));
        cb.setColspan(10);
        cb.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cb.setBorderWidthLeft(0);
        label.addCell(ca);
        label.addCell(cb);
        //Fibre
        ca = new PdfPCell(new Phrase("Fibre " + (int) (nutrients[291] / servings) + "g", LABEL_NORMAL));
        ca.setColspan(6);
        ca.setIndent(16);
        ca.setBorderWidthRight(0);
        cb = new PdfPCell(new Phrase(onePer.format((nutrients[291] / servings) / 25.0), LABEL_BOLD));
        cb.setColspan(10);
        cb.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cb.setBorderWidthLeft(0);
        label.addCell(ca);
        label.addCell(cb);
        //Sugar
        ca = new PdfPCell(new Phrase("Sugars " + (int) (nutrients[269] / servings) + "g", LABEL_NORMAL));
        ca.setColspan(10);
        ca.setIndent(16);
        label.addCell(ca);
        //Protein
        ca = new PdfPCell(new Phrase("Protein " + (int) (nutrients[203] / servings) + "g", LABEL_BOLD));
        ca.setColspan(10);
        label.addCell(ca);
        //Vit A
        ca = new PdfPCell(new Phrase("Vitamin A", LABEL_NORMAL));
        ca.setColspan(6);
        ca.setBorderWidthRight(0);
        ca.setBorderWidthTop(2);
        cb = new PdfPCell(cb = new PdfPCell(new Phrase(
                onePer.format(
                        ((nutrients[319] + (nutrients[321] / 12) + (nutrients[834] / 24)) / servings) / 1000),
                LABEL_NORMAL)));
        cb.setColspan(10);
        cb.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cb.setBorderWidthLeft(0);
        cb.setBorderWidthTop(2);
        label.addCell(ca);
        label.addCell(cb);
        //Vit C
        ca = new PdfPCell(new Phrase("Vitamin C", LABEL_NORMAL));
        ca.setColspan(6);
        ca.setBorderWidthRight(0);
        cb = new PdfPCell(new Phrase(onePer.format((nutrients[401] / servings) / 60.0), LABEL_NORMAL));
        cb.setColspan(10);
        cb.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cb.setBorderWidthLeft(0);
        label.addCell(ca);
        label.addCell(cb);
        //Calcium
        ca = new PdfPCell(new Phrase("Calcium", LABEL_NORMAL));
        ca.setColspan(6);
        ca.setBorderWidthRight(0);
        cb = new PdfPCell(new Phrase(onePer.format((nutrients[301] / servings) / 1100.0), LABEL_NORMAL));
        cb.setColspan(10);
        cb.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cb.setBorderWidthLeft(0);
        label.addCell(ca);
        label.addCell(cb);
        //Iron
        ca = new PdfPCell(new Phrase("Iron", LABEL_NORMAL));
        ca.setColspan(6);
        ca.setBorderWidthRight(0);
        cb = new PdfPCell(new Phrase(onePer.format((nutrients[303] / servings) / 14.0), LABEL_NORMAL));
        cb.setColspan(10);
        cb.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cb.setBorderWidthLeft(0);
        label.addCell(ca);
        label.addCell(cb);
        //Add to the table
        label.setHorizontalAlignment(Element.ALIGN_LEFT);
        p.add(label);
        //add to the document
        doc.add(p);

    } catch (DocumentException ex) {
        System.out.println("Error: " + ex.toString());
    }
}

From source file:IPDGES.ConcentForm.java

/**
 * Handles the HTTP <code>GET</code> method.
 *
 * @param request servlet request/* ww  w .  j a  va2s.c om*/
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    response.setContentType("application/pdf");

    try {
        //style
        Font typeBold = new Font(Font.FontFamily.TIMES_ROMAN, 12, 1);
        Font type = new Font(Font.FontFamily.TIMES_ROMAN, 10);
        Font title = new Font(Font.FontFamily.TIMES_ROMAN, 15, 1);
        Font subTitle = new Font(Font.FontFamily.TIMES_ROMAN, 13, 1);
        Font subTitle2 = new Font(Font.FontFamily.TIMES_ROMAN, 10, 1);
        float space = (float) 20;

        Document document = new Document();
        document.setPageSize(PageSize.LETTER);
        PdfWriter.getInstance(document, response.getOutputStream());
        document.open();

        //General
        PdfPTable table;
        Paragraph p1;
        Paragraph p2;
        PdfPCell cellRow1;
        PdfPCell cellRow2;

        //row: 1
        table = new PdfPTable(2);
        table.setWidthPercentage(100);
        p1 = new Paragraph(space, "FORMULARIO DE CONSTANCIA DE INFORMACION AL PACIENTE GES", title);
        p1.setAlignment(Element.ALIGN_CENTER);
        cellRow1 = new PdfPCell(p1);
        cellRow1.setColspan(2);
        formatCellBorder(cellRow1, 20);
        table.addCell(cellRow1);
        p1 = new Paragraph(space, "(Artculo 24, Ley 19.966)", subTitle2);
        p1.setAlignment(Element.ALIGN_CENTER);
        cellRow1 = new PdfPCell(p1);
        cellRow1.setColspan(2);
        formatCellBorder(cellRow1, 20);
        table.addCell(cellRow1);
        document.add(table);
        document.add(new Paragraph("\n"));

        //row: 2
        table = new PdfPTable(2);
        table.setWidthPercentage(100);
        p1 = new Paragraph(space, "DATOS DEL PRESTADOR", subTitle);
        cellRow1 = new PdfPCell(p1);
        cellRow1.setColspan(2);
        formatCellBorder(cellRow1, 20);
        cellRow1.setBorderWidthTop(1);
        cellRow1.setBorderWidthLeft(1);
        cellRow1.setBorderWidthRight(1);
        cellRow1.setBorderWidthBottom(1);
        table.addCell(cellRow1);
        p1 = new Paragraph(space, "INSTITUCIN (Hospital, Clnica, Consultorio,etc): " + institution, type);
        cellRow1 = new PdfPCell(p1);
        cellRow1.setColspan(2);
        formatCellBorder(cellRow1, 20);
        cellRow1.setBorderWidthLeft(1);
        cellRow1.setBorderWidthRight(1);
        table.addCell(cellRow1);
        p1 = new Paragraph(space, "DIRECCION: " + address, type);
        p2 = new Paragraph(space, "CIUDAD: " + city, type);
        cellRow1 = new PdfPCell(p1);
        cellRow2 = new PdfPCell(p2);
        formatCellBorder(cellRow1, 20);
        formatCellBorder(cellRow2, 20);
        cellRow1.setBorderWidthLeft(1);
        cellRow2.setBorderWidthRight(1);
        table.addCell(cellRow1);
        table.addCell(cellRow2);
        p1 = new Paragraph(space, "NOMBRE PERSONA QUE NOTIFICA: " + personName, type);
        p2 = new Paragraph(space, "RUT: " + rut, type);
        cellRow1 = new PdfPCell(p1);
        cellRow2 = new PdfPCell(p2);
        formatCellBorder(cellRow1, 20);
        formatCellBorder(cellRow2, 20);
        cellRow1.setBorderWidthLeft(1);
        cellRow2.setBorderWidthRight(1);
        cellRow1.setBorderWidthBottom(1);
        cellRow2.setBorderWidthBottom(1);
        table.addCell(cellRow1);
        table.addCell(cellRow2);
        document.add(table);
        document.add(new Paragraph("\n"));

        //row 3
        table = new PdfPTable(2);
        table.setWidthPercentage(100);
        p1 = new Paragraph(space, "ANTECEDENTES DEL PACIENTE", subTitle);
        cellRow1 = new PdfPCell(p1);
        cellRow1.setColspan(2);
        formatCellBorder(cellRow1, 20);
        cellRow1.setBorderWidthTop(1);
        cellRow1.setBorderWidthLeft(1);
        cellRow1.setBorderWidthRight(1);
        cellRow1.setBorderWidthBottom(1);
        table.addCell(cellRow1);
        p1 = new Paragraph(space, "NOMBRE: " + patientName, type);
        cellRow1 = new PdfPCell(p1);
        cellRow1.setColspan(2);
        formatCellBorder(cellRow1, 20);
        cellRow1.setBorderWidthLeft(1);
        cellRow1.setBorderWidthRight(1);
        table.addCell(cellRow1);
        p1 = new Paragraph(space, "RUT: " + patientRut, type);
        p2 = new Paragraph(space, "FONASA: " + patientFonasa, type);
        cellRow1 = new PdfPCell(p1);
        cellRow2 = new PdfPCell(p2);
        formatCellBorder(cellRow1, 20);
        formatCellBorder(cellRow2, 20);
        cellRow1.setBorderWidthLeft(1);
        cellRow2.setBorderWidthRight(1);
        table.addCell(cellRow1);
        table.addCell(cellRow2);
        p1 = new Paragraph(space, "ISAPRE: " + patientIsapre, type);
        p2 = new Paragraph(space, "DOMICILIO: " + home, type);
        cellRow1 = new PdfPCell(p1);
        cellRow2 = new PdfPCell(p2);
        formatCellBorder(cellRow1, 20);
        formatCellBorder(cellRow2, 20);
        cellRow1.setBorderWidthLeft(1);
        cellRow2.setBorderWidthRight(1);
        table.addCell(cellRow1);
        table.addCell(cellRow2);
        p1 = new Paragraph(space, "COMUNA: " + commune, type);
        p2 = new Paragraph(space, "REGION: " + region, type);
        cellRow1 = new PdfPCell(p1);
        cellRow2 = new PdfPCell(p2);
        formatCellBorder(cellRow1, 20);
        formatCellBorder(cellRow2, 20);
        cellRow1.setBorderWidthLeft(1);
        cellRow2.setBorderWidthRight(1);
        table.addCell(cellRow1);
        table.addCell(cellRow2);
        p1 = new Paragraph(space, "N TELFONO FIJO: " + phoneNumber, type);
        p2 = new Paragraph(space, "N TELFONO CELULAR: " + celularNumber, type);
        cellRow1 = new PdfPCell(p1);
        cellRow2 = new PdfPCell(p2);
        formatCellBorder(cellRow1, 20);
        formatCellBorder(cellRow2, 20);
        cellRow1.setBorderWidthLeft(1);
        cellRow2.setBorderWidthRight(1);
        table.addCell(cellRow1);
        table.addCell(cellRow2);
        p1 = new Paragraph(space, "DIRECCIN CORREO ELECTRNICO (E-MAIL): " + mail, type);
        cellRow1 = new PdfPCell(p1);
        cellRow1.setColspan(2);
        formatCellBorder(cellRow1, 20);
        cellRow1.setBorderWidthLeft(1);
        cellRow1.setBorderWidthRight(1);
        cellRow1.setBorderWidthBottom(1);

        table.addCell(cellRow1);
        document.add(table);
        document.add(new Paragraph("\n"));

        //row 4
        table = new PdfPTable(2);
        table.setWidthPercentage(100);
        p1 = new Paragraph(space, "INFORMACIN MDICA", subTitle);
        cellRow1 = new PdfPCell(p1);
        cellRow1.setColspan(2);
        formatCellBorder(cellRow1, 20);
        cellRow1.setBorderWidthTop(1);
        cellRow1.setBorderWidthLeft(1);
        cellRow1.setBorderWidthRight(1);
        cellRow1.setBorderWidthBottom(1);
        table.addCell(cellRow1);
        p1 = new Paragraph(space, "CONFIRMACIN DIAGNSTICA GES:", type);
        cellRow1 = new PdfPCell(p1);
        cellRow1.setColspan(2);
        formatCellBorder(cellRow1, 20);
        cellRow1.setBorderWidthLeft(1);
        cellRow1.setBorderWidthRight(1);
        table.addCell(cellRow1);
        p1 = new Paragraph(space, ges, type);
        cellRow1 = new PdfPCell(p1);
        cellRow1.setColspan(2);
        formatCellBorder(cellRow1, 20);
        cellRow1.setBorderWidthLeft(1);
        cellRow1.setBorderWidthRight(1);
        table.addCell(cellRow1);
        p1 = new Paragraph(space, "(  ) Confirmacin Diagnstica", type);
        p2 = new Paragraph(space, "(  ) Paciente en Tratamiento", type);
        cellRow1 = new PdfPCell(p1);
        cellRow2 = new PdfPCell(p2);
        formatCellBorder(cellRow1, 20);
        formatCellBorder(cellRow2, 20);
        cellRow1.setBorderWidthLeft(1);
        cellRow2.setBorderWidthRight(1);
        cellRow1.setBorderWidthBottom(1);
        cellRow2.setBorderWidthBottom(1);
        table.addCell(cellRow1);
        table.addCell(cellRow2);
        document.add(table);
        //row 5
        document.add(new Paragraph(space, "CONSTANCIA", subTitle));
        Paragraph text1 = new Paragraph(space,
                "Declaro que, con esta fecha y hora, he tomado conocimiento que tengo derecho a acceder a las Garantas Explcitas en Salud, siempre que la atencin sea otorgada en la red de Prestadores que me corresponde segn Fonasa o Isapre, a la que me encuentro adscrito",
                type);
        text1.setAlignment(Element.ALIGN_JUSTIFIED);
        document.add(text1);
        document.add(new Paragraph(space, "IMPORTANTE", subTitle));
        Paragraph text2 = new Paragraph(space,
                "Tenga presente que s no se cumplen las garantas usted puede reclamar ante Fonasa o la Isapre, segn corresponda. Si la respuesta no es satisfactoria, usted puede recurrir en segunda instancia a la Superintendencia de Salud.",
                type);
        text2.setAlignment(Element.ALIGN_JUSTIFIED);
        document.add(text2);
        document.add(new Paragraph(space, "FECHA Y HORA DE NOTIFICACIN: " + "-", subTitle));
        document.add(new Paragraph(space, "\n", type));
        document.add(new Paragraph(space, "\n", type));
        document.add(new Paragraph(space, "\n", type));
        //row 6
        table = new PdfPTable(2);
        table.setWidthPercentage(100);
        p1 = new Paragraph(space, "INFORM DIAGNSTICO GES", subTitle);
        p2 = new Paragraph(space, "TOM CONOCIMIENTO", subTitle);
        cellRow1 = new PdfPCell(p1);
        cellRow2 = new PdfPCell(p2);
        formatCellBorder(cellRow1, 20);
        formatCellBorder(cellRow2, 20);
        table.addCell(cellRow1);
        table.addCell(cellRow2);
        p1 = new Paragraph(space, "(Firma de persona que notifica)", subTitle2);
        p2 = new Paragraph(space, "(Firma o huella digital  representante)", subTitle2);
        cellRow1 = new PdfPCell(p1);
        cellRow2 = new PdfPCell(p2);
        formatCellBorder(cellRow1, 20);
        formatCellBorder(cellRow2, 20);
        table.addCell(cellRow1);
        table.addCell(cellRow2);
        document.add(table);
        //row 7
        document.add(new Paragraph(space,
                "En caso que la persona que tom conocimiento no sea el paciente, identificar.", type));

        //row 8
        table = new PdfPTable(2);
        table.setWidthPercentage(100);
        p1 = new Paragraph(space, "Nombre:", type);
        p2 = new Paragraph(space, "R.U.T:", type);
        cellRow1 = new PdfPCell(p1);
        cellRow2 = new PdfPCell(p2);
        formatCellBorder(cellRow1, 20);
        formatCellBorder(cellRow2, 20);
        table.addCell(cellRow1);
        table.addCell(cellRow2);
        p1 = new Paragraph(space, "N Telfono Celular:", type);
        p2 = new Paragraph(space, "Direccin correo electrnico (e-mail):", type);
        cellRow1 = new PdfPCell(p1);
        cellRow2 = new PdfPCell(p2);
        formatCellBorder(cellRow1, 20);
        formatCellBorder(cellRow2, 20);
        table.addCell(cellRow1);
        table.addCell(cellRow2);
        document.add(table);

        document.close();
    } catch (DocumentException de) {
        throw new IOException(de.getMessage());
    }

}