Example usage for com.itextpdf.text Element ALIGN_RIGHT

List of usage examples for com.itextpdf.text Element ALIGN_RIGHT

Introduction

In this page you can find the example usage for com.itextpdf.text Element ALIGN_RIGHT.

Prototype

int ALIGN_RIGHT

To view the source code for com.itextpdf.text Element ALIGN_RIGHT.

Click Source Link

Document

A possible value for paragraph alignment.

Usage

From source file:Export.FuncPagamento.java

private String pequenoPagamento(String numPagamento, String user, String nomeUser, int i) {
    OutputStream outputStraem;/*  w ww .j ava2  s.c  o m*/
    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 www. j a v a  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.ReciboPagamento.java

public PdfPTable detaDoc(HashMap<String, Object> map, Font fontTitile, Font fontRecibo, Font fontTitileShort,
        Font fontReciboTxt, Font fontConteudo, Font fontConteudoTxt, Font fontConteudoTxtUl)
        throws DocumentException {
    PdfPTable pTablePrincipal = new PdfPTable(new float[] { 100 });
    try {/*from  w w w  . ja  va  2s.  co m*/
        pTablePrincipal.setWidthPercentage(100f);

        PdfPTable pTableTitulo = new PdfPTable(new float[] { 60, 40 });
        pTableTitulo.setWidthPercentage(100);

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

        PdfPCell cellTitulo = new PdfPCell(new Phrase(ConfigDoc.Empresa.NOME, fontTitile));
        cellTitulo.setHorizontalAlignment(Element.ALIGN_CENTER);
        cellTitulo.setBorder(0);
        cellTitulo.setPaddingTop(20f);
        cellTitulo.setPaddingLeft(70f);
        pTableTitulo.addCell(cellTitulo);
        cellTitulo = new PdfPCell(new Phrase("Recibo N ".toUpperCase() + map.get(IDAMORTIZACAO), fontRecibo));
        cellTitulo.setVerticalAlignment(Element.ALIGN_BOTTOM);
        cellTitulo.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cellTitulo.setBorder(0);
        pTableTitulo.addCell(cellTitulo);

        cellTitulo = new PdfPCell(new Phrase(ConfigDoc.Empresa.ENDERECO + ", " + ConfigDoc.Empresa.CAIXAPOSTAL
                + ", " + ConfigDoc.Empresa.TELEFAX, fontTitileShort));
        cellTitulo.setHorizontalAlignment(Element.ALIGN_CENTER);
        cellTitulo.setPaddingLeft(70f);
        cellTitulo.setBorder(0);
        pTableTitulo.addCell(cellTitulo);
        cellTitulo = new PdfPCell(new Phrase(" ", fontTitileShort));
        cellTitulo.setPaddingBottom(0f);
        cellTitulo.setPaddingTop(0f);
        cellTitulo.setBorder(0);
        pTableTitulo.addCell(cellTitulo);

        cellTitulo = new PdfPCell(new Phrase(ConfigDoc.Empresa.REPUBLICA, fontTitileShort));
        cellTitulo.setHorizontalAlignment(Element.ALIGN_CENTER);
        cellTitulo.setBorder(0);
        cellTitulo.setPaddingLeft(70f);
        pTableTitulo.addCell(cellTitulo);
        cellTitulo = new PdfPCell(new Phrase(" ", fontTitileShort));
        cellTitulo.setPaddingBottom(0f);
        cellTitulo.setPaddingTop(0f);
        cellTitulo.setBorder(0);
        pTableTitulo.addCell(cellTitulo);

        cellTitulo = new PdfPCell(new Phrase(ConfigDoc.Empresa.EMAIL, fontTitileShort));
        cellTitulo.setHorizontalAlignment(Element.ALIGN_CENTER);
        cellTitulo.setBorder(0);
        cellTitulo.setPaddingLeft(70f);
        pTableTitulo.addCell(cellTitulo);
        cellTitulo = new PdfPCell(new Phrase(" ", fontTitileShort));
        cellTitulo.setPaddingBottom(0f);
        cellTitulo.setPaddingTop(0f);
        cellTitulo.setBorder(0);
        pTableTitulo.addCell(cellTitulo);

        cellTitulo = new PdfPCell(new Phrase("Ordem de receita / recibo".toUpperCase(), fontRecibo));
        cellTitulo.setHorizontalAlignment(Element.ALIGN_CENTER);
        cellTitulo.setBorder(0);
        cellTitulo.setPaddingLeft(70f);
        pTableTitulo.addCell(cellTitulo);
        cellTitulo = new PdfPCell(new Phrase(" ", fontTitileShort));
        cellTitulo.setVerticalAlignment(Element.ALIGN_TOP);
        cellTitulo.setPaddingBottom(30f);
        cellTitulo.setPaddingTop(0f);
        cellTitulo.setBorder(0);
        pTableTitulo.addCell(cellTitulo);

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

        PdfPCell cellImagem = new PdfPCell(imageEmpresa);
        cellImagem.setBorder(PdfPCell.NO_BORDER);
        cellImagem.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        cellImagem.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);

        PdfPCell cellpTableTitulo = new PdfPCell(pTableTitulo);
        cellpTableTitulo.setBorder(PdfPCell.NO_BORDER);
        cellpTableTitulo.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);

        pTableTituloImage.addCell(cellImagem);
        pTableTituloImage.addCell(cellpTableTitulo);

        PdfPCell cellpTableTituloPrincipal = new PdfPCell(pTableTituloImage);
        cellpTableTituloPrincipal.setBorder(PdfPCell.NO_BORDER);

        pTablePrincipal.addCell(cellpTableTituloPrincipal);

        PdfPTable pTableDataCaixaMontante = new PdfPTable(new float[] { 35f, 5f, 60f });
        pTableDataCaixaMontante.setWidthPercentage(100f);

        PdfPCell cellDataCaixaMontante = new PdfPCell(new Phrase(" ", fontRecibo));
        cellDataCaixaMontante.setBorder(0);
        pTableDataCaixaMontante.addCell(cellDataCaixaMontante);
        pTableDataCaixaMontante.addCell(cellDataCaixaMontante);
        cellDataCaixaMontante = new PdfPCell();
        cellDataCaixaMontante.setBorder(0);
        Paragraph p = new Paragraph();
        p.add(new Phrase("Data: ".toUpperCase(), fontRecibo));

        p.add(new Phrase(converterData(map.get(REGISTROAMORTIZACAO), 1), fontReciboTxt));
        p.setAlignment(Element.ALIGN_RIGHT);
        cellDataCaixaMontante.addElement(p);
        cellDataCaixaMontante.setPaddingBottom(5f);
        pTableDataCaixaMontante.addCell(cellDataCaixaMontante);

        cellDataCaixaMontante = new PdfPCell();
        p = new Paragraph();
        p.add(new Phrase("Caixa de: ".toUpperCase(), fontRecibo));
        p.add(new Phrase("So Tom", fontReciboTxt));
        p.setAlignment(Element.ALIGN_LEFT);
        cellDataCaixaMontante.addElement(p);
        cellDataCaixaMontante.setPaddingTop(-2f);
        cellDataCaixaMontante.setPaddingBottom(5f);
        cellDataCaixaMontante.setBorderColor(BaseColor.BLUE.darker().darker().darker());
        pTableDataCaixaMontante.addCell(cellDataCaixaMontante);

        cellDataCaixaMontante = new PdfPCell(new Phrase(" ", fontRecibo));
        cellDataCaixaMontante.setBorder(0);
        pTableDataCaixaMontante.addCell(cellDataCaixaMontante);

        cellDataCaixaMontante = new PdfPCell();
        p = new Paragraph();
        p.add(new Phrase("Montante: ".toUpperCase(), fontRecibo));

        Double montade = Moeda.arrendodamento(toString(map.get(VALORAMORTIZADO)));

        //            SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy HH:");
        Object dRegistro = map.get(DATAREGAPOLICE);
        montade *= valorCompra(map.get(SIGLAMOEDA) + "", dRegistro);

        p.add(new Phrase(converterMoeda(montade, "STD") + "", fontReciboTxt));
        p.setAlignment(Element.ALIGN_LEFT);
        cellDataCaixaMontante.addElement(p);
        cellDataCaixaMontante.setPaddingTop(-2f);
        cellDataCaixaMontante.setPaddingBottom(5f);
        cellDataCaixaMontante.setBorderColor(BaseColor.BLUE.darker().darker().darker());
        pTableDataCaixaMontante.addCell(cellDataCaixaMontante);

        PdfPCell cellDataCaixaMontantePrincipal = new PdfPCell(pTableDataCaixaMontante);
        cellDataCaixaMontantePrincipal.setBorder(PdfPCell.NO_BORDER);

        pTablePrincipal.addCell(cellDataCaixaMontantePrincipal);

        PdfPTable pTableConteudo = new PdfPTable(new float[] { 40, 60 });
        pTableConteudo.setWidthPercentage(100f);
        PdfPCell cellConteudo = new PdfPCell();
        cellConteudo.setBorder(0);

        Paragraph pConteudo = new Paragraph();
        pConteudo.add(new Phrase("N Assegurado: ".toUpperCase(), fontConteudo));
        pConteudo.add(new Phrase(map.get(NUMREGISTRO) + "\n", fontConteudoTxt));

        /**
         * For alter
         */
        pConteudo.add(new Phrase("Prmio Liquido: ".toUpperCase(), fontConteudo));
        pConteudo.add(new Phrase(converterMoeda(map.get(TOTALBRUTO), map.get(SIGLAMOEDA) + "") + "\n",
                fontConteudoTxt));

        pConteudo.add(new Phrase("Impostos: ".toUpperCase(), fontConteudo));
        pConteudo.add(new Phrase(converterMoeda(impostosCalculo(map.get(TOTAl), map.get(IMPOSTOCONSUMO)),
                map.get(SIGLAMOEDA) + "") + "\n", fontConteudoTxt));

        pConteudo.add(new Phrase("Impostos Selo: ".toUpperCase(), fontConteudo));
        pConteudo.add(new Phrase(
                converterMoeda(impostosCalculo(map.get(TOTAl), map.get(IMPOSTOSELO)), map.get(SIGLAMOEDA) + "")
                        + "\n",
                fontConteudoTxt));

        pConteudo.add(new Phrase("FGA: ", fontConteudo));
        pConteudo.add(new Phrase(
                converterMoeda(impostosCalculo(map.get(TOTAl), map.get(MOTORFOUND)), map.get(SIGLAMOEDA) + "")
                        + "\n",
                fontConteudoTxt));

        pConteudo.add(new Phrase("Total: ".toUpperCase(), fontConteudo));
        pConteudo.add(
                new Phrase(converterMoeda(map.get(TOTAl), map.get(SIGLAMOEDA) + "") + "\n", fontConteudoTxt));

        pConteudo.add(new Phrase("Efeito: ".toUpperCase(), fontConteudo));
        pConteudo.add(new Phrase(converterData(map.get(EFEITO), 1) + "\n", fontConteudoTxt));

        pConteudo.add(new Phrase("Vencimento: ".toUpperCase(), fontConteudo));
        pConteudo.add(new Phrase(converterData(map.get(VENCIMENTO), 1) + "\n", fontConteudoTxt));

        cellConteudo.addElement(pConteudo);
        pTableConteudo.addCell(cellConteudo);

        cellConteudo = new PdfPCell();
        cellConteudo.setBorder(0);

        pConteudo = new Paragraph();
        pConteudo.add(new Phrase("Recebido do Sr: ".toUpperCase(), fontConteudo));
        pConteudo.add(new Phrase(map.get(CLIENTE) + "\n", fontConteudoTxt));

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

        Paragraph pNomeCod = new Paragraph();
        pNomeCod.add(new Phrase("Nome do Assegurado/Pagador: ".toUpperCase(), fontConteudo));
        pNomeCod.add(new Phrase(map.get(CLIENTE) + "", fontConteudoTxt));
        PdfPCell cellNomeCod = new PdfPCell();
        cellNomeCod.addElement(pNomeCod);
        cellNomeCod.setBorder(0);
        cellNomeCod.setPaddingTop(-2f);
        cellNomeCod.setPaddingBottom(2f);
        pTableNomeCod.addCell(cellNomeCod);

        cellNomeCod = new PdfPCell();
        pNomeCod = new Paragraph();
        pNomeCod.add(new Phrase("Codigo: ".toUpperCase(), fontConteudo));
        pNomeCod.add(new Phrase(" ", fontConteudoTxt));
        cellNomeCod.addElement(pNomeCod);
        cellNomeCod.setBorder(0);
        cellNomeCod.setPaddingTop(-2f);
        cellNomeCod.setPaddingBottom(2f);
        pTableNomeCod.addCell(cellNomeCod);

        pNomeCod = new Paragraph();
        pNomeCod.add(new Phrase("Nome do Intermedirio: ".toUpperCase(), fontConteudo));
        pNomeCod.add(new Phrase(" ", fontConteudoTxt));
        cellNomeCod = new PdfPCell();
        cellNomeCod.addElement(pNomeCod);
        cellNomeCod.setBorder(0);
        cellNomeCod.setPaddingTop(-2f);
        cellNomeCod.setPaddingBottom(2f);
        pTableNomeCod.addCell(cellNomeCod);

        cellNomeCod = new PdfPCell();
        pNomeCod = new Paragraph();
        pNomeCod.add(new Phrase("Codigo: ".toUpperCase(), fontConteudo));
        pNomeCod.add(new Phrase(" ", fontConteudoTxt));
        cellNomeCod.addElement(pNomeCod);
        cellNomeCod.setBorder(0);
        cellNomeCod.setPaddingTop(-2f);
        cellNomeCod.setPaddingBottom(2f);
        pTableNomeCod.addCell(cellNomeCod);

        pConteudo.add(pTableNomeCod);

        JTextPane jtp = new JTextPane();
        Double valor = Moeda.arrendodamento((map.get(VALORPRESTACAO) + ""));
        valor *= valorCompra(map.get(SIGLAMOEDA) + "", dRegistro);
        Moeda.EscreverEstenso(valor, jtp, "Dobras");

        pConteudo.add(new Phrase("A soma (por extenso) ".toUpperCase(), fontConteudo));
        pConteudo.add(new Phrase(jtp.getText().trim() + "\n", fontConteudoTxt));

        PdfPTable pTableApoliceDatasP = new PdfPTable(new float[] { 20, 80 });
        pTableApoliceDatasP.setWidthPercentage(100);
        PdfPTable pTableApoliceDatas = new PdfPTable(new float[] { 60, 40 });
        pTableApoliceDatas.setWidthPercentage(100);

        for (int i = 0; i < 1; i++) {
            PdfPCell cellApolice = new PdfPCell();
            Paragraph pApolice = new Paragraph();
            pApolice.add(new Phrase("N ", fontConteudo));
            pApolice.add(new Phrase(map.get(APOLICA) + "", fontConteudoTxt));
            cellApolice.addElement(pApolice);
            cellApolice.setPaddingTop(-2f);
            cellApolice.setPaddingBottom(2f);
            cellApolice.setBorder(0);
            pTableApoliceDatas.addCell(cellApolice);

            PdfPCell cellDatas = new PdfPCell();
            Paragraph pDatas = new Paragraph();
            pDatas.add(new Phrase("Data: ".toUpperCase(), fontConteudo));
            pDatas.add(new Phrase(converterData(map.get(DATAREGAPOLICE), 2) + "", fontConteudoTxt));
            cellDatas.addElement(pDatas);
            cellDatas.setBorder(0);
            cellDatas.setPaddingTop(-2f);
            cellDatas.setPaddingBottom(2f);
            pTableApoliceDatas.addCell(cellDatas);
        }
        PdfPCell cellApoliceP = new PdfPCell(new Phrase("Apolices".toUpperCase(), fontConteudo));
        cellApoliceP.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cellApoliceP.setBorder(0);
        pTableApoliceDatasP.addCell(cellApoliceP);
        cellApoliceP = new PdfPCell(pTableApoliceDatas);
        cellApoliceP.setBorder(0);
        pTableApoliceDatasP.addCell(cellApoliceP);

        pConteudo.add(pTableApoliceDatasP);
        //            
        PdfPTable pTableTipoPagemento = new PdfPTable(new float[] { 70f, 30f });
        pTableTipoPagemento.setWidthPercentage(100f);

        PdfPCell cellTipoPageme = new PdfPCell();
        Paragraph pDatas = new Paragraph();
        pDatas.add(new Phrase("Pagamento: ".toUpperCase(), fontConteudo));
        pDatas.add(new Phrase(map.get(TIPOPAGAMENTO) + " ", fontConteudoTxt));
        cellTipoPageme.addElement(pDatas);
        cellTipoPageme.setBorder(0);
        cellTipoPageme.setPaddingTop(-2f);
        cellTipoPageme.setPaddingBottom(2f);
        //           cellTipoPageme.setBorderColor(BaseColor.BLUE.darker().darker().darker());
        //           cellTipoPageme.setBorderWidthTop((i==0)?0.5f:0f);
        //           cellTipoPageme.setBorderWidthBottom(0.5f);
        pTableTipoPagemento.addCell(cellTipoPageme);

        cellTipoPageme = new PdfPCell();
        pDatas = new Paragraph();
        pDatas.add(new Phrase("N ".toUpperCase(), fontConteudo));
        pDatas.add(new Phrase(toString(map.get(DOCUMENTOAMORTIZACAO)) + " ", fontConteudoTxt));
        cellTipoPageme.addElement(pDatas);
        cellTipoPageme.setBorder(0);
        cellTipoPageme.setPaddingTop(-2f);
        cellTipoPageme.setPaddingBottom(2f);
        //                cellTipoPageme.setBorderColor(BaseColor.BLUE.darker().darker().darker());
        //                cellTipoPageme.setBorderWidthTop((i==0)?0.5f:0f);
        //                cellTipoPageme.setBorderWidthBottom(0.5f);
        pTableTipoPagemento.addCell(cellTipoPageme);

        pConteudo.add(pTableTipoPagemento);

        cellConteudo.addElement(pConteudo);
        pTableConteudo.addCell(cellConteudo);

        PdfPCell cellConteudoPrincipal = new PdfPCell(new PdfPTable(pTableConteudo));
        cellConteudoPrincipal.setBorder(PdfPCell.NO_BORDER);
        pTablePrincipal.addCell(cellConteudoPrincipal);

        PdfPTable pTableAssinatura = new PdfPTable(new float[] { 50f, 50f });
        pTableAssinatura.setWidthPercentage(100f);

        Font fontConteudoTxt_acess = FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI,
                BaseFont.EMBEDDED, 5f, Font.ITALIC, BaseColor.BLACK.darker().darker().darker());
        Font fontConteudo_acess = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI,
                BaseFont.EMBEDDED, 5f, Font.NORMAL, BaseColor.BLUE.darker().darker());

        PdfPCell cellAcessorio = new PdfPCell();
        Paragraph pAcessorio = new Paragraph();
        pAcessorio.add(new Phrase("Acessrios: ".toUpperCase(), fontConteudo_acess));
        pAcessorio.add(new Phrase(
                (map.get(ACCESSORIO) == null) ? " " : (map.get(ACCESSORIO) + "").replaceAll("\n", " "),
                fontConteudoTxt_acess));
        cellAcessorio.addElement(pAcessorio);
        cellAcessorio.setColspan(2);
        cellAcessorio.setBorder(0);
        cellAcessorio.setPaddingBottom(4f);
        cellAcessorio.setPaddingTop(-2f);
        pTableAssinatura.addCell(cellAcessorio);

        PdfPCell cellLinhaAssina = new PdfPCell();
        Paragraph pAssinatura = new Paragraph();
        pAssinatura.add(new Paragraph("_________________________________", fontConteudo));
        pAssinatura.add(new Paragraph("                Carimbo e Assinatura", fontConteudo));
        pAssinatura.setAlignment(Element.ALIGN_CENTER);
        cellLinhaAssina.addElement(pAssinatura);
        cellLinhaAssina.setPaddingBottom(2f);
        cellLinhaAssina.setBorder(0);
        cellLinhaAssina.setPaddingTop(25f);
        pTableAssinatura.addCell(cellLinhaAssina);

        PdfPCell cellCambio = new PdfPCell();
        Paragraph pCombio = new Paragraph();
        pCombio.add(new Phrase("Cambio (USD): ".toUpperCase(), fontConteudo));
        pCombio.add(new Phrase(converterMoeda(valorCompra("USD", dRegistro), "") + "\n", fontConteudoTxt));
        pCombio.add(new Phrase("Cambio (EUR): ".toUpperCase(), fontConteudo));
        pCombio.add(new Phrase(converterMoeda(valorCompra("EUR", dRegistro), "") + "\n", fontConteudoTxt));
        cellCambio.addElement(pCombio);
        cellCambio.setBorder(0);
        cellCambio.setPaddingTop(-2f);
        cellCambio.setPaddingBottom(2f);
        pTableAssinatura.addCell(cellCambio);

        PdfPCell cellpTableAssinaturaPrincipal = new PdfPCell(pTableAssinatura);
        cellpTableAssinaturaPrincipal.setBorder(PdfPCell.NO_BORDER);
        pTablePrincipal.addCell(new PdfPCell(cellpTableAssinaturaPrincipal));

        //            pTableAssinatura.writeSelectedRows(-1, 2, 10, 70, writer.getDirectContent());
        //            pTableImagem.writeSelectedRows(-1, 2, 52.5f, 402.5f, writer.getDirectContent());
    } catch (BadElementException | IOException ex) {
        Logger.getLogger(ReciboPagamento.class.getName()).log(Level.SEVERE, null, ex);
    }
    return pTablePrincipal;
}

From source file:femr.ui.controllers.PDFController.java

License:Open Source License

/**
 * Builds the page header - Title and Empty cell (for border)
 *
 * @return PdfPTable the itext table to add to the document
 *//* www .  j a  va  2  s  .co m*/
public PdfPTable createHeaderTable() {

    PdfPTable table = new PdfPTable(2);
    table.setSpacingAfter(10);
    table.setWidthPercentage(100);

    Paragraph title = new Paragraph("Medical Record", new Font(Font.FontFamily.TIMES_ROMAN, 18, Font.BOLD));
    PdfPCell cell = new PdfPCell(title);
    cell.setVerticalAlignment(Element.ALIGN_BOTTOM);
    cell.setBorder(PdfPCell.NO_BORDER);
    cell.setBorderColorBottom(BaseColor.BLACK);
    cell.setBorderWidthBottom(1);
    cell.setPaddingBottom(5);
    table.addCell(cell);

    //Paragraph encounterId = new Paragraph("Encounter ID: " + patientEncounter.getId(), new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.NORMAL));
    cell = new PdfPCell(table.getDefaultCell());
    cell.setVerticalAlignment(Element.ALIGN_BOTTOM);
    cell.setBorder(PdfPCell.NO_BORDER);
    cell.setBorderColorBottom(BaseColor.BLACK);
    cell.setBorderWidthBottom(1);
    cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
    cell.setPaddingBottom(5);
    table.addCell(cell);

    return table;
}

From source file:fenix.planner.pdf.PDFGenerator.java

License:Open Source License

private void addPageNumbers(PdfReader reader, PdfCopy copy) {
    int pageCount = reader.getNumberOfPages();
    PdfImportedPage page;//from  w  ww. ja v  a2 s .com
    PdfCopy.PageStamp stamp;

    for (int i = 1; i <= pageCount; ++i) {
        Rectangle rect = reader.getBoxSize(i, "art");
        page = copy.getImportedPage(reader, i);
        stamp = copy.createPageStamp(page);
        // add page numbers
        ColumnText.showTextAligned(stamp.getUnderContent(), Element.ALIGN_RIGHT,
                new Phrase(String.format("%d / %d", i, pageCount), footerFont), rect.getRight(),
                rect.getBottom() + 5, 0);
        try {
            stamp.alterContents();
            copy.addPage(page);
        } catch (BadPdfFormatException | IOException ex) {
            throw new PDFGenerationException("Error adding page number to page " + i, ex);
        }
    }
}

From source file:file.PDFWriter.java

License:Open Source License

/**
 * Make the initial header to the PDF, with the date and character
 * @throws DocumentException/* w w w .  j av  a  2s.  c  o m*/
 */
public void makePDFHeader() throws DocumentException {
    PdfPTable headerTable = new PdfPTable(2);
    headerTable.setWidthPercentage(100);

    PdfPCell dateCell = new PdfPCell(new Paragraph(
            "Date: " + date.monthOfYear().getAsString() + "/" + date.dayOfMonth().getAsString(), lineFont));
    dateCell.setHorizontalAlignment(Element.ALIGN_LEFT);
    dateCell.setBorder(PdfPCell.NO_BORDER);
    dateCell.setPadding(0.3f);
    PdfPCell characterCell = new PdfPCell(new Paragraph("Character: " + role.getName(), lineFont));
    characterCell.setHorizontalAlignment(Element.ALIGN_RIGHT);
    characterCell.setBorder(PdfPCell.NO_BORDER);

    headerTable.addCell(dateCell);
    headerTable.addCell(characterCell);
    document.add(headerTable);
    document.add(Chunk.NEWLINE);
    document.add(Chunk.NEWLINE);
}

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

License:Open Source License

public void writeFile(final OutputStream out, final boolean orientationIsPortrait) throws DocumentException {

    // This creates our new PDF document and declares its orientation
    Document pdfDoc;//ww  w. j  a  v  a 2s  . co m
    if (orientationIsPortrait) {
        pdfDoc = new Document(PageSize.LETTER); // portrait
    } else {
        pdfDoc = new Document(PageSize.LETTER.rotate()); // landscape
    }
    PdfWriter.getInstance(pdfDoc, out);

    // Measurements are always in points (72 per inch)
    // This sets up 1/2 inch margins side margins and 0.35in top and bottom
    // margins
    pdfDoc.setMargins(0.5f * POINTS_PER_INCH, 0.5f * POINTS_PER_INCH, 0.35f * POINTS_PER_INCH,
            0.35f * POINTS_PER_INCH);
    pdfDoc.open();

    // Header cell with challenge title to add to both scoresheets
    final Paragraph titleParagraph = new Paragraph();
    final Chunk titleChunk = new Chunk(m_pageTitle,
            FontFactory.getFont(FontFactory.HELVETICA_BOLD, 14, Font.NORMAL, BaseColor.WHITE));
    titleParagraph.setAlignment(Element.ALIGN_CENTER);
    titleParagraph.add(titleChunk);

    titleParagraph.add(Chunk.NEWLINE);
    final Chunk swVersionChunk = new Chunk("SW version: " + Version.getVersion(),
            FontFactory.getFont(FontFactory.HELVETICA, 8, Font.NORMAL, BaseColor.WHITE));
    titleParagraph.add(swVersionChunk);
    if (null != m_revision) {

        final Chunk revisionChunk = new Chunk(" Descriptor revision: " + m_revision,
                FontFactory.getFont(FontFactory.HELVETICA, 8, Font.NORMAL, BaseColor.WHITE));

        titleParagraph.add(revisionChunk);
    }

    final PdfPCell head = new PdfPCell();
    head.setColspan(2);
    head.setBorder(1);
    head.setPaddingTop(0);
    head.setPaddingBottom(3);
    head.setBackgroundColor(new BaseColor(64, 64, 64));
    head.setVerticalAlignment(Element.ALIGN_TOP);
    head.addElement(titleParagraph);

    // Cells for score field, and 2nd check initials
    final Phrase des = new Phrase("Data Entry Score _______", ARIAL_8PT_NORMAL);
    final PdfPCell desC = new PdfPCell(des);
    desC.setBorder(0);
    desC.setPaddingTop(9);
    desC.setPaddingRight(36);
    desC.setHorizontalAlignment(Element.ALIGN_RIGHT);
    final Phrase sci = new Phrase("2nd Check Initials _______", ARIAL_8PT_NORMAL);
    final PdfPCell sciC = new PdfPCell(sci);
    sciC.setBorder(0);
    sciC.setPaddingTop(9);
    sciC.setPaddingRight(36);
    sciC.setHorizontalAlignment(Element.ALIGN_RIGHT);

    // Create a table with a grid cell for each scoresheet on the page
    PdfPTable wholePage = getTableForPage(orientationIsPortrait);
    wholePage.setWidthPercentage(100);
    for (int i = 0; i < m_numSheets; i++) {
        if (i > 0 && (orientationIsPortrait || (i % 2) == 0)) {
            pdfDoc.newPage();
            wholePage = getTableForPage(orientationIsPortrait);
            wholePage.setWidthPercentage(100);
        }

        // This table is a single score sheet
        final PdfPTable scoreSheet = new PdfPTable(2);
        // scoreSheet.getDefaultCell().setBorder(Rectangle.LEFT | Rectangle.BOTTOM
        // | Rectangle.RIGHT | Rectangle.TOP); //FIXME DEBUG should be NO_BORDER
        scoreSheet.getDefaultCell().setBorder(Rectangle.NO_BORDER);
        scoreSheet.getDefaultCell().setPaddingRight(1);
        scoreSheet.getDefaultCell().setPaddingLeft(0);

        scoreSheet.addCell(head);

        final PdfPTable teamInfo = new PdfPTable(7);
        teamInfo.setWidthPercentage(100);
        teamInfo.setWidths(new float[] { 1f, 1f, 1f, 1f, 1f, 1f, .9f });

        // Time label cell
        final Paragraph timeP = new Paragraph("Time:", ARIAL_10PT_NORMAL);
        timeP.setAlignment(Element.ALIGN_RIGHT);
        final PdfPCell timeLc = new PdfPCell(scoreSheet.getDefaultCell());
        timeLc.addElement(timeP);
        teamInfo.addCell(timeLc);
        // Time value cell
        final Paragraph timeV = new Paragraph(null == m_time[i] ? SHORT_BLANK : m_time[i], COURIER_10PT_NORMAL);
        final PdfPCell timeVc = new PdfPCell(scoreSheet.getDefaultCell());
        timeVc.addElement(timeV);
        teamInfo.addCell(timeVc);

        // Table label cell
        final Paragraph tblP = new Paragraph("Table:", ARIAL_10PT_NORMAL);
        tblP.setAlignment(Element.ALIGN_RIGHT);
        final PdfPCell tblLc = new PdfPCell(scoreSheet.getDefaultCell());
        tblLc.addElement(tblP);
        teamInfo.addCell(tblLc);
        // Table value cell
        final Paragraph tblV = new Paragraph(m_table[i], COURIER_10PT_NORMAL);
        final PdfPCell tblVc = new PdfPCell(scoreSheet.getDefaultCell());
        tblVc.addElement(tblV);
        teamInfo.addCell(tblVc);

        // Round number label cell
        final Paragraph rndP = new Paragraph("Round:", ARIAL_10PT_NORMAL);
        rndP.setAlignment(Element.ALIGN_RIGHT);
        final PdfPCell rndlc = new PdfPCell(scoreSheet.getDefaultCell());
        rndlc.addElement(rndP);
        teamInfo.addCell(rndlc);
        // Round number value cell
        final Paragraph rndV = new Paragraph(m_round[i], COURIER_10PT_NORMAL);
        final PdfPCell rndVc = new PdfPCell(scoreSheet.getDefaultCell());
        // rndVc.setColspan(2);
        rndVc.addElement(rndV);
        teamInfo.addCell(rndVc);

        final PdfPCell temp1 = new PdfPCell(scoreSheet.getDefaultCell());
        // temp1.setColspan(2);
        temp1.addElement(new Paragraph("Judge ____", ARIAL_8PT_NORMAL));
        teamInfo.addCell(temp1);

        // Team number label cell
        final Paragraph nbrP = new Paragraph("Team #:", ARIAL_10PT_NORMAL);
        nbrP.setAlignment(Element.ALIGN_RIGHT);
        final PdfPCell nbrlc = new PdfPCell(scoreSheet.getDefaultCell());
        nbrlc.addElement(nbrP);
        teamInfo.addCell(nbrlc);
        // Team number value cell
        final Paragraph nbrV = new Paragraph(null == m_number[i] ? SHORT_BLANK : String.valueOf(m_number[i]),
                COURIER_10PT_NORMAL);
        final PdfPCell nbrVc = new PdfPCell(scoreSheet.getDefaultCell());
        nbrVc.addElement(nbrV);
        teamInfo.addCell(nbrVc);

        // Team division label cell
        final Paragraph divP = new Paragraph(m_divisionLabel[i], ARIAL_10PT_NORMAL);
        divP.setAlignment(Element.ALIGN_RIGHT);
        final PdfPCell divlc = new PdfPCell(scoreSheet.getDefaultCell());
        divlc.addElement(divP);
        divlc.setColspan(2);
        teamInfo.addCell(divlc);
        // Team division value cell
        final Paragraph divV = new Paragraph(m_division[i], COURIER_10PT_NORMAL);
        final PdfPCell divVc = new PdfPCell(scoreSheet.getDefaultCell());
        divVc.setColspan(2);
        divVc.addElement(divV);
        teamInfo.addCell(divVc);

        final PdfPCell temp2 = new PdfPCell(scoreSheet.getDefaultCell());
        // temp2.setColspan(2);
        temp2.addElement(new Paragraph("Team ____", ARIAL_8PT_NORMAL));
        teamInfo.addCell(temp2);

        // Team name label cell
        final Paragraph nameP = new Paragraph("Team Name:", ARIAL_10PT_NORMAL);
        nameP.setAlignment(Element.ALIGN_RIGHT);
        final PdfPCell namelc = new PdfPCell(scoreSheet.getDefaultCell());
        namelc.setColspan(2);
        namelc.addElement(nameP);
        teamInfo.addCell(namelc);
        // Team name value cell
        final Paragraph nameV = new Paragraph(m_name[i], COURIER_10PT_NORMAL);
        final PdfPCell nameVc = new PdfPCell(scoreSheet.getDefaultCell());
        nameVc.setColspan(5);
        nameVc.addElement(nameV);
        teamInfo.addCell(nameVc);

        // add team info cell to the team table
        final PdfPCell teamInfoCell = new PdfPCell(scoreSheet.getDefaultCell());
        teamInfoCell.addElement(teamInfo);
        teamInfoCell.setColspan(2);

        scoreSheet.addCell(teamInfoCell);

        if (null != m_goalsTable) {
            final PdfPCell goalCell = new PdfPCell(m_goalsTable);
            goalCell.setBorder(0);
            goalCell.setPadding(0);
            goalCell.setColspan(2);
            scoreSheet.addCell(goalCell);
        }

        scoreSheet.addCell(desC);
        scoreSheet.addCell(sciC);

        if (null != m_copyright) {
            final Phrase copyright = new Phrase("\u00A9" + m_copyright, f6i);
            final PdfPCell copyrightC = new PdfPCell(scoreSheet.getDefaultCell());
            copyrightC.addElement(copyright);
            copyrightC.setBorder(0);
            copyrightC.setHorizontalAlignment(Element.ALIGN_CENTER);
            copyrightC.setColspan(2);

            scoreSheet.addCell(copyrightC);
        }

        // the cell in the whole page table that will contain the single score
        // sheet
        final PdfPCell scoresheetCell = new PdfPCell(scoreSheet);
        scoresheetCell.setBorder(0);
        scoresheetCell.setPadding(0);

        // Interior borders between scoresheets on a page
        if (!orientationIsPortrait) {
            if (i % 2 == 0) {
                scoresheetCell.setPaddingRight(0.1f * POINTS_PER_INCH);
            } else {
                scoresheetCell.setPaddingLeft(0.1f * POINTS_PER_INCH);
            }
        }

        // Add the current scoresheet to the page
        wholePage.addCell(scoresheetCell);

        // Add the current table of scoresheets to the document
        if (orientationIsPortrait || (i % 2 != 0)) {
            pdfDoc.add(wholePage);
        }
    }

    // Add a blank cells to complete the table of the last page
    if (!orientationIsPortrait && m_numSheets % 2 != 0) {
        final PdfPCell blank = new PdfPCell();
        blank.setBorder(0);
        wholePage.addCell(blank);
        pdfDoc.add(wholePage);
    }

    pdfDoc.close();
}

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./*ww w  . ja  v a2  s  .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:fr.pigouchet.gestion.util.GeneratePdf.java

public static PdfPTable getHeaderTable(int x, int y) {
    PdfPTable table = new PdfPTable(2);
    table.setTotalWidth(527);/*from  w  ww .  ja  v a  2  s .  c  o  m*/
    table.setLockedWidth(true);
    table.getDefaultCell().setFixedHeight(20);
    table.getDefaultCell().setBorder(Rectangle.BOTTOM);
    table.addCell("FOOBAR FILMFESTIVAL");
    table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);
    table.addCell(String.format("Page %d of %d", x, y));
    return table;
}

From source file:Functions.pdf_Export.java

private void createFooter(Document doc, HoaDon hoaDon, NhanVien nv, KhachHang kh) {
    try {//from  w w w  . jav  a 2 s .  co m
        String total = new DecimalFormat("#,###").format(hoaDon.getTongTien());
        Paragraph paragraph = new Paragraph();
        paragraph.add(new Phrase("Total: " + total + " (VND)", smallFont));
        paragraph.setAlignment(Element.ALIGN_RIGHT);
        addEmptyLine(paragraph, 3);
        doc.add(paragraph);

        PdfPTable table = new PdfPTable(2);
        PdfPCell cell = new PdfPCell(new Phrase("Sale Staff", subFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBorder(0);
        table.addCell(cell);
        cell.setPhrase(new Phrase("Customer", subFont));
        table.addCell(cell);
        // add 3 blank row
        for (Integer i = 0; i < 10; i++) {
            cell.setPhrase(new Phrase(" "));
            table.addCell(cell);
        }
        cell.setPhrase(new Phrase(nv.getHoTenNhanVien(), smallFont));
        table.addCell(cell);
        cell.setPhrase(new Phrase(kh.getHoTenKH(), smallFont));
        table.addCell(cell);
        doc.add(table);

        paragraph = new Paragraph();
        addEmptyLine(paragraph, 5);
        paragraph.add(new Phrase(
                "Bill generated by: " + nv.getHoTenNhanVien() + " - " + nv.getMaNhanVien() + ", " + new Date(),
                italicFont));
        doc.add(paragraph);
    } catch (DocumentException ex) {
        Logger.getLogger(pdf_Export.class.getName()).log(Level.SEVERE, null, ex);
    }
}