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

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

Introduction

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

Prototype

public void setPaddingRight(float paddingRight) 

Source Link

Document

Setter for property paddingRight.

Usage

From source file:Controller.PrintOrderManagedBean.java

public void executePDF(String maDH) {
    try {/*  w w  w.  j  a  va 2  s.c o  m*/

        DonHang donhang = new DonHang();
        donhang.init(maDH);
        float CONVERT = 28.346457f;// 1 cm
        FacesContext faces = FacesContext.getCurrentInstance();
        HttpServletResponse response = (HttpServletResponse) faces.getExternalContext().getResponse();
        // setting some response headers
        response.setHeader("Expires", "0");
        response.setHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0");
        //response.setHeader("Content-disposition","inline; filename=kiran.pdf");
        response.setHeader("Pragma", "public");
        response.setContentType("application/pdf");
        //response.setHeader("Content-Disposition", "attachment;filename=\"ContactList.pdf\"");
        response.addHeader("Content-disposition", "attachment;filename=\"DataListBean.pdf\"");
        //step 1: creation of a document-object
        Document document = new Document(PageSize.A4, 0.5f * CONVERT, 0.5f * CONVERT, 1.0f * CONVERT,
                1.0f * CONVERT);
        //step 2: we create a writer that listens to the document
        // and directs a PDF-stream to a temporary buffer
        ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
        PdfWriter writer = PdfWriter.getInstance(document, baos);
        BaseFont bf = BaseFont.createFont("c:\\windows\\fonts\\arial.ttf", BaseFont.IDENTITY_H,
                BaseFont.EMBEDDED);
        Font font = new Font(bf, 18, Font.BOLD);
        Font font11 = new Font(bf, 11, Font.NORMAL);
        Font font11_bo = new Font(bf, 11, Font.BOLD);
        Font font12 = new Font(bf, 12, Font.NORMAL);
        Font font10 = new Font(bf, 10, Font.NORMAL);
        Font font9 = new Font(bf, 9, Font.NORMAL);
        //step 3: we open the document
        document.open();

        PdfPTable tab_Header1;
        tab_Header1 = new PdfPTable(1);
        tab_Header1.setWidthPercentage(100);

        tab_Header1.setHorizontalAlignment(Element.ALIGN_CENTER);

        PdfPCell cell1;
        cell1 = new PdfPCell(new Phrase("CNG TY TNHH ABC FASHION", font11));
        cell1.setHorizontalAlignment(Element.ALIGN_LEFT);
        cell1.setPaddingBottom(5.0f);
        cell1.setBorder(0);
        tab_Header1.addCell(cell1);

        cell1 = new PdfPCell(
                new Phrase("?a ch: 146 Linh Trung,P. Linh Trung, Q. Th ?c, TP HCM", font11));
        cell1.setHorizontalAlignment(Element.ALIGN_LEFT);
        cell1.setPaddingBottom(5.0f);
        cell1.setBorder(0);
        tab_Header1.addCell(cell1);

        cell1 = new PdfPCell(new Phrase("S?T: 0909465621", font11));
        cell1.setHorizontalAlignment(Element.ALIGN_LEFT);
        cell1.setPaddingBottom(5.0f);
        cell1.setBorder(0);
        tab_Header1.addCell(cell1);

        cell1 = new PdfPCell(new Phrase("", font11));
        cell1.setHorizontalAlignment(Element.ALIGN_LEFT);
        cell1.setPaddingBottom(5.0f);
        cell1.setBorder(0);
        tab_Header1.addCell(cell1);

        cell1 = new PdfPCell(new Phrase("?N GIAO HNG", font12));
        cell1.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell1.setPaddingBottom(5.0f);
        cell1.setBorder(0);
        tab_Header1.addCell(cell1);

        cell1 = new PdfPCell(new Phrase("Bn Bn:", font11_bo));
        cell1.setHorizontalAlignment(Element.ALIGN_LEFT);
        cell1.setPaddingBottom(5.0f);
        cell1.setBorder(0);
        tab_Header1.addCell(cell1);

        cell1 = new PdfPCell(new Phrase("Tn: CNG TY TNHH ABC FASHION", font11));
        cell1.setHorizontalAlignment(Element.ALIGN_LEFT);
        cell1.setPaddingBottom(5.0f);
        cell1.setBorder(0);
        tab_Header1.addCell(cell1);

        cell1 = new PdfPCell(
                new Phrase("?a ch: 146 Linh Trung,P. Linh Trung, Q. Th ?c, TP HCM", font11));
        cell1.setHorizontalAlignment(Element.ALIGN_LEFT);
        cell1.setPaddingBottom(5.0f);
        cell1.setBorder(0);
        tab_Header1.addCell(cell1);

        cell1 = new PdfPCell(new Phrase("S in thoi: 0909465621", font11));
        cell1.setHorizontalAlignment(Element.ALIGN_LEFT);
        cell1.setPaddingBottom(5.0f);
        cell1.setBorder(0);
        tab_Header1.addCell(cell1);

        cell1 = new PdfPCell(new Phrase("Bn Mua:", font11_bo));
        cell1.setHorizontalAlignment(Element.ALIGN_LEFT);
        cell1.setPaddingBottom(5.0f);
        cell1.setBorder(0);
        tab_Header1.addCell(cell1);

        cell1 = new PdfPCell(new Phrase("Tn: " + donhang.getTenKH(), font11));
        cell1.setHorizontalAlignment(Element.ALIGN_LEFT);
        cell1.setPaddingBottom(5.0f);
        cell1.setBorder(0);
        tab_Header1.addCell(cell1);

        cell1 = new PdfPCell(new Phrase("?a ch: " + donhang.getDiaChiKH(), font11));
        cell1.setHorizontalAlignment(Element.ALIGN_LEFT);
        cell1.setPaddingBottom(5.0f);
        cell1.setBorder(0);
        tab_Header1.addCell(cell1);

        cell1 = new PdfPCell(new Phrase("S in thoi: " + donhang.getSoDTKH(), font11));
        cell1.setHorizontalAlignment(Element.ALIGN_LEFT);
        cell1.setPaddingBottom(5.0f);
        cell1.setBorder(0);
        tab_Header1.addCell(cell1);

        cell1 = new PdfPCell(new Phrase("Bn Vn chuyn:", font11_bo));
        cell1.setHorizontalAlignment(Element.ALIGN_LEFT);
        cell1.setPaddingBottom(5.0f);
        cell1.setBorder(0);
        tab_Header1.addCell(cell1);

        cell1 = new PdfPCell(new Phrase("Tn:....................................", font11));
        cell1.setHorizontalAlignment(Element.ALIGN_LEFT);
        cell1.setPaddingBottom(5.0f);
        cell1.setBorder(0);
        tab_Header1.addCell(cell1);

        cell1 = new PdfPCell(new Phrase("?a ch:...............................", font11));
        cell1.setHorizontalAlignment(Element.ALIGN_LEFT);
        cell1.setPaddingBottom(5.0f);
        cell1.setBorder(0);
        tab_Header1.addCell(cell1);

        cell1 = new PdfPCell(new Phrase("S in thoi:...............................", font11));
        cell1.setHorizontalAlignment(Element.ALIGN_LEFT);
        cell1.setPaddingBottom(5.0f);
        cell1.setBorder(0);
        tab_Header1.addCell(cell1);

        cell1 = new PdfPCell(new Phrase("Danh sch hng ha:", font11));
        cell1.setHorizontalAlignment(Element.ALIGN_LEFT);
        cell1.setPaddingBottom(5.0f);
        cell1.setBorder(0);
        tab_Header1.addCell(cell1);
        ///////////////////////////////bn sn phm
        float[] crDonHang = { 1.0f * CONVERT, 4.0f * CONVERT, 1.0f * CONVERT, 2.0f * CONVERT, 2.0f * CONVERT };

        PdfPTable tab_Header2;
        tab_Header2 = new PdfPTable(crDonHang.length);
        tab_Header2.setWidthPercentage(100);
        tab_Header2.setWidths(crDonHang);
        tab_Header2.setHorizontalAlignment(Element.ALIGN_CENTER);
        NumberFormat formatter = new DecimalFormat("#,###,###");

        String[] crheader = { "STT", "Tn Hng", "S Lng", "Gi Bn(VN?)", "Thnh Ti?n(VN?)" };

        for (int i = 0; i < crheader.length; i++) {
            PdfPCell cell = new PdfPCell(new Phrase(crheader[i], font11));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);

            tab_Header2.addCell(cell);
        }
        int stt = 1;
        for (SanPhamDH sp : donhang.getListSP()) {

            PdfPCell cell = new PdfPCell(new Phrase(String.valueOf(stt), font11));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);

            tab_Header2.addCell(cell);

            cell = new PdfPCell(new Phrase(sp.getTenSP(), font11));
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);

            tab_Header2.addCell(cell);

            cell = new PdfPCell(new Phrase(sp.getSoluong(), font11));
            cell.setHorizontalAlignment(Element.ALIGN_RIGHT);

            tab_Header2.addCell(cell);

            cell = new PdfPCell(new Phrase(formatter.format(Double.parseDouble(sp.getGiaSP())), font11));
            cell.setHorizontalAlignment(Element.ALIGN_RIGHT);

            tab_Header2.addCell(cell);

            cell = new PdfPCell(new Phrase(formatter.format(Double.parseDouble(sp.getThanhTien())), font11));
            cell.setHorizontalAlignment(Element.ALIGN_RIGHT);

            tab_Header2.addCell(cell);

            stt++;
        }
        cell1 = new PdfPCell(tab_Header2);
        cell1.setHorizontalAlignment(Element.ALIGN_CENTER);
        tab_Header1.addCell(cell1);

        cell1 = new PdfPCell(new Phrase("Tng ti?n hng:   "
                + formatter.format(
                        Double.parseDouble(donhang.getTienTamTinh() == null ? "0" : donhang.getTienTamTinh()))
                + " VN?", font11));
        cell1.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cell1.setPaddingBottom(5.0f);
        cell1.setBorder(0);
        tab_Header1.addCell(cell1);

        cell1 = new PdfPCell(new Phrase("Tng ti?n vn chuyn:   "
                + formatter.format(Double
                        .parseDouble(donhang.getTienVanChuyen() == null ? "0" : donhang.getTienVanChuyen()))
                + " VN?", font11));
        cell1.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cell1.setPaddingBottom(5.0f);
        cell1.setBorder(0);
        tab_Header1.addCell(cell1);

        cell1 = new PdfPCell(new Phrase("Tng ti?n thanh ton:   "
                + formatter.format(Double.parseDouble(donhang.getTongTien())) + " VN?", font11));
        cell1.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cell1.setPaddingBottom(5.0f);
        cell1.setBorder(0);
        tab_Header1.addCell(cell1);

        cell1 = new PdfPCell(new Phrase("S ti?n thanh ton bng ch: "
                + DocTien.doctien(donhang.getTongTien().replaceAll(" ", "")) + "ng", font11));
        cell1.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell1.setPaddingBottom(5.0f);
        cell1.setBorder(0);
        tab_Header1.addCell(cell1);

        cell1 = new PdfPCell(new Phrase(" ", font11));
        cell1.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell1.setPaddingBottom(5.0f);
        cell1.setBorder(0);
        tab_Header1.addCell(cell1);

        cell1 = new PdfPCell(new Phrase("TP H Ch Minh, ngy      thng       nm       ", font11));
        cell1.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cell1.setPaddingRight(1.0f * CONVERT);
        cell1.setBorder(0);
        tab_Header1.addCell(cell1);

        cell1 = new PdfPCell(new Phrase(" ", font11));
        cell1.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell1.setPaddingBottom(5.0f);
        cell1.setBorder(0);
        tab_Header1.addCell(cell1);

        PdfPTable tab_Header3;
        tab_Header3 = new PdfPTable(3);
        tab_Header3.setWidthPercentage(100);

        tab_Header3.setHorizontalAlignment(Element.ALIGN_CENTER);

        cell1 = new PdfPCell(new Phrase("Ng?i nhn hng", font11));
        cell1.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell1.setPaddingBottom(5.0f);
        cell1.setBorder(0);
        tab_Header3.addCell(cell1);

        cell1 = new PdfPCell(new Phrase("Ng?i giao hng", font11));
        cell1.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell1.setPaddingBottom(5.0f);
        cell1.setBorder(0);
        tab_Header3.addCell(cell1);

        cell1 = new PdfPCell(new Phrase("Ng?i bn hng", font11));
        cell1.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell1.setPaddingBottom(5.0f);
        cell1.setBorder(0);
        tab_Header3.addCell(cell1);

        cell1 = new PdfPCell(new Phrase("(k v ghi r h? tn)", font11));
        cell1.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell1.setPaddingBottom(5.0f);
        cell1.setBorder(0);
        tab_Header3.addCell(cell1);

        cell1 = new PdfPCell(new Phrase("(k v ghi r h? tn)", font11));
        cell1.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell1.setPaddingBottom(5.0f);
        cell1.setBorder(0);
        tab_Header3.addCell(cell1);

        cell1 = new PdfPCell(new Phrase("(k v ghi r h? tn)", font11));
        cell1.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell1.setPaddingBottom(5.0f);
        cell1.setBorder(0);
        tab_Header3.addCell(cell1);

        cell1 = new PdfPCell(tab_Header3);
        cell1.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell1.setBorder(0);
        tab_Header1.addCell(cell1);

        document.add(tab_Header1);

        document.close();
        //step 6: we output the writer as bytes to the response output
        // the contentlength is needed for MSIE!!!
        response.setContentLength(baos.size());
        // write ByteArrayOutputStream to the ServletOutputStream
        ServletOutputStream out = response.getOutputStream();
        baos.writeTo(out);
        baos.flush();
        faces.responseComplete();

    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:edu.cornell.mannlib.vitro.webapp.visualization.visutils.PDFDocument.java

License:Open Source License

private void setTableFooterStyle(BaseColor footerBackgroundColor, PdfPCell cell) {
    cell.setBorderWidth(0.0f);//from w w  w .j  ava2 s. c o  m
    cell.setBackgroundColor(footerBackgroundColor);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setPaddingTop(5f);
    cell.setPaddingRight(10f);
    cell.setPaddingBottom(5f);
    cell.setPaddingLeft(10f);
}

From source file:edu.cornell.mannlib.vitro.webapp.visualization.visutils.PDFDocument.java

License:Open Source License

private void setTableBodyStyle(BaseColor bodyBackgroundColor, PdfPCell cell) {
    cell.setBorderWidth(0.0f);//from ww  w . ja v  a2  s . com
    cell.setBackgroundColor(bodyBackgroundColor);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setPaddingTop(5f);
    cell.setPaddingRight(10f);
    cell.setPaddingBottom(5f);
    cell.setPaddingLeft(10f);
}

From source file:edu.cornell.mannlib.vitro.webapp.visualization.visutils.PDFDocument.java

License:Open Source License

private void setTableHeaderStyle(BaseColor headerBackgroundColor, PdfPCell cell) {
    cell.setBorderWidth(0.0f);// ww  w .j a  va 2 s  .  co m
    cell.setBackgroundColor(headerBackgroundColor);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setPaddingTop(5f);
    cell.setPaddingRight(10f);
    cell.setPaddingBottom(5f);
    cell.setPaddingLeft(10f);
}

From source file:edu.cornell.mannlib.vitro.webapp.visualization.visutils.PDFDocument.java

License:Open Source License

private void setTableCaptionStyle(BaseColor summaryBackgroundColor, PdfPCell cell) {
    cell.setBorderWidth(0.0f);//from w  w  w .  j a v a 2 s. co m
    cell.setBackgroundColor(summaryBackgroundColor);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setPaddingTop(5.0f);
    cell.setPaddingRight(10.0f);
    cell.setPaddingBottom(5.0f);
    cell.setPaddingLeft(10.0f);
    cell.setColspan(2);
}

From source file:Export.ExporOnlyViagemPdf.java

private void setStyleRodape(PdfPCell cellRodape) {
    cellRodape.setBorderWidthBottom(0.5f);
    cellRodape.setPadding(2f);/*from w  w  w . ja  va 2s  .c o  m*/
    cellRodape.setPaddingLeft(0.8f);
    cellRodape.setPaddingRight(0.8f);
}

From source file:Export.FuncPagamento.java

private String folhaPagamento(String numPagamento, String user, String nomeUser, int j)
        throws NumberFormatException {
    try {/*from  w  w w  . j  av  a  2s .  c om*/

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

        Font fontCabecalhoN = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED,
                9.5f);
        Font fontCorpo = FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 9f);
        Font fontCorpoP = FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 8f);
        Font fontCorpoN = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 9f);
        Font fontCorpoNU = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 9f,
                Font.UNDERLINE);
        Font fontCorpoNG = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED,
                11.5f);
        Font fontCorpoNGT = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED,
                13f, Font.UNDERLINE);
        Font fontCabecalhoNG = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED,
                16f, Font.UNDERLINE);

        ArrayList<HashMap<String, Object>> mapList = getObj(numPagamento);

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

        String Ddata = sdf1.format(new Date());

        int size = mapList.size(), i = 0;

        File ff = new File(ConfigDoc.Fontes.getDiretorio() + "/" + user + "/Pagamentos/");

        ff.mkdirs();
        ff = new File(ff.getAbsoluteFile() + "/" + "Pagamentos Func " + Ddata + ".pdf");

        OutputStream outputStraem = new FileOutputStream(ff);
        PdfWriter writer = PdfWriter.getInstance(documento, outputStraem);

        MyFooter event = new MyFooter();
        writer.setPageEvent(event);

        documento.open();

        for (HashMap<String, Object> hashMap : mapList) {
            i++;

            PdfPTable pTableEmpresaPricipal = new PdfPTable(new float[] { 25f, 75f });
            pTableEmpresaPricipal.setWidthPercentage(90);
            PdfPTable pTableEmpresaInforImpres1 = new PdfPTable(1);
            PdfPTable pTableEmpresaInforImpres5 = new PdfPTable(1);

            PdfPTable pTableNull = new PdfPTable(1);
            PdfPCell cellNull = new PdfPCell(new Phrase(" ", fontCorpoP));
            cellNull.setBorder(0);
            pTableNull.addCell(cellNull);

            PdfPCell pCellNomeEmpresa = new PdfPCell(new Phrase(ConfigDoc.Empresa.NOME, fontCabecalhoNG));
            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);

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

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

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

            pTableEmpresaInforImpres5.addCell(cellTabela3);

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

            PdfPCell cellTabela6 = new PdfPCell(imageEmpresa);
            cellTabela6.setBorder(0);

            pTableEmpresaPricipal.addCell(cellTabela6);
            pTableEmpresaPricipal.addCell(cellTabela5);

            documento.add(pTableEmpresaPricipal);

            documento.add(pTableNull);
            documento.add(pTableNull);

            PdfPTable pTableTitulo = new PdfPTable(new float[] { 50, 50 });
            pTableTitulo.setWidthPercentage(90f);
            PdfPCell cellTitulo = new PdfPCell(new Phrase("Comprovativo de Pagamento", fontCorpoNGT));
            cellTitulo.setBorder(0);
            cellTitulo.setHorizontalAlignment(Element.ALIGN_RIGHT);
            cellTitulo.setPaddingRight(-80f);
            cellTitulo.setPaddingTop(-26f);
            pTableTitulo.addCell(cellTitulo);
            cellTitulo = new PdfPCell(new Phrase("N: " + hashMap.get(PAGAMENTO), fontCorpoNGT));
            cellTitulo.setHorizontalAlignment(Element.ALIGN_RIGHT);
            cellTitulo.setBorder(0);
            cellTitulo.setPaddingBottom(5f);
            pTableTitulo.addCell(cellTitulo);

            documento.add(pTableTitulo);

            PdfPTable pTableAno = new PdfPTable(new float[] { 100 });
            pTableAno.setWidthPercentage(90f);
            PdfPCell cellAno = new PdfPCell(new Phrase(toData(hashMap.get(REGISTRO), j), fontCorpoNGT));
            cellAno.setBorder(0);
            cellAno.setPaddingBottom(20f);
            pTableAno.addCell(cellAno);

            documento.add(pTableAno);

            PdfPTable pTableDetalhesPagamento = new PdfPTable(new float[] { 100 });
            pTableDetalhesPagamento.setWidthPercentage(90f);
            PdfPCell cellDetalhesPagamento = new PdfPCell();

            Paragraph pDetalhesPagamento = new Paragraph();
            pDetalhesPagamento.add(new Paragraph("\nDetalhes de Pagamento ", fontCorpoNG));

            pDetalhesPagamento.add(new Phrase("Beneficirio: ", fontCorpoN));
            pDetalhesPagamento.add(new Phrase(toString(hashMap.get(BENEFICIARIO)) + "\n", fontCorpo));
            pDetalhesPagamento.add(new Phrase("Descrio do pagamento: ", fontCorpoN));
            pDetalhesPagamento.add(new Phrase(toString(hashMap.get(DESCRICAOPAGAMENTO)), fontCorpo));
            pDetalhesPagamento.add(new Paragraph("CONFORME APROVADO\n\n", fontCorpoN));

            pDetalhesPagamento.add(new Paragraph("Valor Pagamento", fontCorpoNG));
            pDetalhesPagamento.add(new Phrase("Valor Numerico: ", fontCorpoN));
            pDetalhesPagamento.add(new Phrase(
                    toMoeda(hashMap.get(VALORPAGAMENTO), toString(hashMap.get(SIGLA))) + "\n", fontCorpo));
            System.err.println(toString(hashMap.get(RETENCAOFONTE)) + " hfhfh retensao");
            if (toString(hashMap.get(RETENCAOFONTE)).trim().equals("1")) {
                double ret = getValorImportRetensao();
                pDetalhesPagamento.add(new Phrase("Valor Retensao Fonte: ", fontCorpoN));
                pDetalhesPagamento.add(new Phrase(toMoeda(ret, "%") + "\n", fontCorpo));
                pDetalhesPagamento.add(new Phrase("Valor Retido: ", fontCorpoN));
                double valret = toDouble(hashMap.get(VALORPAGAMENTO)) * ret;
                pDetalhesPagamento
                        .add(new Phrase(toMoeda(valret, toString(hashMap.get(SIGLA))) + "\n", fontCorpo));
            }

            JTextPane jtp = new JTextPane();
            Double valor = Double.valueOf((hashMap.get(VALORPAGAMENTO) + ""));
            Moeda.EscreverEstenso(valor, jtp, toString(hashMap.get(MOEDA)));

            pDetalhesPagamento.add(new Phrase("Valor por Extenso: ", fontCorpoN));
            pDetalhesPagamento.add(new Phrase(jtp.getText().trim() + " \n\n", fontCorpo));

            pDetalhesPagamento.add(new Paragraph("Descrio da Conta", fontCorpoNG));
            pDetalhesPagamento.add(new Phrase("Cod Conta: ", fontCorpoN));
            pDetalhesPagamento.add(new Phrase(hashMap.get(CODIGOCONTAPAGAMENTO) + "\n", fontCorpo));
            pDetalhesPagamento.add(new Phrase("Titulo da Conta: ", fontCorpoN));
            pDetalhesPagamento.add(new Phrase(hashMap.get(TITULOCONTAPAGAMENTO) + "\n", fontCorpo));

            /**
             * For alter
             */
            pDetalhesPagamento.add(new Phrase("Forma de Pagamento: ", fontCorpoN));
            pDetalhesPagamento.add(new Phrase(hashMap.get(FORMAPAGAMENTO) + " \n", fontCorpo));
            pDetalhesPagamento.add(new Phrase("Documento de Pagamento: ", fontCorpoN));
            pDetalhesPagamento.add(new Phrase(toString(hashMap.get(DESCRICAOCONTABANCO)) + " - "
                    + toString(hashMap.get(DOCFORMAPAGAMENTO)) + "\n\n", fontCorpo));
            pDetalhesPagamento.add(new Paragraph(" ", fontCorpoN));

            cellDetalhesPagamento.addElement(pDetalhesPagamento);
            pTableDetalhesPagamento.addCell(cellDetalhesPagamento);

            cellDetalhesPagamento = new PdfPCell();
            pDetalhesPagamento = new Paragraph();

            pDetalhesPagamento.add(new Paragraph(" ", fontCorpo));
            pDetalhesPagamento.add(new Phrase("Preparado por: ", fontCorpoN));
            pDetalhesPagamento.add(new Phrase(nomeUser + " ", fontCorpoP));
            pDetalhesPagamento.add(new Phrase("            Examinado por", fontCorpoN));
            pDetalhesPagamento.add(new Phrase("____________________\n", fontCorpo));

            pDetalhesPagamento.add(new Paragraph(" ", fontCorpoN));
            pDetalhesPagamento.add(new Paragraph("Pagamento Autorizado por:", fontCorpoNG));

            pDetalhesPagamento.add(new Paragraph(" ", fontCorpoN));
            pDetalhesPagamento.add(new Phrase("Assinatura: ", fontCorpoN));
            pDetalhesPagamento.add(new Phrase(" ____________________________________________", fontCorpo));
            pDetalhesPagamento.add(new Phrase("    Data ", fontCorpoN));
            pDetalhesPagamento.add(new Phrase(" ______________________\n\n", fontCorpo));

            pDetalhesPagamento.add(new Phrase("Assinatura: ", fontCorpoN));
            pDetalhesPagamento.add(new Phrase(" ____________________________________________", fontCorpo));
            pDetalhesPagamento.add(new Phrase("    Data ", fontCorpoN));
            pDetalhesPagamento.add(new Phrase(" ______________________\n", fontCorpo));

            pDetalhesPagamento.add(new Paragraph(" ", fontCorpo));
            pDetalhesPagamento.add(new Paragraph(
                    "............................................................................."
                            + "...........................................................................",
                    fontCorpoN));

            pDetalhesPagamento.add(new Paragraph(" ", fontCorpo));
            Paragraph pReceip = new Paragraph("RECIBO", fontCorpoN);
            pReceip.setAlignment(Element.ALIGN_CENTER);
            pDetalhesPagamento.add(pReceip);

            pDetalhesPagamento.add(new Paragraph(" ", fontCorpo));
            pDetalhesPagamento.add(new Phrase("Recebi o valor de: ", fontCorpo));
            pDetalhesPagamento.add(new Phrase(jtp.getText() + " \n", fontCorpoNU));

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

            PdfPTable pTableNumCheque = new PdfPTable(
                    new float[] { 33.3333333333f, 33.3333333333f, 33.3333333333f });
            pTableNumCheque.setWidthPercentage(90f);
            pTableNumCheque.setWidthPercentage(100f);

            PdfPCell cellNumCheque = new PdfPCell(new Phrase("_______________________", fontCorpo));
            cellNumCheque.setBorder(0);
            cellNumCheque.setHorizontalAlignment(Element.ALIGN_CENTER);
            pTableNumCheque.addCell(cellNumCheque);
            cellNumCheque = new PdfPCell(new Phrase("_______________________", fontCorpo));
            cellNumCheque.setBorder(0);
            cellNumCheque.setHorizontalAlignment(Element.ALIGN_CENTER);
            pTableNumCheque.addCell(cellNumCheque);
            cellNumCheque = new PdfPCell(new Phrase("_______________________", fontCorpo));
            cellNumCheque.setBorder(0);
            cellNumCheque.setHorizontalAlignment(Element.ALIGN_CENTER);
            pTableNumCheque.addCell(cellNumCheque);

            cellNumCheque = new PdfPCell(new Phrase("Cheque No.", fontCorpoN));
            cellNumCheque.setBorder(0);
            cellNumCheque.setHorizontalAlignment(Element.ALIGN_CENTER);
            pTableNumCheque.addCell(cellNumCheque);
            cellNumCheque = new PdfPCell(new Phrase("Data", fontCorpoN));
            cellNumCheque.setBorder(0);
            cellNumCheque.setHorizontalAlignment(Element.ALIGN_CENTER);
            pTableNumCheque.addCell(cellNumCheque);
            cellNumCheque = new PdfPCell(new Phrase("Receiver Name & Signature", fontCorpoN));
            cellNumCheque.setBorder(0);
            cellNumCheque.setHorizontalAlignment(Element.ALIGN_CENTER);
            pTableNumCheque.addCell(cellNumCheque);

            pDetalhesPagamento.add(pTableNumCheque);

            pDetalhesPagamento.add(new Phrase(
                    "\nNOTA: Um recibo oficial pode ser obtido por um pagamento e informado na parte inversa deste comprovativo. \n\n",
                    fontCorpo));

            cellDetalhesPagamento.addElement(pDetalhesPagamento);

            pTableDetalhesPagamento.addCell(cellDetalhesPagamento);

            documento.add(pTableDetalhesPagamento);

            if (i != size) {
                documento.newPage();
            }
        }

        documento.close();

        reString = "../Documentos/" + user + "/Pagamentos/" + "Pagamentos Func " + Ddata + ".pdf";
        return reString;
    } catch (BadElementException | IOException ex) {
        Logger.getLogger(FuncPagamento.class.getName()).log(Level.SEVERE, null, ex);
    } catch (DocumentException ex) {
        Logger.getLogger(FuncPagamento.class.getName()).log(Level.SEVERE, null, ex);
    }
    return reString;
}

From source file:Export.FuncPagamento.java

private String pequenoPagamento(String numPagamento, String user, String nomeUser, int i) {
    OutputStream outputStraem;//from   ww w .ja v  a2 s  .c  om
    try {
        SimpleDateFormat sdf = new SimpleDateFormat("MMMM yyyy - dd", new Locale("pt", "BR"));
        SimpleDateFormat sdf3 = new SimpleDateFormat("dd-MM-yyyy");
        SimpleDateFormat sdf2 = new SimpleDateFormat("dd 'de' MMMM 'de' yyyy", new Locale("pt", "BR"));
        SimpleDateFormat sdf1 = new SimpleDateFormat("dd-MM-yyyy hh'.'mm'.'ss");

        Font fontCabecalhoN = FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED,
                14f);
        Font fontCorpo = FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 8.5f);
        Font fontCorpoU = FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 9f,
                Font.UNDERLINE);
        //            Font fontCorpoP= FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED ,8f );
        Font fontCorpoN = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 9f);
        Font fontCorpoNG = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED,
                8.5f);
        //            Font fontCorpoNGT= FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED , 13f ,Font.UNDERLINE);
        Font fontCabecalhoNG = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED,
                16f, Font.UNDERLINE);

        Document documento = new Document();
        documento.setPageSize(PageSize.A4);
        documento.setMargins(20f, 20f, 10f, 5f);
        String Ddata = sdf1.format(new Date());

        ArrayList<HashMap<String, Object>> mapList = getObj(numPagamento);
        int total = mapList.size();

        File ff = new File(ConfigDoc.Fontes.getDiretorio() + "/" + user + "/Pagamentos/");
        ff.mkdirs();
        ff = new File(ff.getAbsoluteFile() + "/" + "Pagamentos Func " + Ddata + ".pdf");

        outputStraem = new FileOutputStream(ff);
        PdfWriter writer = PdfWriter.getInstance(documento, outputStraem);
        MyFooterA5 event = new MyFooterA5();
        writer.setPageEvent(event);

        documento.open();

        PdfPTable pTableTitile = new PdfPTable(new float[] { 100 });
        pTableTitile.setWidthPercentage(95f);
        PdfPCell cellTitile = new PdfPCell();
        cellTitile.setBorder(0);

        Paragraph pTitile = new Paragraph();

        pTitile.add(new Phrase(ConfigDoc.Empresa.NOME.toUpperCase(), fontCabecalhoNG));
        pTitile.setAlignment(Element.ALIGN_CENTER);

        PdfPTable pTableSubTitile = new PdfPTable(new float[] { 80, 20 });
        pTableSubTitile.setWidthPercentage(101f);

        PdfPCell cellSubTitile = new PdfPCell(
                new Phrase("Petty cash voucher no.".toUpperCase(), fontCabecalhoN));
        cellSubTitile.setBorder(0);
        cellSubTitile.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cellSubTitile.setPaddingBottom(20);
        cellSubTitile.setPaddingRight(67);
        cellSubTitile.setPaddingTop(10);
        pTableSubTitile.addCell(cellSubTitile);

        cellSubTitile = new PdfPCell(
                new Phrase(toData((mapList.size() > 0) ? mapList.get(0).get(REGISTRO) : " ", i).toUpperCase(),
                        fontCabecalhoN));
        cellSubTitile.setHorizontalAlignment(Element.ALIGN_LEFT);
        cellSubTitile.setBorder(0);
        cellSubTitile.setPaddingBottom(20);
        cellSubTitile.setPaddingTop(10);
        pTableSubTitile.addCell(cellSubTitile);
        //            pTitile.add(cellSubTitile);

        pTitile.add(pTableSubTitile);

        cellTitile.addElement(pTitile);
        pTableTitile.addCell(cellTitile);

        documento.add(pTableTitile);

        PdfPTable pTableDados = new PdfPTable(new float[] { 5.6f, 6.05f, 53.5f, 17.95f, 19f });
        pTableDados.setWidthPercentage(95f);

        PdfPCell cellDados = new PdfPCell(new Phrase("S/N", fontCorpoNG));
        cellDados.setHorizontalAlignment(Element.ALIGN_CENTER);
        pTableDados.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("Qty", fontCorpoNG));
        cellDados.setHorizontalAlignment(Element.ALIGN_CENTER);
        pTableDados.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("Detail Description", fontCorpoNG));
        cellDados.setHorizontalAlignment(Element.ALIGN_CENTER);
        pTableDados.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("Unit price", fontCorpoNG));
        cellDados.setHorizontalAlignment(Element.ALIGN_CENTER);
        pTableDados.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("AMT (STD)", fontCorpoNG));
        cellDados.setHorizontalAlignment(Element.ALIGN_CENTER);
        pTableDados.addCell(cellDados);

        Double toPa = 0.0;
        for (int j = 0; j < total; j++) {
            int tLinha = toString(mapList.get(j).get(DESCRICAOPAGAMENTO)).split("\n").length;

            float pad = setPadding(total, tLinha);

            cellDados = new PdfPCell(new Phrase((j + 1) + "", fontCorpo));
            cellDados.setPaddingBottom(pad);
            cellDados.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cellDados.setPaddingTop(pad);
            pTableDados.addCell(cellDados);

            cellDados = new PdfPCell(new Phrase(toInt(mapList.get(j).get(QUANTIDADE)) + "", fontCorpo));
            cellDados.setPaddingBottom(pad);
            cellDados.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cellDados.setPaddingTop(pad);
            pTableDados.addCell(cellDados);

            cellDados = new PdfPCell(new Phrase(toString(mapList.get(j).get(DESCRICAOPAGAMENTO)), fontCorpo));
            cellDados.setPaddingBottom(pad);
            cellDados.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cellDados.setPaddingTop(pad);
            pTableDados.addCell(cellDados);

            cellDados = new PdfPCell(new Phrase(toMoeda(
                    (toDouble(mapList.get(j).get(VALORPAGAMENTO))
                            / (float) toInt(mapList.get(j).get(QUANTIDADE))),
                    toString(mapList.get(j).get(SIGLA))), fontCorpo));
            cellDados.setPaddingBottom(pad);
            cellDados.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cellDados.setPaddingTop(pad);
            pTableDados.addCell(cellDados);

            cellDados = new PdfPCell(new Phrase(
                    toMoeda(toDouble(mapList.get(j).get(VALORPAGAMENTO)), toString(mapList.get(j).get(SIGLA))),
                    fontCorpo));
            cellDados.setPaddingBottom(pad);
            cellDados.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cellDados.setPaddingTop(pad);
            pTableDados.addCell(cellDados);

            toPa += toDouble(mapList.get(j).get(VALORPAGAMENTO));
        }
        //            5.6f,5.6f,53.5f,17.95f,19.45f
        PdfPTable pTableRodape = new PdfPTable(new float[] { 5.6f, 6.05f, 19.795f, 33.705f, 17.95f, 19f });
        pTableRodape.setWidthPercentage(95f);

        cellDados = new PdfPCell(new Phrase(" ", fontCorpoNG));
        pTableRodape.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("CODE", fontCorpoNG));
        pTableRodape.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase(toString(mapList.get(0).get(DOCFORMAPAGAMENTO)), fontCorpoNG));
        pTableRodape.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase(toString(mapList.get(0).get(DESCRICAOCONTABANCO)), fontCorpoNG));
        pTableRodape.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("TOTAL", fontCorpoNG));
        pTableRodape.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase(toMoeda(toPa, toString(mapList.get(0).get(SIGLA))), fontCorpoNG));
        pTableRodape.addCell(cellDados);

        documento.add(pTableDados);
        documento.add(pTableRodape);

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

        pTableAssiEstenso.setWidthPercentage(95f);

        PdfPCell cellAssiEstenso = new PdfPCell();
        Paragraph pAssiEstenso = new Paragraph();

        PdfPTable pTableResposavel = new PdfPTable(new float[] { 70, 30 });
        pTableResposavel.setWidthPercentage(100f);

        PdfPCell cellResposavel = new PdfPCell();
        cellResposavel
                .addElement(new Phrase("Requested by:_________________________________________", fontCorpoN));
        cellResposavel.setPaddingTop(10f);
        cellResposavel.setPaddingBottom(20f);
        cellResposavel.setBorder(0);
        pTableResposavel.addCell(cellResposavel);

        cellResposavel = new PdfPCell();
        cellResposavel.addElement(new Phrase(" HOD:___________________", fontCorpoN));
        cellResposavel.setPaddingTop(10f);
        cellResposavel.setPaddingBottom(20f);
        cellResposavel.setBorder(0);
        pTableResposavel.addCell(cellResposavel);

        cellResposavel = new PdfPCell();
        cellResposavel
                .addElement(new Phrase("Approveds by:_________________________________________", fontCorpoN));
        cellResposavel.setPaddingTop(-5f);
        cellResposavel.setPaddingBottom(20f);
        cellResposavel.setBorder(0);
        pTableResposavel.addCell(cellResposavel);

        cellResposavel = new PdfPCell();
        cellResposavel.addElement(new Phrase(" Date:___________________", fontCorpoN));
        cellResposavel.setPaddingTop(-5f);
        cellResposavel.setPaddingBottom(20f);
        cellResposavel.setBorder(0);
        pTableResposavel.addCell(cellResposavel);

        pAssiEstenso.add(pTableResposavel);
        cellAssiEstenso.addElement(pAssiEstenso);

        PdfPTable pTableExteso = new PdfPTable(new float[] { 25f, 75f });
        pTableExteso.setWidthPercentage(100f);

        JTextPane jtp = new JTextPane();
        Moeda.EscreverEstenso(toPa, jtp, ((mapList.size() > 0) ? toString(mapList.get(0).get(MOEDA)) : ""));

        PdfPCell cellExteso = new PdfPCell(new Phrase("Recived the sum of", fontCorpoN));
        cellExteso.setBorder(0);
        pTableExteso.addCell(cellExteso);
        cellExteso = new PdfPCell(new Phrase(jtp.getText().toUpperCase().trim(), fontCorpoU));
        cellExteso.setBorder(0);
        pTableExteso.addCell(cellExteso);

        pAssiEstenso.add(pTableExteso);

        PdfPTable pTableAss = new PdfPTable(new float[] { 45f, 55f });
        pTableAss.setWidthPercentage(100f);

        PdfPCell cellAss = new PdfPCell(new Phrase(" ______________", fontCorpoN));
        cellAss.setPaddingTop(15f);
        cellAss.setHorizontalAlignment(Element.ALIGN_CENTER);
        cellAss.setBorder(0);
        cellAss.setPaddingBottom(0f);
        pTableAss.addCell(cellAss);

        cellAss = new PdfPCell(new Phrase(" ____________________________________________", fontCorpoN));
        cellAss.setPaddingTop(15f);
        cellAss.setPaddingBottom(0f);
        cellAss.setHorizontalAlignment(Element.ALIGN_CENTER);
        cellAss.setBorder(0);
        pTableAss.addCell(cellAss);

        cellAss = new PdfPCell(new Phrase("Date", fontCorpoN));
        cellAss.setHorizontalAlignment(Element.ALIGN_CENTER);
        cellAss.setBorder(0);
        pTableAss.addCell(cellAss);

        cellAss = new PdfPCell(new Phrase("Receiver name & signature", fontCorpoN));
        cellAss.setHorizontalAlignment(Element.ALIGN_CENTER);
        cellAss.setBorder(0);
        pTableAss.addCell(cellAss);
        pTableAss.setHorizontalAlignment(Element.ALIGN_CENTER);

        pAssiEstenso.add(pTableAss);
        pAssiEstenso.setAlignment(Element.ALIGN_CENTER);
        pAssiEstenso.add(new Phrase(
                "NOTA: Um recibo oficial pode ser obtido por um pagamento e informado na parte inversa deste comprovativo.\n\n",
                fontCorpoN));
        cellAssiEstenso = new PdfPCell();
        cellAssiEstenso.addElement(pAssiEstenso);

        pTableAssiEstenso.addCell(cellAssiEstenso);

        documento.add(pTableAssiEstenso);

        documento.close();
        reString = "../Documentos/" + user + "/Pagamentos/" + "Pagamentos Func " + Ddata + ".pdf";
        return reString;
    } catch (FileNotFoundException | DocumentException ex) {
        Logger.getLogger(FuncPagamento.class.getName()).log(Level.SEVERE, null, ex);
    }
    return reString;
}

From source file:Export.FuncPagamento.java

public static String folhaPagamentoOnlyMovCre(String numPagamento, String user, String nomeUser, Object ob)
        throws NumberFormatException {
    try {/*from  w w  w .j  a  va  2 s.co m*/

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

        Font fontCabecalhoN = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED,
                9.5f);
        Font fontCorpo = FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 9f);
        Font fontCorpoP = FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 8f);
        Font fontCorpoN = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 9f);
        Font fontCorpoNU = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 9f,
                Font.UNDERLINE);
        Font fontCorpoNG = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED,
                11.5f);
        Font fontCorpoNGT = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED,
                13f, Font.UNDERLINE);
        Font fontCabecalhoNG = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED,
                16f, Font.UNDERLINE);

        ArrayList<HashMap<String, Object>> mapList = setObj(numPagamento, ob);

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

        String Ddata = sdf1.format(new Date());

        int size = mapList.size(), i = 0;

        File ff = new File(ConfigDoc.Fontes.getDiretorio() + "/" + user + "/Pagamentos/");

        ff.mkdirs();
        ff = new File(ff.getAbsoluteFile() + "/" + "Pagamentos Func " + Ddata + ".pdf");

        OutputStream outputStraem = new FileOutputStream(ff);
        PdfWriter writer = PdfWriter.getInstance(documento, outputStraem);

        MyFooter event = new MyFooter();
        writer.setPageEvent(event);

        documento.open();

        for (HashMap<String, Object> hashMap : mapList) {
            i++;

            PdfPTable pTableEmpresaPricipal = new PdfPTable(new float[] { 25f, 75f });
            pTableEmpresaPricipal.setWidthPercentage(90);
            PdfPTable pTableEmpresaInforImpres1 = new PdfPTable(1);
            PdfPTable pTableEmpresaInforImpres5 = new PdfPTable(1);

            PdfPTable pTableNull = new PdfPTable(1);
            PdfPCell cellNull = new PdfPCell(new Phrase(" ", fontCorpoP));
            cellNull.setBorder(0);
            pTableNull.addCell(cellNull);

            PdfPCell pCellNomeEmpresa = new PdfPCell(new Phrase(ConfigDoc.Empresa.NOME, fontCabecalhoNG));
            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);

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

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

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

            pTableEmpresaInforImpres5.addCell(cellTabela3);

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

            PdfPCell cellTabela6 = new PdfPCell(imageEmpresa);
            cellTabela6.setBorder(0);

            pTableEmpresaPricipal.addCell(cellTabela6);
            pTableEmpresaPricipal.addCell(cellTabela5);

            documento.add(pTableEmpresaPricipal);

            documento.add(pTableNull);
            documento.add(pTableNull);

            PdfPTable pTableTitulo = new PdfPTable(new float[] { 50, 50 });
            pTableTitulo.setWidthPercentage(90f);
            PdfPCell cellTitulo = new PdfPCell(new Phrase("Comprovativo de Pagamento", fontCorpoNGT));
            cellTitulo.setBorder(0);
            cellTitulo.setHorizontalAlignment(Element.ALIGN_RIGHT);
            cellTitulo.setPaddingRight(-80f);
            cellTitulo.setPaddingTop(-26f);
            pTableTitulo.addCell(cellTitulo);
            cellTitulo = new PdfPCell(new Phrase("N: " + hashMap.get(PAGAMENTO), fontCorpoNGT));
            cellTitulo.setHorizontalAlignment(Element.ALIGN_RIGHT);
            cellTitulo.setBorder(0);
            cellTitulo.setPaddingBottom(5f);
            pTableTitulo.addCell(cellTitulo);

            documento.add(pTableTitulo);

            PdfPTable pTableAno = new PdfPTable(new float[] { 100 });
            pTableAno.setWidthPercentage(90f);

            SimpleDateFormat sdfVeiw = new SimpleDateFormat("MMMM '('dd/MM/yyyy')'", new Locale("pt", "BR"));
            PdfPCell cellAno = new PdfPCell(new Phrase(sdfVeiw.format(new Date()), fontCorpoNGT));
            cellAno.setBorder(0);
            cellAno.setPaddingBottom(20f);
            pTableAno.addCell(cellAno);

            documento.add(pTableAno);

            PdfPTable pTableDetalhesPagamento = new PdfPTable(new float[] { 100 });
            pTableDetalhesPagamento.setWidthPercentage(90f);
            PdfPCell cellDetalhesPagamento = new PdfPCell();

            Paragraph pDetalhesPagamento = new Paragraph();
            pDetalhesPagamento.add(new Paragraph("\nDetalhes de Pagamento ", fontCorpoNG));

            pDetalhesPagamento.add(new Phrase("Beneficirio: ", fontCorpoN));
            pDetalhesPagamento.add(new Phrase(toString(hashMap.get(BENEFICIARIO)) + "\n", fontCorpo));
            pDetalhesPagamento.add(new Phrase("Descrio do pagamento: ", fontCorpoN));
            pDetalhesPagamento.add(new Phrase(toString(hashMap.get(DESCRICAOPAGAMENTO)), fontCorpo));
            pDetalhesPagamento.add(new Paragraph("CONFORME APROVADO\n\n", fontCorpoN));

            pDetalhesPagamento.add(new Paragraph("Valor Pagamento", fontCorpoNG));
            pDetalhesPagamento.add(new Phrase("Valor Numerico: ", fontCorpoN));
            pDetalhesPagamento.add(new Phrase(
                    toMoeda(hashMap.get(VALORPAGAMENTO), toString(hashMap.get(SIGLA))) + "\n", fontCorpo));
            System.err.println(toString(hashMap.get(RETENCAOFONTE)) + " hfhfh retensao");
            if (toString(hashMap.get(RETENCAOFONTE)).trim().equals("1")) {
                double ret = getValorImportRetensao();
                pDetalhesPagamento.add(new Phrase("Valor Retensao Fonte: ", fontCorpoN));
                pDetalhesPagamento.add(new Phrase(toMoeda(ret, "%") + "\n", fontCorpo));
                pDetalhesPagamento.add(new Phrase("Valor Retido: ", fontCorpoN));
                double valret = toDouble(hashMap.get(VALORPAGAMENTO)) * ret;
                pDetalhesPagamento
                        .add(new Phrase(toMoeda(valret, toString(hashMap.get(SIGLA))) + "\n", fontCorpo));
            }

            JTextPane jtp = new JTextPane();
            Double valor = Double.valueOf((hashMap.get(VALORPAGAMENTO) + ""));
            Moeda.EscreverEstenso(valor, jtp, toString(hashMap.get(MOEDA)));

            pDetalhesPagamento.add(new Phrase("Valor por Extenso: ", fontCorpoN));
            pDetalhesPagamento.add(new Phrase(jtp.getText().trim() + " \n\n", fontCorpo));

            pDetalhesPagamento.add(new Paragraph("Descrio da Conta", fontCorpoNG));
            pDetalhesPagamento.add(new Phrase("Cod Conta: ", fontCorpoN));
            pDetalhesPagamento.add(new Phrase(hashMap.get(CODIGOCONTAPAGAMENTO) + "\n", fontCorpo));
            pDetalhesPagamento.add(new Phrase("Titulo da Conta: ", fontCorpoN));
            pDetalhesPagamento.add(new Phrase(hashMap.get(TITULOCONTAPAGAMENTO) + "\n", fontCorpo));

            /**
             * For alter
             */
            //                pDetalhesPagamento.add(new Phrase("Forma de Pagamento: ", fontCorpoN));
            //                pDetalhesPagamento.add(new Phrase(hashMap.get(FORMAPAGAMENTO) + " \n", fontCorpo));
            pDetalhesPagamento.add(new Phrase("Documento de Pagamento: ", fontCorpoN));
            pDetalhesPagamento.add(new Phrase(toString(hashMap.get(DESCRICAOCONTABANCO)) + " - "
                    + toString(hashMap.get(DOCFORMAPAGAMENTO)) + "\n\n", fontCorpo));
            pDetalhesPagamento.add(new Paragraph(" ", fontCorpoN));

            cellDetalhesPagamento.addElement(pDetalhesPagamento);
            pTableDetalhesPagamento.addCell(cellDetalhesPagamento);

            cellDetalhesPagamento = new PdfPCell();
            pDetalhesPagamento = new Paragraph();

            pDetalhesPagamento.add(new Paragraph(" ", fontCorpo));
            pDetalhesPagamento.add(new Phrase("Preparado por: ", fontCorpoN));
            pDetalhesPagamento.add(new Phrase(nomeUser + " ", fontCorpoP));
            pDetalhesPagamento.add(new Phrase("            Examinado por", fontCorpoN));
            pDetalhesPagamento.add(new Phrase("____________________\n", fontCorpo));

            pDetalhesPagamento.add(new Paragraph(" ", fontCorpoN));
            pDetalhesPagamento.add(new Paragraph("Pagamento Autorizado por:", fontCorpoNG));

            pDetalhesPagamento.add(new Paragraph(" ", fontCorpoN));
            pDetalhesPagamento.add(new Phrase("Assinatura: ", fontCorpoN));
            pDetalhesPagamento.add(new Phrase(" ____________________________________________", fontCorpo));
            pDetalhesPagamento.add(new Phrase("    Data ", fontCorpoN));
            pDetalhesPagamento.add(new Phrase(" ______________________\n\n", fontCorpo));

            pDetalhesPagamento.add(new Phrase("Assinatura: ", fontCorpoN));
            pDetalhesPagamento.add(new Phrase(" ____________________________________________", fontCorpo));
            pDetalhesPagamento.add(new Phrase("    Data ", fontCorpoN));
            pDetalhesPagamento.add(new Phrase(" ______________________\n", fontCorpo));

            pDetalhesPagamento.add(new Paragraph(" ", fontCorpo));
            pDetalhesPagamento.add(new Paragraph(
                    "............................................................................."
                            + "...........................................................................",
                    fontCorpoN));

            pDetalhesPagamento.add(new Paragraph(" ", fontCorpo));
            Paragraph pReceip = new Paragraph("RECIBO", fontCorpoN);
            pReceip.setAlignment(Element.ALIGN_CENTER);
            pDetalhesPagamento.add(pReceip);

            pDetalhesPagamento.add(new Paragraph(" ", fontCorpo));
            pDetalhesPagamento.add(new Phrase("Recebi o valor de: ", fontCorpo));
            pDetalhesPagamento.add(new Phrase(jtp.getText() + " \n", fontCorpoNU));

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

            PdfPTable pTableNumCheque = new PdfPTable(
                    new float[] { 33.3333333333f, 33.3333333333f, 33.3333333333f });
            pTableNumCheque.setWidthPercentage(90f);
            pTableNumCheque.setWidthPercentage(100f);

            PdfPCell cellNumCheque = new PdfPCell(new Phrase("_______________________", fontCorpo));
            cellNumCheque.setBorder(0);
            cellNumCheque.setHorizontalAlignment(Element.ALIGN_CENTER);
            pTableNumCheque.addCell(cellNumCheque);
            cellNumCheque = new PdfPCell(new Phrase("_______________________", fontCorpo));
            cellNumCheque.setBorder(0);
            cellNumCheque.setHorizontalAlignment(Element.ALIGN_CENTER);
            pTableNumCheque.addCell(cellNumCheque);
            cellNumCheque = new PdfPCell(new Phrase("_______________________", fontCorpo));
            cellNumCheque.setBorder(0);
            cellNumCheque.setHorizontalAlignment(Element.ALIGN_CENTER);
            pTableNumCheque.addCell(cellNumCheque);

            cellNumCheque = new PdfPCell(new Phrase("Cheque No.", fontCorpoN));
            cellNumCheque.setBorder(0);
            cellNumCheque.setHorizontalAlignment(Element.ALIGN_CENTER);
            pTableNumCheque.addCell(cellNumCheque);
            cellNumCheque = new PdfPCell(new Phrase("Data", fontCorpoN));
            cellNumCheque.setBorder(0);
            cellNumCheque.setHorizontalAlignment(Element.ALIGN_CENTER);
            pTableNumCheque.addCell(cellNumCheque);
            cellNumCheque = new PdfPCell(new Phrase("Receiver Name & Signature", fontCorpoN));
            cellNumCheque.setBorder(0);
            cellNumCheque.setHorizontalAlignment(Element.ALIGN_CENTER);
            pTableNumCheque.addCell(cellNumCheque);

            pDetalhesPagamento.add(pTableNumCheque);

            pDetalhesPagamento.add(new Phrase(
                    "\nNOTA: Um recibo oficial pode ser obtido por um pagamento e informado na parte inversa deste comprovativo. \n\n",
                    fontCorpo));

            cellDetalhesPagamento.addElement(pDetalhesPagamento);

            pTableDetalhesPagamento.addCell(cellDetalhesPagamento);

            documento.add(pTableDetalhesPagamento);

            if (i != size) {
                documento.newPage();
            }
        }

        documento.close();
        String ret = "../Documentos/" + user + "/Pagamentos/" + "Pagamentos Func " + Ddata + ".pdf";

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

        return ret;
    } catch (BadElementException | IOException ex) {
        Logger.getLogger(FuncPagamento.class.getName()).log(Level.SEVERE, null, ex);
    } catch (DocumentException ex) {
        Logger.getLogger(FuncPagamento.class.getName()).log(Level.SEVERE, null, ex);
    }
    return null;
}

From source file:Export.GrossSarary.java

public static void criaDoc(String user) {
    OutputStream outputStraem;/*from  w w  w .  j  av  a 2s .c om*/
    try {
        Font fontCabecalhoN = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED,
                10f);
        Font fontCorpo = FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 9f);
        Font fontCorpoBP = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 9f);
        Font fontCorpoN = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED,
                9.5f);
        Font fontCorpoNG = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED,
                13f);
        Font fontCorpoTitile = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED,
                11f);
        Font fontCabecalhoNG = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED,
                16f, Font.UNDERLINE);

        SimpleDateFormat sdf1 = new SimpleDateFormat("dd-MM-yyyy hh'.'mm'.'ss");
        File ff = new File(ConfigDoc.Fontes.getDiretorio() + "/" + user + "/Relatorio");
        ff.mkdirs();
        String Ddata = sdf1.format(new Date());
        ff = new File(ff.getAbsoluteFile() + "/" + "Gross Salary " + Ddata + ".pdf");
        outputStraem = new FileOutputStream(ff);

        String reString = "../Documentos/" + user + "/Relatorio/Gross Salary " + Ddata + ".pdf";

        PdfPTable pTableEmpresaPricipal = new PdfPTable(new float[] { 15f, 85f });
        PdfPTable pTableEmpresaInforImpres1 = new PdfPTable(1);
        PdfPTable pTableEmpresaInforImpres5 = new PdfPTable(1);

        PdfPTable pTableNull = new PdfPTable(1);
        PdfPCell cellNull = new PdfPCell(new Phrase(" ", fontCorpo));
        cellNull.setBorder(0);
        pTableNull.addCell(cellNull);

        PdfPCell pCellNomeEmpresa = new PdfPCell(new Phrase(ConfigDoc.Empresa.NOME, fontCabecalhoNG));
        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);

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

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

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

        pTableEmpresaInforImpres5.addCell(cellTabela3);

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

        PdfPCell cellTabela6 = new PdfPCell(imageEmpresa);
        cellTabela6.setBorder(0);
        pTableEmpresaPricipal.setWidthPercentage(97);
        pTableEmpresaPricipal.addCell(cellTabela6);
        pTableEmpresaPricipal.addCell(cellTabela5);

        Document documento = new Document(PageSize.A4.rotate());
        PdfWriter writer = PdfWriter.getInstance(documento, outputStraem);

        //Table Principal
        PdfPTable pTableTitile = new PdfPTable(new float[] { 100 });
        PdfPTable pTableTablePrincipal = new PdfPTable(
                new float[] { 16.875f, 11.875f, 11.875f, 11.875f, 11.875f, 11.875f, 11.875f, 11.875f });
        pTableTablePrincipal.setWidthPercentage(100f);

        PdfPCell pCellTable = new PdfPCell(new Phrase("Categoria".toUpperCase(), fontCorpoTitile));
        pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        pCellTable.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        pTableTablePrincipal.addCell(pCellTable);

        //Table principal
        PdfPTable tableCell;
        for (int i = 1; i <= 7; i++) {
            tableCell = new PdfPTable(new float[] { 100 });

            pCellTable = new PdfPCell(new Phrase("NIVEL", fontCorpoTitile));
            pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
            tableCell.addCell(pCellTable);

            pCellTable = new PdfPCell(new Phrase(i + "", fontCorpoTitile));
            pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
            tableCell.addCell(pCellTable);

            pTableTablePrincipal.addCell(tableCell);
        }

        de = getList();

        for (DadosEstrutura de1 : de) {
            pCellTable = new PdfPCell(new Phrase(de1.categoria, fontCorpoN));
            pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
            pTableTablePrincipal.addCell(pCellTable);

            pCellTable = new PdfPCell(new Phrase(de1.set1, fontCorpo));
            pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
            pTableTablePrincipal.addCell(pCellTable);

            pCellTable = new PdfPCell(new Phrase(de1.set2, fontCorpo));
            pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
            pTableTablePrincipal.addCell(pCellTable);

            pCellTable = new PdfPCell(new Phrase(de1.set3, fontCorpo));
            pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
            pTableTablePrincipal.addCell(pCellTable);

            pCellTable = new PdfPCell(new Phrase(de1.set4, fontCorpo));
            pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
            pTableTablePrincipal.addCell(pCellTable);

            pCellTable = new PdfPCell(new Phrase(de1.set5, fontCorpo));
            pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
            pTableTablePrincipal.addCell(pCellTable);

            pCellTable = new PdfPCell(new Phrase(de1.set6, fontCorpo));
            pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
            pTableTablePrincipal.addCell(pCellTable);

            pCellTable = new PdfPCell(new Phrase(de1.set7, fontCorpo));
            pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
            pTableTablePrincipal.addCell(pCellTable);
        }

        //Titulo de Table
        pCellTable = new PdfPCell(new Phrase("Estrutura de salrio Grosso".toUpperCase(), fontCorpoNG));
        pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        pCellTable.setBorder(PdfPCell.NO_BORDER);
        pCellTable.setPadding(15f);
        pTableTitile.addCell(pCellTable);

        pCellTable = new PdfPCell(new Phrase("Mensal".toUpperCase(), fontCorpoNG));
        pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        pCellTable.setBorder(PdfPCell.NO_BORDER);
        pTableTitile.addCell(pCellTable);

        @SuppressWarnings("UnusedAssignment")
        PdfPTable pTableInf = null;
        PdfPTable pTableInfTile = new PdfPTable(new float[] { 6, 18.5f, 18.5f, 18.5f, 18f, 20f });
        PdfPTable pTableInfReal = new PdfPTable(new float[] { 100f });
        pTableInfTile.setWidthPercentage(95f);
        pTableInfReal.setWidthPercentage(95f);

        pTableInfTile.setHorizontalAlignment(PdfPTable.ALIGN_CENTER);
        pTableInfReal.setHorizontalAlignment(PdfPTable.ALIGN_CENTER);

        pCellTable = new PdfPCell(new Phrase("NIVEL", fontCorpoN));
        pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        pCellTable.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        pTableInfTile.addCell(pCellTable);

        pCellTable = new PdfPCell(new Phrase("SAL?RIO BASE", fontCorpoN));
        pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        pCellTable.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        pTableInfTile.addCell(pCellTable);

        pCellTable = new PdfPCell(new Phrase("SUBSIDIO ALMOO", fontCorpoN));
        pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        pCellTable.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        pTableInfTile.addCell(pCellTable);

        pCellTable = new PdfPCell(new Phrase("SUBSIDIO ALOGAMENTO", fontCorpoN));
        pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        pCellTable.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        pTableInfTile.addCell(pCellTable);

        pCellTable = new PdfPCell(new Phrase("SUBSIDIO TRANSPORTE", fontCorpoN));
        pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        pCellTable.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        pTableInfTile.addCell(pCellTable);

        pCellTable = new PdfPCell(new Phrase("TOTAL", fontCorpoN));
        pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        pCellTable.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        pTableInfTile.addCell(pCellTable);

        HashMap<String, ArrayList<Categoria>> outherAr = GrossSarary.getCatList();
        int si = outherAr.size(), i = 0;
        for (Map.Entry<String, ArrayList<Categoria>> eSet : outherAr.entrySet()) {

            pTableInf = new PdfPTable(new float[] { 6, 18.5f, 18.5f, 18.5f, 18f, 20f });
            pTableInf.setWidthPercentage(95f);
            pTableInf.setHorizontalAlignment(PdfPTable.ALIGN_CENTER);

            pCellTable = new PdfPCell(new Phrase(eSet.getKey(), fontCorpoNG));
            pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
            pCellTable.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
            pCellTable.setBorder(PdfPCell.NO_BORDER);
            pCellTable.setColspan(6);
            pTableInf.addCell(pCellTable);

            pCellTable = new PdfPCell(new Phrase(" ", fontCorpoN));
            pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
            pCellTable.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
            pCellTable.setColspan(6);
            pCellTable.setBorder(PdfPCell.NO_BORDER);
            pTableInf.addCell(pCellTable);

            pCellTable = new PdfPCell(pTableInfTile);
            pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
            pCellTable.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
            pCellTable.setColspan(6);
            pCellTable.setBorder(PdfPCell.NO_BORDER);
            pTableInf.addCell(pCellTable);

            for (Categoria ca : eSet.getValue()) {
                pCellTable = new PdfPCell(new Phrase(ca.nivel, fontCorpo));
                pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
                pCellTable.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
                pTableInf.addCell(pCellTable);

                pCellTable = new PdfPCell(new Phrase(toConverterToMoeda(ca.salarioBase), fontCorpo));
                pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
                pCellTable.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
                pCellTable.setPaddingRight(10f);
                pTableInf.addCell(pCellTable);

                pCellTable = new PdfPCell(new Phrase(toConverterToMoeda(ca.subsidioAlmoco), fontCorpo));
                pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
                pCellTable.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
                pCellTable.setPaddingRight(10f);
                pTableInf.addCell(pCellTable);

                pCellTable = new PdfPCell(new Phrase(toConverterToMoeda(ca.subsidioAlogamento), fontCorpo));
                pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
                pCellTable.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
                pCellTable.setPaddingRight(10f);
                pTableInf.addCell(pCellTable);

                pCellTable = new PdfPCell(new Phrase(toConverterToMoeda(ca.subsidioTransporte), fontCorpo));
                pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
                pCellTable.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
                pCellTable.setPaddingRight(10f);
                pTableInf.addCell(pCellTable);

                pCellTable = new PdfPCell(new Phrase(toConverterToMoeda(ca.total), fontCorpo));
                pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
                pCellTable.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
                pCellTable.setPaddingRight(10f);
                pTableInf.addCell(pCellTable);
            }

            pCellTable = new PdfPCell(new Phrase(" ", fontCorpoN));
            pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
            pCellTable.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
            pCellTable.setBorder(PdfPCell.NO_BORDER);
            pCellTable.setColspan(6);

            i++;
            if (si == i) {
                pTableInf.addCell(pCellTable);
                pTableInf.addCell(pCellTable);
                pTableInf.addCell(pCellTable);
            }

            pCellTable = new PdfPCell(pTableInf);
            pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
            pCellTable.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
            pCellTable.setBorder(PdfPCell.NO_BORDER);
            pTableInfReal.addCell(pCellTable);

        }

        documento.open();
        documento.add(pTableEmpresaPricipal);
        documento.add(pTableNull);
        documento.add(pTableTitile);
        documento.add(pTableNull);
        documento.add(pTableTablePrincipal);
        //                documento.add(pTableNull);
        documento.newPage();
        documento.add(pTableInfReal);
        documento.close();

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

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