Example usage for com.itextpdf.text Element ALIGN_TOP

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

Introduction

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

Prototype

int ALIGN_TOP

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

Click Source Link

Document

A possible value for vertical alignment.

Usage

From source file:com.softwaremagico.tm.pdf.small.skills.LearnedSkillsTable.java

License:Open Source License

private static PdfPCell getSkillsColumnTable(CharacterPlayer characterPlayer, String language)
        throws InvalidXmlElementException {
    float[] widths = { 4f, 1f };
    PdfPTable table = new PdfPTable(widths);
    setTablePropierties(table);//ww w .ja  va 2s.c  o m
    table.getDefaultCell().setBorder(0);

    table.addCell(createCompactTitle(getTranslator().getTranslatedText("learnedSkills"),
            FadingSunsTheme.CHARACTER_SMALL_SKILLS_TITLE_FONT_SIZE));

    int added = 0;
    if (characterPlayer != null) {
        for (AvailableSkill skill : characterPlayer.getLearnedSkills()) {
            if (characterPlayer.getSkillTotalRanks(skill) > 0) {
                table.addCell(createSkillElement(characterPlayer, skill,
                        FadingSunsTheme.CHARACTER_SMALL_SKILLS_LINE_FONT_SIZE, MAX_SKILL_COLUMN_WIDTH));
                table.addCell(createSkillValue(characterPlayer.getSkillTotalRanks(skill),
                        characterPlayer.isSkillSpecial(skill)
                                || characterPlayer.hasSkillTemporalModificator(skill),
                        characterPlayer.hasSkillModificator(skill),
                        FadingSunsTheme.CHARACTER_SMALL_SKILLS_LINE_FONT_SIZE));
                added++;
            }
        }
    }

    if (characterPlayer == null) {
        for (int i = added; i < ROWS; i++) {
            table.addCell(CustomPdfTable.createEmptyElementLine(GAP, MAX_SKILL_COLUMN_WIDTH));
            table.addCell(CustomPdfTable.createEmptyElementLine(GAP, MAX_SKILL_RANK_WIDTH));
        }
    } else {
        for (int i = added; i < ROWS; i++) {
            table.addCell(CustomPdfTable.createEmptyElementLine(" ", MAX_SKILL_COLUMN_WIDTH));
            table.addCell(CustomPdfTable.createEmptyElementLine(" ", MAX_SKILL_RANK_WIDTH));
        }
    }

    PdfPCell cell = new PdfPCell();
    setCellProperties(cell);

    cell.addElement(table);
    cell.setVerticalAlignment(Element.ALIGN_TOP);
    return cell;
}

From source file:com.softwaremagico.tm.pdf.small.skills.NaturalSkillsTable.java

License:Open Source License

private static PdfPCell getSkillsColumnTable(CharacterPlayer characterPlayer, String language)
        throws InvalidXmlElementException {
    float[] widths = { 4f, 1f };
    PdfPTable table = new PdfPTable(widths);
    setTablePropierties(table);//from   ww  w .j a  v  a 2  s  . c o m
    table.getDefaultCell().setBorder(0);

    table.addCell(createCompactTitle(getTranslator().getTranslatedText("naturalSkills"),
            FadingSunsTheme.CHARACTER_SMALL_SKILLS_TITLE_FONT_SIZE));

    if (characterPlayer == null) {
        for (AvailableSkill skill : AvailableSkillsFactory.getInstance().getNaturalSkills(language)) {
            table.addCell(createSkillElement(null, skill, FadingSunsTheme.CHARACTER_SMALL_SKILLS_LINE_FONT_SIZE,
                    MAX_SKILL_COLUMN_WIDTH));
            table.addCell(
                    createSkillLine(SKILL_VALUE_GAP, FadingSunsTheme.CHARACTER_SMALL_SKILLS_LINE_FONT_SIZE));
        }
    } else {
        for (AvailableSkill skill : characterPlayer.getNaturalSkills()) {
            table.addCell(createSkillElement(characterPlayer, skill,
                    FadingSunsTheme.CHARACTER_SMALL_SKILLS_LINE_FONT_SIZE, MAX_SKILL_COLUMN_WIDTH));
            table.addCell(createSkillValue(characterPlayer.getSkillTotalRanks(skill),
                    characterPlayer.isSkillSpecial(skill) || characterPlayer.hasSkillTemporalModificator(skill),
                    characterPlayer.hasSkillModificator(skill),
                    FadingSunsTheme.CHARACTER_SMALL_SKILLS_LINE_FONT_SIZE));
        }
    }

    PdfPCell cell = new PdfPCell();
    setCellProperties(cell);

    cell.addElement(table);
    cell.setVerticalAlignment(Element.ALIGN_TOP);
    return cell;
}

From source file:com.softwaremagico.tm.pdf.small.SmallPartySheet.java

License:Open Source License

private void initializeTableContent() {
    float[] widths = { 1f, 1f };
    mainTable = new PdfPTable(widths);
    BaseElement.setTablePropierties(mainTable);
    mainTable.getDefaultCell().setVerticalAlignment(Element.ALIGN_TOP);
    mainTable.getDefaultCell().setBorderWidth(2);
    mainTable.getDefaultCell().setPadding(0);
}

From source file:com.udec.utilidades.PdfTable.java

public PdfPTable tabla3(List<Nomina> no) throws DocumentException {
    //Instanciamos una tabla de 3 columnas
    PdfPTable tabla = new PdfPTable(4);
    tabla.setWidthPercentage(100);//from  w  w w . j  av a2  s.  c om
    tabla.setWidths(new float[] { 1, 3, 1, 1 });
    //Declaramos un objeto para manejar las celdas
    PdfPCell celda;
    celda = new PdfPCell(new Phrase("CODIGO"));
    celda.setHorizontalAlignment(Element.ALIGN_JUSTIFIED);
    celda.setBorder(Rectangle.BOTTOM);
    celda.setVerticalAlignment(Element.ALIGN_TOP);
    celda.setBorderWidth(1);
    tabla.addCell(celda);
    celda = new PdfPCell(new Phrase("DESCRIPCION"));
    celda.setBorder(Rectangle.BOTTOM);
    celda.setVerticalAlignment(Element.ALIGN_TOP);
    celda.setBorderWidth(1);
    celda.setHorizontalAlignment(Element.ALIGN_JUSTIFIED);
    tabla.addCell(celda);
    celda = new PdfPCell(new Phrase("VLR.DEVEN"));
    celda.setBorder(Rectangle.BOTTOM);
    celda.setVerticalAlignment(Element.ALIGN_TOP);
    celda.setBorderWidth(1);
    celda.setHorizontalAlignment(Element.ALIGN_JUSTIFIED);
    celda.setBorderWidth(1);
    celda.setVerticalAlignment(Element.ALIGN_TOP);
    tabla.addCell(celda);
    celda = new PdfPCell(new Phrase("VLR.DEDUC"));
    celda.setBorder(Rectangle.BOTTOM);
    celda.setVerticalAlignment(Element.ALIGN_TOP);
    celda.setBorderWidth(1);
    celda.setHorizontalAlignment(Element.ALIGN_JUSTIFIED);
    tabla.addCell(celda);
    double totalDev = 0, totalDed = 0;
    for (Nomina nomina : no) {
        celda = new PdfPCell(new Phrase("" + nomina.getConceptoIdconcepto().getCodigo()));
        celda.setBorder(Rectangle.NO_BORDER);
        celda.setHorizontalAlignment(Element.ALIGN_JUSTIFIED);
        tabla.addCell(celda);
        celda = new PdfPCell(new Phrase("" + nomina.getConceptoIdconcepto().getConcepto()));
        celda.setBorder(Rectangle.NO_BORDER);
        celda.setHorizontalAlignment(Element.ALIGN_JUSTIFIED);
        tabla.addCell(celda);
        if (nomina.getConceptoIdconcepto().getTipo().equals("DEVENGADO")) {
            totalDev += nomina.getValor();
            celda = new PdfPCell(new Phrase("" + nomina.getValor()));
            celda.setBorder(Rectangle.NO_BORDER);
            celda.setHorizontalAlignment(Element.ALIGN_RIGHT);
            tabla.addCell(celda);
        } else {
            celda = new PdfPCell(new Phrase(""));
            celda.setBorder(Rectangle.NO_BORDER);
            tabla.addCell(celda);
        }
        if (nomina.getConceptoIdconcepto().getTipo().equals("DEDUCIDO")) {
            totalDed += nomina.getValor();
            celda = new PdfPCell(new Phrase("" + nomina.getValor()));
            celda.setBorder(Rectangle.NO_BORDER);
            celda.setHorizontalAlignment(Element.ALIGN_RIGHT);
            tabla.addCell(celda);
        } else {
            celda = new PdfPCell(new Phrase(""));
            celda.setBorder(Rectangle.NO_BORDER);
            tabla.addCell(celda);
        }

    }

    celda = new PdfPCell(new Phrase(""));
    celda.setBorder(Rectangle.NO_BORDER);
    tabla.addCell(celda);
    celda = new PdfPCell(new Phrase("TOTALES"));
    celda.setBorder(Rectangle.NO_BORDER);
    tabla.addCell(celda);
    celda = new PdfPCell(new Phrase("" + totalDev));
    celda.setHorizontalAlignment(Element.ALIGN_RIGHT);
    celda.setBorder(Rectangle.TOP);
    tabla.addCell(celda);
    celda = new PdfPCell(new Phrase(" " + totalDed));
    celda.setHorizontalAlignment(Element.ALIGN_RIGHT);
    celda.setBorder(Rectangle.TOP);
    tabla.addCell(celda);
    celda = new PdfPCell(new Phrase(""));
    celda.setBorder(Rectangle.NO_BORDER);
    tabla.addCell(celda);
    celda = new PdfPCell(new Phrase("NETO A PAGAR"));
    celda.setBorder(Rectangle.NO_BORDER);
    tabla.addCell(celda);
    celda = new PdfPCell(new Phrase(" " + (totalDev - totalDed)));
    celda.setBorder(Rectangle.NO_BORDER);
    celda.setHorizontalAlignment(Element.ALIGN_RIGHT);
    tabla.addCell(celda);
    celda = new PdfPCell(new Phrase(" "));
    celda.setBorder(Rectangle.NO_BORDER);
    tabla.addCell(celda);

    return tabla;
}

From source file:Export.DocNotaDebito.java

@SuppressWarnings({ "CallToPrintStackTrace", "null", "UnusedAssignment" })
public String docSeguros(String nomeSeguro, String numApolice, String interCodVendedor, String idCliente,
        String fundoContrato, ArrayList<String[]> listaValores, Contrato contrato, String user, String moeda,
        String arquivo, String numeroRegistro) {
    String reString;/* w  ww.j a  va 2s  .  com*/
    try {

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        pTableEmpresaInforImpres4.addCell(cellTabela1);

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

        pTableEmpresaInforImpres4.addCell(cellTabela2);

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

        pTableEmpresaInforImpres5.addCell(cellTabela3);

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

        pTableEmpresaInforImpres5.addCell(cellTabela4);

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

        pTableEmpresaPricipal.addCell(cellTabela5);

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

        pTableEmpresaPricipal.addCell(cellTabela6);

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        pTableData.addCell(cellData);

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

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

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

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

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

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

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

    return "";
}

From source file:Export.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 {// ww w.  j av  a2  s .  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: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;//from  w ww  . ja va 2s . c  om
    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./*  w w w .j a  v a  2  s. c  om*/
 */
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:gov.utah.dts.det.ccl.actions.trackingrecordscreening.letters.reports.LivescanAuthorization.java

private static void generateDocumentPage1(TrackingRecordScreeningLetter screeningLetter, Document document,
        PdfWriter writer) throws BadElementException, DocumentException, Exception {
    PdfPTable table = null;//from   w ww.java2 s  .  c  o m
    int headerwidths[] = {};
    Paragraph paragraph = null;
    List blist = null;
    ListItem item = null;
    ListItem subItem = null;
    SimpleDateFormat df = new SimpleDateFormat("MM/dd/yyyy");

    // LS Authorization Letter Page 1
    addLetterIdentifier(screeningLetter, document);

    paragraph = new Paragraph(fixedLeadingLarge);
    paragraph.add(new Phrase("Office of Licensing Authorization", largefontB));
    paragraph.setAlignment(Element.ALIGN_CENTER);
    document.add(paragraph);

    paragraph = new Paragraph(fixedLeadingLarge);
    paragraph.add(new Phrase("for Electronic Background Check", largefontB));
    paragraph.setAlignment(Element.ALIGN_CENTER);
    document.add(paragraph);

    paragraph = new Paragraph(fixedLeadingLarge);
    paragraph.add(new Phrase(df.format(screeningLetter.getLetterDate()), mediumfontB));
    paragraph.setAlignment(Element.ALIGN_CENTER);
    document.add(paragraph);

    paragraph = new Paragraph(fixedLeadingMedium);
    paragraph.add(new Phrase("Office of Licensing Information", mediumfontU));
    paragraph.setSpacingBefore(page1SeparatorSpace);
    document.add(paragraph);

    paragraph = new Paragraph(fixedLeadingSmall);
    paragraph.add(new Phrase("Type of Background Check Required and Agency Billing Code:", smallfont));
    paragraph.setSpacingBefore(page1SeparatorSpace);
    document.add(paragraph);

    /*
     * Start of Billing information line generation
     */
    table = new PdfPTable(3);
    // format the table
    headerwidths = new int[] { 20, 45, 35 }; // percentage
    table.setWidths(headerwidths); // percentage
    table.setWidthPercentage(100);
    table.setSpacingBefore(page1SeparatorSpace);
    table.getDefaultCell().setPadding(0);
    table.getDefaultCell().setBorder(Rectangle.NO_BORDER);
    table.getDefaultCell().setVerticalAlignment(Element.ALIGN_TOP);
    table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);

    // Add Billing Code
    if (screeningLetter.getTrackingRecordScreening().getTrsDpsFbi() != null
            && screeningLetter.getTrackingRecordScreening().getTrsDpsFbi().getBilling() != null
            && StringUtils.isNotBlank(
                    screeningLetter.getTrackingRecordScreening().getTrsDpsFbi().getBilling().getValue())) {
        table.addCell(
                new Phrase(screeningLetter.getTrackingRecordScreening().getTrsDpsFbi().getBilling().getValue(),
                        xlargefontB));
    } else {
        table.addCell(new Phrase(" ", xlargefontB));
    }

    // Add Fee information
    paragraph = new Paragraph(fixedLeadingSmall);
    paragraph.add(new Phrase("Search Fee = ", smallfont));
    if (screeningLetter.getTrackingRecordScreening().getTrsDpsFbi() != null
            && screeningLetter.getTrackingRecordScreening().getTrsDpsFbi().getSearchFee() != null) {
        paragraph.add(new Phrase(
                CommonUtils.fromDoubleToCurrency(
                        screeningLetter.getTrackingRecordScreening().getTrsDpsFbi().getSearchFee()),
                smallfontB));
    } else {
        paragraph.add(SMALL_BLANK);
    }
    paragraph.add(new Phrase(" /  Scan Fee = ", smallfont));
    if (screeningLetter.getTrackingRecordScreening().getTrsDpsFbi() != null
            && screeningLetter.getTrackingRecordScreening().getTrsDpsFbi().getScanFee() != null) {
        paragraph
                .add(new Phrase(
                        CommonUtils.fromDoubleToCurrency(
                                screeningLetter.getTrackingRecordScreening().getTrsDpsFbi().getScanFee()),
                        smallfontB));
    }
    table.addCell(paragraph);

    // Add Facility Type information
    table.addCell(new Phrase("Licensed Treatment Programs", smallfont));
    // Add Billing Information Line Table to document
    document.add(table);
    /*
     * End of Billing information line table generation
     */

    // Add Check Number document line
    paragraph = new Paragraph(fixedLeadingSmall);
    paragraph.add(new Phrase("Check Number  ", smallfont));
    if (screeningLetter.getTrackingRecordScreening().getTrsDpsFbi() != null && StringUtils
            .isNotBlank(screeningLetter.getTrackingRecordScreening().getTrsDpsFbi().getMoNumber())) {
        paragraph.add(new Phrase(screeningLetter.getTrackingRecordScreening().getTrsDpsFbi().getMoNumber(),
                smallfontB));
    }
    paragraph.setSpacingBefore(page1SeparatorSpace);
    document.add(paragraph);

    /*
     * Start of Check Issuer information line
     */
    table = new PdfPTable(2);
    // format the table
    headerwidths = new int[] { 40, 60 }; // percentage
    table.setWidths(headerwidths); // percentage
    table.setWidthPercentage(100);
    table.setSpacingBefore(page1SeparatorSpace);
    table.getDefaultCell().setPadding(0);
    table.getDefaultCell().setBorder(Rectangle.NO_BORDER);
    table.getDefaultCell().setVerticalAlignment(Element.ALIGN_TOP);
    table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);

    // Add Issuer information
    paragraph = new Paragraph(fixedLeadingSmall);
    paragraph.add(new Phrase("Issuer  ", smallfont));
    if (screeningLetter.getTrackingRecordScreening().getTrsDpsFbi() != null && StringUtils
            .isNotBlank(screeningLetter.getTrackingRecordScreening().getTrsDpsFbi().getIssuedBy())) {
        paragraph.add(new Phrase(screeningLetter.getTrackingRecordScreening().getTrsDpsFbi().getIssuedBy(),
                smallfontB));
    }
    table.addCell(paragraph);

    // Add Program Name information
    paragraph = new Paragraph(fixedLeadingSmall);
    paragraph.add(new Phrase("Program Name  ", smallfont));
    if (screeningLetter.getTrackingRecordScreening().getFacility() != null
            && StringUtils.isNotBlank(screeningLetter.getTrackingRecordScreening().getFacility().getName())) {
        paragraph.add(
                new Phrase(screeningLetter.getTrackingRecordScreening().getFacility().getName(), smallfontB));
    }
    table.addCell(paragraph);
    // Add the Check Issuer table to the document
    document.add(table);
    /*
     * End of Check Issuer information line
     */

    /*
     * Start of Applicant information line generation
     */
    table = new PdfPTable(3);
    // format the table
    headerwidths = new int[] { 43, 20, 37 }; // percentage
    table.setWidths(headerwidths); // percentage
    table.setWidthPercentage(100);
    table.setSpacingBefore(page1SeparatorSpace);
    table.getDefaultCell().setPadding(0);
    table.getDefaultCell().setBorder(Rectangle.NO_BORDER);
    table.getDefaultCell().setVerticalAlignment(Element.ALIGN_TOP);
    table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_MIDDLE);

    // Add Applicant name
    paragraph = new Paragraph(fixedLeadingSmall);
    paragraph.add(new Phrase("Applicant  ", smallfont));
    if (screeningLetter.getTrackingRecordScreening().getPerson() != null
            && StringUtils.isNotBlank(screeningLetter.getTrackingRecordScreening().getFirstAndLastName())) {
        paragraph.add(
                new Phrase(screeningLetter.getTrackingRecordScreening().getFirstAndLastName(), smallfontB));
    }
    table.addCell(paragraph);

    // Add Applicant ID
    paragraph = new Paragraph(fixedLeadingSmall);
    paragraph.add(new Phrase("ID  ", smallfont));
    if (StringUtils.isNotBlank(screeningLetter.getTrackingRecordScreening().getPersonIdentifier())) {
        paragraph.add(
                new Phrase(screeningLetter.getTrackingRecordScreening().getPersonIdentifier(), smallfontB));
    }
    table.addCell(paragraph);

    // Add DOB information
    paragraph = new Paragraph(fixedLeadingSmall);
    paragraph.add(new Phrase("DOB  ", smallfont));
    try {
        paragraph.add(
                new Phrase(df.format(screeningLetter.getTrackingRecordScreening().getBirthday()), smallfontB));
    } catch (NullPointerException e) {

    }
    table.addCell(paragraph);
    // Add Applicant Information Line Table to document
    document.add(table);
    /*
     * End of Applicant information line generation
     */

    // Add Facility Licensing Specialist Information
    paragraph = new Paragraph(fixedLeadingSmall);
    paragraph.add(new Phrase("OL Representative  ", smallfont));
    if (screeningLetter.getTrackingRecordScreening().getFacility() != null
            && screeningLetter.getTrackingRecordScreening().getFacility().getLicensingSpecialist() != null
            && StringUtils.isNotBlank(screeningLetter.getTrackingRecordScreening().getFacility()
                    .getLicensingSpecialist().getFirstAndLastName())) {
        paragraph.add(new Phrase(screeningLetter.getTrackingRecordScreening().getFacility()
                .getLicensingSpecialist().getFirstAndLastName(), smallfontB));
    }
    paragraph.setSpacingBefore(page1SeparatorSpace);
    document.add(paragraph);

    // Add Distribution Line
    paragraph = new Paragraph(fixedLeadingSmall);
    paragraph.add(new Phrase(
            "Distribution:  Original for the Applicant to turn in to the Live Scan Operator. Copy retained by Office of Licensing.",
            smallfont));
    paragraph.setSpacingBefore(page1SeparatorSpace);
    document.add(paragraph);

    // Add Program & Applicatant header line
    paragraph = new Paragraph(fixedLeadingSmall);
    paragraph.add(new Phrase("Program & Applicant Information and Instructions", smallfontBU));
    paragraph.setSpacingBefore(page1SeparatorSpace);
    document.add(paragraph);

    // Add READ THIS CAREFULLY
    paragraph = new Paragraph(fixedLeadingMedium);
    paragraph.add(new Phrase("READ THIS CAREFULLY", mediumfontB));
    paragraph.setAlignment(Element.ALIGN_CENTER);
    paragraph.setSpacingBefore(page1SeparatorSpace);
    document.add(paragraph);

    /*
     * Start of instructions list section
     */
    blist = new List(false, 20);
    item = new ListItem(fixedLeadingSmall);
    item.setListSymbol(new Chunk("1.", mediumfont));
    item.add(new Phrase(
            "The Office of Licensing authorizes the applicant to submit her/his fingerprints for an electronic applicant background check ",
            smallfont));
    item.add(new Phrase(
            "at various sites throughout Utah using the Live Scan system. Please see the enclosed list for site information. Each site ",
            smallfont));
    item.add(new Phrase(
            "charges a fee for the electronic fingerprint scan. Scanning fees vary from site to site. This is a separate fee from the ",
            smallfont));
    item.add(new Phrase(
            "one submitted to the Department of Human Services for the actual criminal background search.",
            smallfont));
    item.setSpacingBefore(page1ListSpace);
    blist.add(item);

    item = new ListItem(fixedLeadingSmall);
    item.setListSymbol(new Chunk("2.", mediumfont));
    item.add(new Phrase(
            "Complete electronic fingerprint submission within 15 days of the date of this authorization letter. If unused, ",
            smallfontB));
    item.add(new Phrase("requests for refunds will not be considered after 30 days. ", smallfontB));
    item.setSpacingBefore(page1ListSpace);
    blist.add(item);

    item = new ListItem(fixedLeadingSmall);
    item.setListSymbol(new Chunk("", smallfont));
    item.add(new Phrase(
            "Refund requests require a letter of explanation from the licensed program accompanied by this original authorization letter.",
            smallfontBU));
    item.setSpacingBefore(4.0f);
    blist.add(item);

    item = new ListItem(fixedLeadingSmall);
    item.setListSymbol(new Chunk("", smallfont));
    item.add(new Phrase(
            "Failure to complete electronic fingerprint submission within this time will result in the denial of the background screening ",
            smallfontB));
    item.add(new Phrase(
            "clearance and the applicant will not be permitted to have direct access to children or vulnerable adults, will not be eligible ",
            smallfontB));
    item.add(new Phrase(
            "to provide services to programs licensed by the Utah Department of Human Services, Office of Licensing, and will not be ",
            smallfontB));
    item.add(new Phrase("eligible to proceed with foster care or adoption.", smallfontB));
    item.setSpacingBefore(4.0f);
    blist.add(item);

    item = new ListItem(fixedLeadingSmall);
    item.setListSymbol(new Chunk("3.", mediumfont));
    paragraph = new Paragraph(fixedLeadingSmall);
    paragraph.add(new Phrase("You will need to take with you:", smallfont));
    item.add(paragraph);
    List subList = new List(false, 10);
    subList.setIndentationLeft(10);
    subItem = new ListItem(fixedLeadingSmall);
    subItem.add(new Phrase("This original letter. Photocopies and facsimile (FAX) copies will not be accepted.",
            smallfont));
    subList.add(subItem);
    subItem = new ListItem(fixedLeadingSmall);
    subItem.add(new Phrase(
            "Photo identification in the form of your driver license or state identification card issued by the Division of Motor Vehicles.",
            smallfont));
    subList.add(subItem);
    subItem = new ListItem(fixedLeadingSmall);
    subItem.add(new Phrase("Social Security Card", smallfont));
    subList.add(subItem);
    subItem = new ListItem(fixedLeadingSmall);
    subItem.add(
            new Phrase("Cash or check as required (see site list for acceptable form of payment).", smallfont));
    subList.add(subItem);
    item.add(subList);
    item.setSpacingBefore(page1ListSpace);
    blist.add(item);

    item = new ListItem(fixedLeadingSmall);
    item.setListSymbol(new Chunk("4.", mediumfont));
    item.add(new Phrase(
            "If the electronically submitted fingerprints are rejected, the Office of Licensing will notify the applicant/licensed program ",
            smallfont));
    item.add(new Phrase("of additional instructions for completing the nationwide background search.",
            smallfont));
    item.setSpacingBefore(page1ListSpace);
    blist.add(item);

    item = new ListItem(fixedLeadingSmall);
    item.setListSymbol(new Chunk("5.", mediumfont));
    item.add(new Phrase("Legibly print the following information for the scanning operator:", smallfont));
    item.setSpacingBefore(page1ListSpace);
    blist.add(item);

    document.add(blist);

    document.add(getPage1WriteInLine1());
    document.add(getPage1WriteInLine2());
    document.add(getPage1WriteInLine3());

    blist = new List(false, 20);
    item = new ListItem(fixedLeadingSmall);
    item.setListSymbol(new Chunk("6.", mediumfont));
    item.add(new Phrase(
            "Applicant Signature ___________________________________________________  Date ________________",
            smallfont));
    item.setSpacingBefore(page1ListSpace);
    blist.add(item);
    document.add(blist);

    paragraph = new Paragraph();
    paragraph.add(new Phrase(
            "A current list of Livescan sites is available at www.hslic.utah.gov/docs/livescan sites.pdf",
            smallfontB));
    paragraph.setAlignment(Element.ALIGN_CENTER);
    paragraph.setSpacingBefore(page1SeparatorSpace);
    document.add(paragraph);

    if (screeningLetter.getTrackingRecordScreening().getTrsDpsFbi() != null
            && screeningLetter.getTrackingRecordScreening().getTrsDpsFbi().getBilling() != null
            && StringUtils.isNotBlank(
                    screeningLetter.getTrackingRecordScreening().getTrsDpsFbi().getBilling().getValue())) {
        paragraph = new Paragraph();
        paragraph.add(
                new Phrase(screeningLetter.getTrackingRecordScreening().getTrsDpsFbi().getBilling().getValue(),
                        xlargefontB));
        paragraph.setAlignment(Element.ALIGN_RIGHT);
        paragraph.setSpacingBefore(page1SeparatorSpace);
        document.add(paragraph);
    }
    /*
     * End of instructions list section
     */
}

From source file:gov.utah.dts.det.ccl.actions.trackingrecordscreening.letters.reports.LivescanAuthorization.java

private static PdfPTable getPage1WriteInLine1() throws BadElementException, DocumentException, Exception {
    PdfPTable table = new PdfPTable(2);
    PdfPTable dtl = null;/*from   w  w  w  .j  av a2  s.c om*/

    int headerwidths[] = { 4, 96 }; // percentage
    table.setWidths(headerwidths); // percentage
    table.setWidthPercentage(100);
    table.setSpacingBefore(page1ListSpace);
    table.getDefaultCell().setPadding(0);
    table.getDefaultCell().setBorder(Rectangle.NO_BORDER);

    // Redefine the headerwidths for the detail table
    headerwidths = new int[] { 25, 25, 25, 25 }; // percentage

    dtl = new PdfPTable(4);
    dtl.setWidths(headerwidths); // percentage
    dtl.setWidthPercentage(100);
    dtl.getDefaultCell().setLeading(fixedLeadingSmall, 0);
    dtl.getDefaultCell().setPadding(0);
    dtl.getDefaultCell().setBorder(Rectangle.NO_BORDER);
    dtl.getDefaultCell().setVerticalAlignment(Element.ALIGN_BOTTOM);
    dtl.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
    dtl.getDefaultCell().setCellEvent(new FloatingLinedPdfPCell());
    dtl.addCell(SMALL_BLANK);
    dtl.addCell(SMALL_BLANK);
    dtl.addCell(SMALL_BLANK);
    dtl.addCell(SMALL_BLANK);
    table.addCell(SMALL_BLANK); // Leave first cell blank
    table.addCell(dtl);

    dtl = new PdfPTable(4);
    dtl.setWidths(headerwidths); // percentage
    dtl.setWidthPercentage(100);
    dtl.getDefaultCell().setLeading(fixedLeadingSmall, 0);
    dtl.getDefaultCell().setPadding(0);
    dtl.getDefaultCell().setBorder(Rectangle.NO_BORDER);
    dtl.getDefaultCell().setVerticalAlignment(Element.ALIGN_TOP);
    dtl.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
    dtl.getDefaultCell().setCellEvent(new FloatingPdfPCell());
    dtl.addCell(new Phrase("Last Name", smallfont));
    dtl.addCell(new Phrase("Full First Name", smallfont));
    dtl.addCell(new Phrase("Full Middle Name", smallfont));
    dtl.addCell(new Phrase("AKA", smallfont));
    table.addCell(SMALL_BLANK); // Leave first cell blank
    table.addCell(dtl);

    dtl = new PdfPTable(4);
    dtl.getDefaultCell().setLeading(fixedLeadingSmall, 0);
    dtl.getDefaultCell().setPadding(0);
    dtl.getDefaultCell().setBorder(Rectangle.NO_BORDER);
    dtl.getDefaultCell().setVerticalAlignment(Element.ALIGN_TOP);
    dtl.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
    dtl.getDefaultCell().setCellEvent(new FloatingPdfPCell());
    dtl.addCell(SMALL_BLANK);
    dtl.addCell(SMALL_BLANK);
    dtl.addCell(new Phrase("If no middle name, write NA.", smallfont));
    dtl.addCell(SMALL_BLANK);
    table.addCell(SMALL_BLANK); // Leave first cell blank
    table.addCell(dtl);

    return table;
}