Example usage for com.itextpdf.text.pdf ColumnText addText

List of usage examples for com.itextpdf.text.pdf ColumnText addText

Introduction

In this page you can find the example usage for com.itextpdf.text.pdf ColumnText addText.

Prototype

public void addText(final Chunk chunk) 

Source Link

Document

Adds a Chunk to the current text array.

Usage

From source file:com.automaster.autoview.server.servlet.LendoTemplateContratoVenda.java

public static void main(String[] args) throws IOException, DocumentException {

    //String placa = request.getParameter("placa");
    //criando map que ir adicionar as informaes do cliente
    ArrayList<TreeMap<String, String>> clienteAuxiliar = new ArrayList<TreeMap<String, String>>();
    int codCliente = Integer.parseInt("2");
    int tipoCliente = Integer.parseInt("2");
    String cpfCnpj = "53487465000185";
    // busca no BD as informaes do cliente
    ClienteDAO clienteDAO = null;// ww  w  .  j  a  v  a  2s  .c  o  m
    clienteDAO = new ClienteDAO();
    TreeMap<String, ArrayList<TreeMap<String, String>>> cliente = clienteDAO.buscarPorCodCliente(codCliente);
    //guarda no map auxiliar
    clienteAuxiliar = cliente.get(cliente.firstKey());
    //variveis de endereo do cliente 
    String logradouro = null;
    String bairro = null;
    String numero = null;
    String cidade = null;
    String cep = null;
    String uf = null;
    String nomeEstado = null;
    //busca no BD aas informaes da unidade
    UnidadeDAO unidadeDAO = new UnidadeDAO();
    int codUnidade = Integer.parseInt(clienteAuxiliar.get(0).get("codUnidade"));
    //guarda no map as informaes da unidade
    TreeMap<String, String> unidade = unidadeDAO.buscarPorCodUnidadeCompleta(codUnidade);
    //vaiveis que iro guardar as informaes da unidade
    String autoMaster = "AUTO MASTER LTDA";
    String cnpjUn = formataCNPJ(unidade.get("cnpj"));
    String cidadeUn = unidade.get("nomeCidade");
    String nomeEstadoUn = unidade.get("nomeCompletoEstado");
    String ufUn = unidade.get("nomeEstado");
    String logradouroUn = unidade.get("logradouro");
    String numeroUn = unidade.get("numero");
    String bairroUn = unidade.get("bairro");
    // pega a data atual do sistema
    Date dataAtual = new Date(System.currentTimeMillis());
    //System.out.println("Cliente auxiliar :"+clienteAuxiliar);
    //busca no BD as informaes de endereo do cliente
    TreeMap<String, String> endAuxiliar = new TreeMap<String, String>();
    int index = 0;
    for (TreeMap<String, String> ends : clienteAuxiliar) {
        if (clienteAuxiliar.get(index).get("descricaoEndereco").equalsIgnoreCase("ENDEREO DE COBRANA")
                && endAuxiliar.get(ends.get("codEndereco")) == null) {
            //System.out.println("linha 01!!");
            logradouro = ends.get("logradouro");
            bairro = ends.get("bairro");
            numero = ends.get("numeroEndereco");
            cidade = ends.get("nomeCidade");
            cep = ends.get("cep");
            uf = ends.get("estadoUf");
            nomeEstado = ends.get("nomeEstado");
            endAuxiliar.put(ends.get("codEndereco"), ends.get("codEndereco"));
            //System.out.println("Linha 02!!");
        }
        index++;
    }
    // montando a string que ir compor o cabealho do contrato
    String cab1 = "Pelo presente instrumento particular, de um lado ";
    String cab2 = autoMaster;
    String cab3 = ", atuante no setor de segurana de monitoramento de veculos, inscrita no ";
    String cab4 = "CNPJ: " + cnpjUn;
    String cab5 = " localizada na ";
    String cab6 = logradouroUn;
    String cab7 = " n ";
    String cab8 = numeroUn;
    String cab9 = ", ";
    String cab10 = bairroUn;
    String cab11 = ", ";
    String cab12 = cidadeUn;
    String cab13 = "/";
    String cab14 = ufUn;
    String cab15 = ", doravante ";
    String cab16 = "designada simplesmente ";
    String cab17 = "AUTO MASTER MONITORAMENTO";
    String cab18 = ", e de outro lado ";
    String cab19 = clienteAuxiliar.get(0).get("nomeCliente")
            + ((tipoCliente == 1) ? ", CPF: " + formataCPF(cpfCnpj) : ", CNPJ: " + formataCNPJ(cpfCnpj));
    String cab20 = " localizado a ";
    String cab21 = logradouro;
    String cab22 = ", bairro: ";
    String cab23 = bairro;
    String cab24 = ", N ";
    String cab25 = numero;
    String cab255 = ", CIDADE : ";
    String cab26 = cidade;
    String cab266 = ", CEP : ";
    String cab2661 = cep;
    String cab27 = ", adquirente do RASTREADOR PARA AUTOS AUTO MASTER, ";
    String cab28 = "doravante denominado simplesmente como CONTRATANTE, firmam o presente CONTRATO DE PRESTAO DE SERVIOS, "
            + "conforme condies e clusulas adiante mencionadas:";
    //busca no BD os veculos do cliente
    VeiculoDAO veiculoDAO = new VeiculoDAO();
    ArrayList<TreeMap<String, String>> veiculos = veiculoDAO.buscarVeiculoAtivoPorCliente(codCliente);
    //incrementa a string somente com as placas dos veculos do cliente
    String listaDePlacas = "";
    for (int i = 0; i < veiculos.size(); i++) {
        if (i == veiculos.size() - 1) {
            listaDePlacas = " " + listaDePlacas + veiculos.get(i).get("placa");
        } else {
            listaDePlacas = " " + listaDePlacas + veiculos.get(i).get("placa") + ",";
        }
    }
    String textPlacas1 = "3.1 - Os veculo(s) listado(s) a seguir, com sua(s) respectiva(s) data(s) de instalao, so identificado(s) pela(s) placa(s): ";
    String textPlacas2 = listaDePlacas;
    String textPlacas3 = ", sendo vedada a remoo do aparelho rastreador desses(s) veiculo(s), sem prvia e expressa anuncia da Contratada, "
            + "que se dar sempre por escrito, sob pena de aplicao da penalidade prevista por infrao contratual;";
    // PDF que  o template da aplicao
    PdfReader reader = new PdfReader(
            "D:\\Users\\Adriano\\Documents\\NetBeansProjects\\JRGWT\\web\\contratos\\contrato_venda.pdf");
    //PDF resultante
    PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(
            "D:\\Users\\Adriano\\Documents\\NetBeansProjects\\JRGWT\\web\\contratos\\contrato_venda01.pdf"));

    // ir adicionar na primeira pgina do PDF resultante
    PdfContentByte cabecalho = stamper.getOverContent(1);
    // cria um objeto que ir acomodar a o PdfContentByte
    ColumnText collumText = new ColumnText(cabecalho);
    // definie as configuraes de fonte para o objeto frase
    BaseFont normal = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
    BaseFont negrito = BaseFont.createFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
    //cria uma frase
    Phrase phraseCabecalho = new Phrase();
    //adiciona fonte para a frase
    phraseCabecalho.setFont(new com.itextpdf.text.Font(normal, 9.6f));
    //adiciona a string que ir compor a frase
    phraseCabecalho.add(cab1);
    //adiciona fonte para a frase
    phraseCabecalho.setFont(new com.itextpdf.text.Font(negrito, 9.6f));
    //adiciona a string que ir compor a frase
    phraseCabecalho.add(cab2);
    //adiciona fonte para a frase
    phraseCabecalho.setFont(new com.itextpdf.text.Font(normal, 9.6f));
    //adiciona a string que ir compor a frase
    phraseCabecalho.add(cab3);
    //adiciona fonte para a frase
    phraseCabecalho.setFont(new com.itextpdf.text.Font(negrito, 9.6f));
    //adiciona a string que ir compor a frase
    phraseCabecalho.add(cab4);
    //adiciona fonte para a frase
    phraseCabecalho.setFont(new com.itextpdf.text.Font(normal, 9.6f));
    //adiciona a string que ir compor a frase
    phraseCabecalho.add(cab5);
    //adiciona fonte para a frase
    phraseCabecalho.setFont(new com.itextpdf.text.Font(negrito, 9.6f));
    //adiciona a string que ir compor a frase
    phraseCabecalho.add(cab6);
    //adiciona fonte para a frase
    phraseCabecalho.setFont(new com.itextpdf.text.Font(normal, 9.6f));
    //adiciona a string que ir compor a frase
    phraseCabecalho.add(cab7);
    //adiciona fonte para a frase
    phraseCabecalho.setFont(new com.itextpdf.text.Font(negrito, 9.6f));
    //adiciona a string que ir compor a frase
    phraseCabecalho.add(cab8);
    //adiciona fonte para a frase
    phraseCabecalho.setFont(new com.itextpdf.text.Font(normal, 9.6f));
    //adiciona a string que ir compor a frase
    phraseCabecalho.add(cab9);
    //adiciona fonte para a frase
    phraseCabecalho.setFont(new com.itextpdf.text.Font(negrito, 9.6f));
    //adiciona a string que ir compor a frase
    phraseCabecalho.add(cab10);
    //adiciona fonte para a frase
    phraseCabecalho.setFont(new com.itextpdf.text.Font(normal, 9.6f));
    //adiciona a string que ir compor a frase
    phraseCabecalho.add(cab11);
    //adiciona fonte para a frase
    phraseCabecalho.setFont(new com.itextpdf.text.Font(negrito, 9.6f));
    //adiciona a string que ir compor a frase
    phraseCabecalho.add(cab12);
    //adiciona fonte para a frase
    phraseCabecalho.setFont(new com.itextpdf.text.Font(negrito, 9.6f));
    //adiciona a string que ir compor a frase
    phraseCabecalho.add(cab13);
    //adiciona fonte para a frase
    phraseCabecalho.setFont(new com.itextpdf.text.Font(negrito, 9.6f));
    //adiciona a string que ir compor a frase
    phraseCabecalho.add(cab14);
    //adiciona fonte para a frase
    phraseCabecalho.setFont(new com.itextpdf.text.Font(normal, 9.6f));
    //adiciona a string que ir compor a frase
    phraseCabecalho.add(cab15);
    //adiciona fonte para a frase
    phraseCabecalho.setFont(new com.itextpdf.text.Font(normal, 9.6f));
    //adiciona a string que ir compor a frase
    phraseCabecalho.add(cab16);
    //adiciona fonte para a frase
    phraseCabecalho.setFont(new com.itextpdf.text.Font(negrito, 9.6f));
    //adiciona a string que ir compor a frase
    phraseCabecalho.add(cab17);
    //adiciona fonte para a frase
    phraseCabecalho.setFont(new com.itextpdf.text.Font(normal, 9.6f));
    //adiciona a string que ir compor a frase
    phraseCabecalho.add(cab18);
    //adiciona fonte para a frase
    phraseCabecalho.setFont(new com.itextpdf.text.Font(negrito, 9.6f));
    //adiciona a string que ir compor a frase
    phraseCabecalho.add(cab19);
    //adiciona fonte para a frase
    phraseCabecalho.setFont(new com.itextpdf.text.Font(normal, 9.6f));
    //adiciona a string que ir compor a frase
    phraseCabecalho.add(cab20);
    //adiciona fonte para a frase
    phraseCabecalho.setFont(new com.itextpdf.text.Font(negrito, 9.6f));
    //adiciona a string que ir compor a frase
    phraseCabecalho.add(cab21);
    //adiciona fonte para a frase
    phraseCabecalho.setFont(new com.itextpdf.text.Font(normal, 9.6f));
    //adiciona a string que ir compor a frase
    phraseCabecalho.add(cab22);
    //adiciona fonte para a frase
    phraseCabecalho.setFont(new com.itextpdf.text.Font(negrito, 9.6f));
    //adiciona a string que ir compor a frase
    phraseCabecalho.add(cab23);
    //adiciona fonte para a frase
    phraseCabecalho.setFont(new com.itextpdf.text.Font(negrito, 9.6f));
    //adiciona a string que ir compor a frase
    phraseCabecalho.add(cab24);
    //adiciona fonte para a frase
    phraseCabecalho.setFont(new com.itextpdf.text.Font(negrito, 9.6f));
    //adiciona a string que ir compor a frase
    phraseCabecalho.add(cab25);
    //adiciona fonte para a frase
    phraseCabecalho.setFont(new com.itextpdf.text.Font(normal, 9.6f));
    //adiciona a string que ir compor a frase
    phraseCabecalho.add(cab255);
    //adiciona fonte para a frase
    phraseCabecalho.setFont(new com.itextpdf.text.Font(negrito, 9.6f));
    //adiciona a string que ir compor a frase
    phraseCabecalho.add(cab26);
    //adiciona fonte para a frase
    phraseCabecalho.setFont(new com.itextpdf.text.Font(normal, 9.6f));
    //adiciona a string que ir compor a frase
    phraseCabecalho.add(cab266);
    //adiciona fonte para a frase
    phraseCabecalho.setFont(new com.itextpdf.text.Font(negrito, 9.6f));
    //adiciona a string que ir compor a frase
    phraseCabecalho.add(cab2661);
    //adiciona fonte para a frase
    phraseCabecalho.setFont(new com.itextpdf.text.Font(normal, 9.6f));
    //adiciona a string que ir compor a frase
    phraseCabecalho.add(cab27);
    //adiciona fonte para a frase
    phraseCabecalho.setFont(new com.itextpdf.text.Font(normal, 9.6f));
    //adiciona a string que ir compor a frase
    phraseCabecalho.add(cab28);
    //adicionar a frase no contener do PDF
    collumText.addText(phraseCabecalho);
    // escolhe alinhamento justificado para o objeto collumText
    collumText.setAlignment(3);
    //justifica a primeira linha
    collumText.setAdjustFirstLine(true);
    //dar uma identao de 30pt na primeira linha do collumText
    collumText.setIndent(30);
    //posiciona o collumText na pgina 1
    collumText.setSimpleColumn(40, 560, 560, 760);
    //escreve o collumText no PDF
    collumText.go(false);
    // ITENS ADICIONADOS A P?GINA 04 //
    // ir adicionar na quarta pgina do PDF resultante
    PdfContentByte placas = stamper.getOverContent(4);
    // cria um objeto que ir acomodar a o PdfContentByte
    ColumnText collumTextPlacas = new ColumnText(placas);
    // definie as configuraes de fonte para o objeto frase
    //BaseFont bfPlacas = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
    //cria uma frase
    Phrase phrasePlacas = new Phrase();
    //adiciona fonte para a frase
    phrasePlacas.setFont(new com.itextpdf.text.Font(normal, 9.6f));
    //adiciona a string que ir compor a frase
    phrasePlacas.add(textPlacas1);
    //adiciona fonte para a frase
    phrasePlacas.setFont(new com.itextpdf.text.Font(negrito, 9.6f));
    //adiciona a string que ir compor a frase
    phrasePlacas.add(textPlacas2);
    //adiciona fonte para a frase
    phrasePlacas.setFont(new com.itextpdf.text.Font(normal, 9.6f));
    //adiciona a string que ir compor a frase
    phrasePlacas.add(textPlacas3);
    //adicionar a frase no contener do PDF
    collumTextPlacas.addText(phrasePlacas);
    //dar uma identao de 30pt na primeira linha do collumText
    collumTextPlacas.setIndent(30);
    // escolhe alinhamento justificado para o objeto collumText
    collumTextPlacas.setAlignment(3);
    //justifica a primeira linha
    collumTextPlacas.setAdjustFirstLine(true);
    //posiciona o collumText na pgina 4
    collumTextPlacas.setSimpleColumn(40, 600, 560, 800);
    //escreve o collumText no PDF
    collumTextPlacas.go(false);

    // ITENS ADICIONADOS A P?GINA 06 //
    String dia = new SimpleDateFormat("dd").format(dataAtual);
    String ano = new SimpleDateFormat("yyyy").format(dataAtual);
    //form.setFieldProperty("txtDataLocal", "txtDataLocal", PdfFormField., inst);
    int mes = dataAtual.getMonth();
    String mesEscrito = null;
    switch (mes) {
    case 0:
        mesEscrito = "janeiro";
        break;
    case 1:
        mesEscrito = "favereiro";
        break;
    case 2:
        mesEscrito = "maro";
        break;
    case 3:
        mesEscrito = "abril";
        break;
    case 4:
        mesEscrito = "maio";
        break;
    case 5:
        mesEscrito = "junho";
        break;
    case 6:
        mesEscrito = "julho";
        break;
    case 7:
        mesEscrito = "agosto";
        break;
    case 8:
        mesEscrito = "setembro";
        break;
    case 9:
        mesEscrito = "outubro";
        break;
    case 10:
        mesEscrito = "novembro";
        break;
    case 11:
        mesEscrito = "dezembro";
        break;
    }
    String textRodape1 = "Fica eleito o foro da Comarca de ";
    String textRodape12 = cidadeUn;
    String textRodape121 = ", estado do ";
    String textRodape122 = nomeEstadoUn;
    String textRodape123 = ", para dirimir eventuais dvidas oriundas do presente contrato, "
            + "quer na sua aplicao ou interpretao, com renncia a qualquer outro por mais "
            + "privilegiado que seja. E por estarem assim compromissados, firmam o presente termo "
            + "em 02 (duas) vias de igual teor e forma na presena de 2 (duas) testemunhas abaixo assinadas.";

    String textRodape2 = cidadeUn + " , " + nomeEstadoUn + "    " + dia + "  de  " + mesEscrito + "  de  " + ano
            + ".";
    String textRodape3 = autoMaster + "\n" + cnpjUn;
    String textRodape4 = clienteAuxiliar.get(0).get("nomeCliente") + "\n"
            + ((tipoCliente == 1) ? "CPF: " + formataCPF(cpfCnpj) : "CNPJ: " + formataCNPJ(cpfCnpj));
    // ir adicionar na quarta pgina do PDF resultante
    PdfContentByte rodape = stamper.getOverContent(6);
    // cria um objeto que ir acomodar a o PdfContentByte
    ColumnText collumTextRodape1 = new ColumnText(rodape);
    //cria uma frase
    Phrase phraseRadape1 = new Phrase();
    //adiciona fonte para a frase
    phraseRadape1.setFont(new com.itextpdf.text.Font(normal, 9.6f));
    //adiciona a string que ir compor a frase
    phraseRadape1.add(textRodape1);
    //adiciona fonte para a frase
    phraseRadape1.setFont(new com.itextpdf.text.Font(negrito, 9.6f));
    //adiciona a string que ir compor a frase
    phraseRadape1.add(textRodape12);
    //adiciona fonte para a frase
    phraseRadape1.setFont(new com.itextpdf.text.Font(normal, 9.6f));
    //adiciona a string que ir compor a frase
    phraseRadape1.add(textRodape121);
    //adiciona fonte para a frase
    phraseRadape1.setFont(new com.itextpdf.text.Font(negrito, 9.6f));
    //adiciona a string que ir compor a frase
    phraseRadape1.add(textRodape122);
    //adiciona fonte para a frase
    phraseRadape1.setFont(new com.itextpdf.text.Font(normal, 9.6f));
    //adiciona a string que ir compor a frase
    phraseRadape1.add(textRodape123);
    //adicionar a frase no contener do PDF
    collumTextRodape1.addText(phraseRadape1);
    //dar uma identao de 30pt na primeira linha do collumText
    collumTextRodape1.setIndent(30);
    // escolhe alinhamento justificado para o objeto collumText
    collumTextRodape1.setAlignment(3);
    //justifica a primeira linha
    collumTextRodape1.setAdjustFirstLine(true);
    //posiciona o collumText na pgina 4
    collumTextRodape1.setSimpleColumn(40, 580, 560, 780);
    //escreve o collumText no PDF
    collumTextRodape1.go(false);

    // cria um objeto que ir acomodar a o PdfContentByte
    ColumnText collumTextRodape2 = new ColumnText(rodape);
    //cria uma frase
    Phrase phraseRadape2 = new Phrase();
    //adiciona fonte para a frase
    phraseRadape2.setFont(new com.itextpdf.text.Font(normal, 9.6f));
    //adiciona a string que ir compor a frase
    phraseRadape2.add(textRodape2);
    //adicionar a frase no contener do PDF
    collumTextRodape2.addText(phraseRadape2);
    //dar uma identao de 30pt na primeira linha do collumText
    collumTextRodape2.setIndent(30);
    // escolhe alinhamento justificado para o objeto collumText
    collumTextRodape2.setAlignment(2);
    //justifica a primeira linha
    collumTextRodape2.setAdjustFirstLine(true);
    //posiciona o collumText na pgina 4
    collumTextRodape2.setSimpleColumn(40, 580, 560, 680);
    //escreve o collumText no PDF
    collumTextRodape2.go(false);

    // cria um objeto que ir acomodar a o PdfContentByte
    ColumnText collumTextRodape3 = new ColumnText(rodape);
    //cria uma frase
    Phrase phraseRadape3 = new Phrase();
    //adiciona fonte para a frase
    phraseRadape3.setFont(new com.itextpdf.text.Font(negrito, 9.6f));
    //adiciona a string que ir compor a frase
    phraseRadape3.add(textRodape3);
    //adicionar a frase no contener do PDF
    collumTextRodape3.addText(phraseRadape3);
    //dar uma identao de 30pt na primeira linha do collumText
    collumTextRodape3.setIndent(30);
    // escolhe alinhamento justificado para o objeto collumText
    collumTextRodape3.setAlignment(1);
    //justifica a primeira linha
    collumTextRodape3.setAdjustFirstLine(true);
    //posiciona o collumText na pgina 4
    collumTextRodape3.setSimpleColumn(250, 460, 600, 560);
    //escreve o collumText no PDF
    collumTextRodape3.go(false);

    // cria um objeto que ir acomodar a o PdfContentByte
    ColumnText collumTextRodape4 = new ColumnText(rodape);
    //cria uma frase
    Phrase phraseRadape4 = new Phrase();
    //adiciona fonte para a frase
    phraseRadape4.setFont(new com.itextpdf.text.Font(negrito, 9.6f));
    //adiciona a string que ir compor a frase
    phraseRadape4.add(textRodape4);
    //adicionar a frase no contener do PDF
    collumTextRodape4.addText(phraseRadape4);
    //dar uma identao de 30pt na primeira linha do collumText
    collumTextRodape4.setIndent(30);
    // escolhe alinhamento justificado para o objeto collumText
    collumTextRodape4.setAlignment(1);
    //justifica a primeira linha
    collumTextRodape4.setAdjustFirstLine(true);
    //posiciona o collumText na pgina 4
    collumTextRodape4.setSimpleColumn(25, 460, 200, 560);
    //escreve o collumText no PDF
    collumTextRodape4.go(false);

    stamper.close();
    reader.close();
}

From source file:com.chaschev.itext.ColumnTextBuilder.java

License:Apache License

public ColumnTextBuilder addTruncatedLine(Chunk chunk, boolean addEllipsis) {
    final float pixelsForEllipsis = 6;

    try {/*www  . ja  v  a 2  s.  com*/
        ColumnText dup = ColumnText.duplicate(columnText);

        final Rectangle oneLineRectangle = new Rectangle(simpleColumnRectangle);

        oneLineRectangle.setTop(dup.getYLine());

        final float fontHeight = calcApproximateFontHeight(chunk.getFont()) * 1.6f;

        oneLineRectangle.setBottom(dup.getYLine() - fontHeight);

        if (addEllipsis) {
            oneLineRectangle.setRight(oneLineRectangle.getRight() - pixelsForEllipsis);
        }

        dup.setSimpleColumn(oneLineRectangle);
        dup.addText(chunk);

        final int status = dup.go();

        float yLine;

        if (addEllipsis && ColumnText.hasMoreText(status)) {
            oneLineRectangle.setLeft(dup.getLastX() + 2);
            oneLineRectangle.setRight(oneLineRectangle.getRight() + pixelsForEllipsis * 2);

            dup = ColumnText.duplicate(dup);

            dup.setSimpleColumn(oneLineRectangle);

            final Chunk ellipses = new Chunk("...\n", chunk.getFont());

            dup.setText(new Phrase(ellipses));
            dup.go();
            yLine = dup.getYLine();
        } else {
            yLine = dup.getYLine();
        }

        setYLine(yLine);

        return this;

    } catch (DocumentException e) {
        throw Exceptions.runtime(e);
    }
}

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

License:Open Source License

private void createImage(Document document, PdfWriter writer, Font featureHeaderStyle)
        throws BadElementException, MalformedURLException, IOException, DocumentException {
    Image imageSprite = Image.getInstance(new URL(
            "http://lh3.ggpht.com/_4msVPAgKJv8/SCRYD-pPVKI/AAAAAAAAAYU/zUN963EPoZc/s1024/102_0609.JPG"));
    imageSprite.setAbsolutePosition(400, 500);
    imageSprite.scaleAbsolute(171.0f, 250.0f);
    float imageSpriteY = document.getPageSize().getHeight() * 0.60f;
    float imageSpriteX = document.getPageSize().getWidth() * 0.65f;
    imageSprite.setAlignment(Image.UNDERLYING);

    document.add(imageSprite);// w  w w  .  j a v  a 2  s .  c  o m

    PdfContentByte cb = writer.getDirectContent();
    ColumnText ct = new ColumnText(cb);
    Chunk imageHeader = new Chunk("Images", featureHeaderStyle);
    ct.addText(imageHeader);
    ct.setAlignment(Element.ALIGN_LEFT);
    ct.setSimpleColumn(imageSpriteX, imageSpriteY - imageSprite.getScaledHeight(),
            imageSpriteX + imageSprite.getScaledWidth(), imageSpriteY + imageSprite.getScaledHeight() + 20);
    ct.go();

    ct = new ColumnText(cb);
    Chunk imageFooter = new Chunk("Footer to be set for a figure. Similar to 'image cpation'.",
            FontFactory.getFont(FontFactory.TIMES_ROMAN, 8));
    ct.addText(imageFooter);
    ct.setAlignment(Element.ALIGN_CENTER);
    ct.setSimpleColumn(imageSpriteX, imageSpriteY - 150, imageSpriteX + imageSprite.getScaledWidth(),
            imageSpriteY);
    ct.go();
}

From source file:eyeofthetiger.utils.PDFDossardGenerator.java

public void createPdf(List<Participant> participants, OutputStream out) throws IOException, DocumentException {
    sortParticipants(participants);// w w  w . j  ava2 s. c  om

    Document document = new Document(PageSize.A4.rotate());
    float margin = CentimeterToUserSpace(marginCm);
    document.setMargins(margin, margin, margin, margin);
    PdfWriter writer = PdfWriter.getInstance(document, out);
    document.open();
    PdfContentByte cb = writer.getDirectContent();

    PdfReader pdfBackgroundReader = null;
    PdfImportedPage backgroundPage = null;
    if (pdfBackground != null && (new File(pdfBackground)).exists() && (new File(pdfBackground)).isFile()) {
        pdfBackgroundReader = new PdfReader(pdfBackground);
        backgroundPage = writer.getImportedPage(pdfBackgroundReader, 1);
    }

    float documentTop = document.top();
    float documentBottom = document.bottom();
    float documentHeight = documentTop - documentBottom;
    float left = document.left();
    float right = document.right();
    float width = right - left;
    float height = documentTop - documentBottom;

    //cb.rectangle(left, documentBottom, width, documentHeight);
    //cb.stroke();

    boolean logoLeftExist = (new File(logoLeft)).exists() && (new File(logoLeft)).isFile();
    boolean logoRightExist = (new File(logoRight)).exists() && (new File(logoRight)).isFile();

    float imgLeftRight = left;
    float imgLeftBottom = documentTop;
    float imgRightLeft = right;
    float imgRighBottom = documentTop;
    Image imgLeft = null;
    Image imgRight = null;
    if (exportLogos) {
        if (logoLeftExist) {
            imgLeft = Image.getInstance(logoLeft);
            float h = imgLeft.getHeight();
            float w = imgLeft.getWidth();
            float nw = width * logoLeftWidth;
            float nh = (h / w) * nw;
            imgLeft.scaleAbsolute(nw, nh);
            //img.scaleAbsoluteHeight(img.getScaledWidth() / xyRatio);
            imgLeft.setAbsolutePosition(left, documentTop - imgLeft.getScaledHeight());
            //cb.addImage(img);   

            imgLeftRight = imgLeft.getAbsoluteX() + imgLeft.getScaledWidth();
            imgLeftBottom = imgLeft.getAbsoluteY();
        }

        if (logoRightExist) {
            imgRight = Image.getInstance(logoRight);
            float h = imgRight.getHeight();
            float w = imgRight.getWidth();
            float nw = width * logoRightWidth;
            float nh = (h / w) * nw;
            imgRight.scaleAbsolute(nw, nh);
            imgRight.setAbsolutePosition(right - imgRight.getScaledWidth(),
                    documentTop - imgRight.getScaledHeight());
            //cb.addImage(imgRight);
            imgRightLeft = imgRight.getAbsoluteX();
            imgRighBottom = imgRight.getAbsoluteY();
        }

    }

    float nameHeightPercent = 0.35f;
    float groupHeightPercent = 0.25f;

    float nameTop = documentTop;
    float nameBottom = nameTop;
    if (exportName) {
        nameBottom = nameTop - (documentHeight * nameHeightPercent);
    }
    float groupeTop = nameBottom;
    float groupeBottom = nameBottom;
    if (exportGroup) {
        groupeBottom = groupeTop - (documentHeight * groupHeightPercent);
    }
    float barcodeTop = groupeBottom;
    float barcodeBottom = documentBottom;

    ColumnText columnText;

    for (Participant participant : participants) {

        if (backgroundPage != null) {
            //cb.addTemplate(backgroundPage, 1f, 0, 0, 1, 0, 0); //TODO
            cb.addTemplate(backgroundPage, 0, 0);
        }

        float nameFontSize = 65f;
        float groupFontSize = 45f;
        float renseignementFontSize = 35f;

        if (imgLeft != null) {
            cb.addImage(imgLeft);
        }
        if (imgRight != null) {
            cb.addImage(imgRight);
        }

        if (exportName) {
            columnText = new ColumnText(cb);
            columnText.setAlignment(Rectangle.ALIGN_CENTER);

            if (imgLeftRight != -1 && imgLeftBottom != -1) {
                float[] leftBorder = null;
                if (imgLeftBottom < nameBottom) {
                    leftBorder = new float[] { imgLeftRight, nameTop, imgLeftRight, nameBottom, left,
                            nameBottom };
                } else {
                    leftBorder = new float[] { imgLeftRight, nameTop, imgLeftRight, imgLeftBottom, left,
                            imgLeftBottom, left, nameBottom };
                }

                float[] rightBorder = null;
                if (imgRighBottom < nameBottom) {
                    rightBorder = new float[] { imgRightLeft, nameTop, imgRightLeft, nameBottom, right,
                            nameBottom };
                } else {
                    rightBorder = new float[] { imgRightLeft, nameTop, imgRightLeft, imgRighBottom, right,
                            imgRighBottom, right, nameBottom };
                }

                columnText.setColumns(leftBorder, rightBorder);
            } else {
                columnText.setSimpleColumn(left, nameTop, right, nameBottom);
            }
            //cb.rectangle(left, nameBottom, width, (nameTop - nameBottom));
            //cb.stroke();

            columnText.setExtraParagraphSpace(0f);
            columnText.setAdjustFirstLine(false);
            columnText.setIndent(0);

            String txt = participant.getNom().toUpperCase() + " " + participant.getPrenom();

            float previousPos = columnText.getYLine();
            columnText.setLeading(nameFontSize);
            columnText.setText(createCleanPhrase(txt, nameFontSize, true));
            while (nameFontSize > 1 && ColumnText.hasMoreText(columnText.go(true))) {
                nameFontSize = nameFontSize - 0.5f;
                columnText.setLeading(nameFontSize);
                columnText.setText(createCleanPhrase(txt, nameFontSize, true));
                columnText.setYLine(previousPos);
            }

            columnText.setLeading(nameFontSize);
            columnText.setText(createCleanPhrase(txt, nameFontSize, true));
            columnText.setYLine(previousPos);
            columnText.go(false);

        }

        if (exportGroup) {
            columnText = new ColumnText(cb);
            columnText.setAlignment(Rectangle.ALIGN_CENTER);

            columnText.setSimpleColumn(document.left(), groupeTop, document.right(), groupeBottom);
            float groupeHeight = groupeTop - groupeBottom;
            //cb.rectangle(document.left(), groupeTop - groupeHeight, document.right() - document.left(), groupeHeight);
            //cb.stroke();

            columnText.setExtraParagraphSpace(0f);
            columnText.setAdjustFirstLine(false);
            columnText.setIndent(0);
            columnText.setFollowingIndent(0);

            String txt1 = participant.getGroupe();
            String txt2 = exportRenseignement ? "\n" + participant.getRenseignements() : null;

            float previousPos = columnText.getYLine();
            columnText.setText(null);
            columnText.setLeading(groupFontSize);
            columnText.addText(createCleanPhrase(txt1, groupFontSize, true));
            columnText.addText(createCleanPhrase(txt2, renseignementFontSize, false));
            while (groupFontSize > 1 && ColumnText.hasMoreText(columnText.go(true))) {
                groupFontSize = groupFontSize - 0.5f;
                renseignementFontSize = renseignementFontSize - 0.5f;
                columnText.setText(null);
                columnText.setLeading(groupFontSize);
                columnText.addText(createCleanPhrase(txt1, groupFontSize, true));
                columnText.addText(createCleanPhrase(txt2, renseignementFontSize, false));
                columnText.setYLine(previousPos);
            }

            columnText.setText(null);
            columnText.setLeading(groupFontSize);
            columnText.addText(createCleanPhrase(txt1, groupFontSize, true));
            columnText.addText(createCleanPhrase(txt2, renseignementFontSize, false));
            columnText.setYLine(previousPos);
            columnText.go(false);
        }

        {
            columnText = new ColumnText(cb);

            float topMargin = 12f;
            columnText.setSimpleColumn(left, barcodeTop - topMargin, right, barcodeBottom);
            float barcodeHeight = (barcodeTop - topMargin) - barcodeBottom;
            //cb.rectangle(left, barcodeTop - barcodeHeight, width, barcodeHeight);
            //cb.stroke();

            columnText.setExtraParagraphSpace(0f);
            columnText.setAdjustFirstLine(false);
            columnText.setIndent(0);

            float previousPos = columnText.getYLine();
            columnText.setText(null);
            columnText.addElement(createCleanBarcode(cb, participant.getNumero(), width, barcodeHeight));
            columnText.go(false);
        }

        document.newPage();

    }

    document.close();

    if (pdfBackgroundReader != null) {
        pdfBackgroundReader.close();
    }
}

From source file:gov.utah.dts.det.ccl.actions.facility.information.license.reports.LicenseCertificate.java

private static void writePdf(License license, ByteArrayOutputStream ba, HttpServletRequest request)
        throws DocumentException, BadElementException {
    SimpleDateFormat df = new SimpleDateFormat("MMMM d, yyyy");
    StringBuilder sb;/*  ww w .  ja va  2s .c om*/

    // Retrieve the certificate template to use as watermark
    ServletContext context = request.getSession().getServletContext();
    String templatefile = context.getRealPath("/resources") + "/LicenseCertificateTemplate.pdf";
    PdfReader reader = getTemplateReader(templatefile);
    if (reader != null && reader.getNumberOfPages() > 0) {
        Phrase phrase;

        // Create new document using the page size of the certificate template document
        Document document = new Document(reader.getPageSizeWithRotation(1), 0, 0, 0, 0);
        PdfWriter writer = PdfWriter.getInstance(document, ba);
        document.open();

        // Get the writer under content byte for placing of watermark
        PdfContentByte under = writer.getDirectContentUnder();
        PdfContentByte over = writer.getDirectContent();

        // Retrieve the first page of the template document and wrap as an Image to use as new document watermark
        PdfImportedPage page = writer.getImportedPage(reader, 1);
        Image img = Image.getInstance(page);
        // Make sure the image has an absolute page position
        if (!img.hasAbsoluteX() || !img.hasAbsoluteY()) {
            img.setAbsolutePosition(0, 0);
        }

        under.addImage(img);

        /*
         * THE FOLLOWING TWO FUNCTION CALLS DISPLAY THE PAGE MARGINS AND TEXT COLUMN BORDERS FOR DEBUGGING TEXT PLACEMENT.
         * UNCOMMENT EACH FUNCTION CALL TO HAVE BORDERS DISPLAYED ON THE OUTPUT DOCUMENT.  THIS WILL HELP WHEN YOU NEED
         * TO SEE WHERE TEXT WILL BE PLACED ON THE CERTIFICATE FORM.
         */
        // Show the page margins
        //showPageMarginBorders(over);

        // Show the text column borders
        //showColumnBorders(over);

        ColumnText ct = new ColumnText(over);
        ct.setLeading(fixedLeading);

        // Add Facility Name to column
        String text = license.getFacility().getName();
        if (text != null) {
            phrase = new Phrase(text.toUpperCase(), mediumfontB);
            phrase.setLeading(noLeading);
            ct.addText(phrase);
            ct.addText(Chunk.NEWLINE);
        }
        // Add Facility Site to column
        text = license.getFacility().getSiteName();
        if (text != null) {
            phrase = new Phrase(text.toUpperCase(), mediumfontB);
            phrase.setLeading(noLeading);
            ct.addText(phrase);
            ct.addText(Chunk.NEWLINE);
        }
        // Add Facility Address to column
        text = license.getFacility().getLocationAddress().getAddressOne();
        if (text != null) {
            phrase = new Phrase(text.toUpperCase(), mediumfontB);
            phrase.setLeading(noLeading);
            ct.addText(phrase);
            ct.addText(Chunk.NEWLINE);
        }
        text = license.getFacility().getLocationAddress().getCityStateZip();
        if (text != null) {
            phrase = new Phrase(text.toUpperCase(), mediumfontB);
            phrase.setLeading(noLeading);
            ct.addText(phrase);
            ct.addText(Chunk.NEWLINE);
        }
        // Write column to document
        ct.setAlignment(Element.ALIGN_CENTER);
        ct.setSimpleColumn(COLUMNS[0][0], COLUMNS[0][1], COLUMNS[0][2], COLUMNS[0][3]);
        ct.go();

        // Add Certification Service Code to column
        ct = new ColumnText(over);
        ct.setLeading(fixedLeading);
        String service = "";
        if (license.getSpecificServiceCode() != null
                && StringUtils.isNotBlank(license.getSpecificServiceCode().getValue())
                && DV_TREATMENT.equalsIgnoreCase(license.getSpecificServiceCode().getValue())) {
            service += DOMESTIC_VIOLENCE;
        }
        if (!license.getProgramCodeIds().isEmpty()) { // redmine 25410
            mentalHealthLoop: for (PickListValue pkv : license.getProgramCodeIds()) {
                String program = pkv.getValue();
                int idx = program.indexOf(" -");
                if (idx >= 0) {
                    String code = program.substring(0, idx);
                    if (MENTAL_HEALTH_CODES.indexOf(code + ":") >= 0) {
                        if (service.length() > 0) {
                            service += " / ";
                        }
                        service += MENTAL_HEALTH;
                        break mentalHealthLoop;
                    }
                }
            }
            substanceAbuseLoop: for (PickListValue pkv : license.getProgramCodeIds()) {
                String program = pkv.getValue();
                int idx = program.indexOf(" -");
                if (idx >= 0) {
                    String code = program.substring(0, idx);
                    if (SUBSTANCE_ABUSE_CODES.indexOf(code + ":") >= 0) {
                        if (service.length() > 0) {
                            service += " / ";
                        }
                        service += SUBSTANCE_ABUSE;
                        break substanceAbuseLoop;
                    }
                }
            }
        }
        if (StringUtils.isNotBlank(license.getServiceCodeDesc())) {
            if (service.length() > 0) {
                service += " / ";
            }
            service += license.getServiceCodeDesc();
        }
        if (StringUtils.isNotEmpty(service)) {
            phrase = new Phrase(service.toUpperCase(), mediumfont);
            phrase.setLeading(noLeading);
            ct.addText(phrase);
            ct.addText(Chunk.NEWLINE);
        }

        // Add CLIENTS Info to column
        sb = new StringBuilder("FOR ");
        if (license.getAgeGroup() == null
                || license.getAgeGroup().getValue().equalsIgnoreCase("Adult & Youth")) {
            // Adult & Youth
            if (license.getAdultTotalSlots() != null) {
                sb.append(license.getAdultTotalSlots().toString());
            }
            sb.append(" ADULT AND YOUTH CLIENTS");
        } else if (license.getAgeGroup().getValue().equalsIgnoreCase("Adult")) {
            // Adult
            if (license.getAdultTotalSlots() != null) {
                // Are male or female counts specified?
                sb.append(license.getAdultTotalSlots().toString());
                sb.append(" ADULT");
                if (license.getAdultFemaleCount() != null || license.getAdultMaleCount() != null) {
                    // Does either the male or female count equal the total slot count?
                    if ((license.getAdultFemaleCount() != null
                            && license.getAdultFemaleCount().equals(license.getAdultTotalSlots()))) {
                        sb.append(" FEMALE CLIENTS");
                    } else if (license.getAdultMaleCount() != null
                            && license.getAdultMaleCount().equals(license.getAdultTotalSlots())) {
                        sb.append(" MALE CLIENTS");
                    } else {
                        sb.append(" CLIENTS, ");
                        if (license.getAdultMaleCount() != null) {
                            sb.append(license.getAdultMaleCount().toString() + " MALE");
                        }
                        if (license.getAdultFemaleCount() != null) {
                            if (license.getAdultMaleCount() != null) {
                                sb.append(" AND ");
                            }
                            sb.append(license.getAdultFemaleCount().toString() + " FEMALE");
                        }
                        if (license.getFromAge() != null || license.getToAge() != null) {
                            sb.append(",");
                        }
                    }
                } else {
                    sb.append(" CLIENTS");
                }
            } else {
                sb.append(" ADULT CLIENTS");
            }
        } else {
            // Youth
            if (license.getYouthTotalSlots() != null) {
                // Are male or female counts specified?
                sb.append(license.getYouthTotalSlots().toString());
                sb.append(" YOUTH");
                if (license.getYouthFemaleCount() != null || license.getYouthMaleCount() != null) {
                    // Does either the male or female count equal the total slot count?
                    if ((license.getYouthFemaleCount() != null
                            && license.getYouthFemaleCount().equals(license.getYouthTotalSlots()))) {
                        sb.append(" FEMALE CLIENTS");
                    } else if (license.getYouthMaleCount() != null
                            && license.getYouthMaleCount().equals(license.getYouthTotalSlots())) {
                        sb.append(" MALE CLIENTS");
                    } else {
                        sb.append(" CLIENTS, ");
                        if (license.getYouthMaleCount() != null) {
                            sb.append(license.getYouthMaleCount().toString() + " MALE");
                        }
                        if (license.getYouthFemaleCount() != null) {
                            if (license.getYouthMaleCount() != null) {
                                sb.append(" AND ");
                            }
                            sb.append(license.getYouthFemaleCount().toString() + " FEMALE");
                        }
                        if (license.getFromAge() != null || license.getToAge() != null) {
                            sb.append(",");
                        }
                    }
                } else {
                    sb.append(" CLIENTS");
                }
            } else {
                sb.append(" YOUTH CLIENTS");
            }
        }
        if (license.getFromAge() != null || license.getToAge() != null) {
            sb.append(" AGES ");
            if (license.getFromAge() != null) {
                sb.append(license.getFromAge().toString());
                if (license.getToAge() != null) {
                    sb.append(" TO " + license.getToAge().toString());
                } else {
                    sb.append(" AND OLDER");
                }
            } else {
                sb.append("TO " + license.getToAge().toString());
            }
        }
        phrase = new Phrase(sb.toString(), mediumfont);
        phrase.setLeading(noLeading);
        ct.addText(phrase);
        ct.addText(Chunk.NEWLINE);

        // Add Certificate Comments
        if (StringUtils.isNotBlank(license.getCertificateComment())) {
            phrase = new Phrase(license.getCertificateComment().toUpperCase(), mediumfont);
            phrase.setLeading(noLeading);
            ct.addText(phrase);
        }

        // Write column to document
        ct.setAlignment(Element.ALIGN_CENTER);
        ct.setSimpleColumn(COLUMNS[1][0], COLUMNS[1][1], COLUMNS[1][2], COLUMNS[1][3]);
        ct.go();

        // Add Certificate Start Date
        if (license.getStartDate() != null) {
            phrase = new Phrase(df.format(license.getStartDate()), mediumfont);
            phrase.setLeading(noLeading);
            ct = new ColumnText(over);
            ct.setSimpleColumn(phrase, COLUMNS[2][0], COLUMNS[2][1], COLUMNS[2][2], COLUMNS[2][3], fixedLeading,
                    Element.ALIGN_RIGHT);
            ct.go();
        }

        // Add Certificate End Date
        if (license.getEndDate() != null) {
            phrase = new Phrase(df.format(license.getEndDate()), mediumfont);
            phrase.setLeading(noLeading);
            ct = new ColumnText(over);
            ct.setSimpleColumn(phrase, COLUMNS[3][0], COLUMNS[3][1], COLUMNS[3][2], COLUMNS[3][3], fixedLeading,
                    Element.ALIGN_LEFT);
            ct.go();
        }

        // Add License Number
        if (license.getLicenseNumber() != null) {
            phrase = new Phrase(license.getLicenseNumber().toString(), largefontB);
            phrase.setLeading(noLeading);
            ct = new ColumnText(over);
            ct.setSimpleColumn(phrase, COLUMNS[4][0], COLUMNS[4][1], COLUMNS[4][2], COLUMNS[4][3],
                    numberLeading, Element.ALIGN_CENTER);
            ct.go();
        }
        document.close();
    }
}

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

private static void generateDocumentPage1(TrackingRecordScreeningLetter screeningLetter, Document document,
        PdfWriter writer) throws BadElementException, DocumentException, Exception {
    PdfPTable table = null;/*from   w ww.  ja  v a2  s  .co m*/
    int headerwidths[] = {};
    Paragraph paragraph = null;
    List blist = null;
    ListItem item = null;
    ListItem subItem = null;
    SimpleDateFormat df = new SimpleDateFormat("MM/dd/yyyy");
    StringBuilder sb;
    PdfContentByte over = writer.getDirectContent();

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

    paragraph = new Paragraph(fixedLeadingLarge);
    paragraph.add(new Phrase("Office of Licensing Livescan Authorization", largefontB));
    paragraph.setAlignment(Element.ALIGN_CENTER);
    paragraph.setSpacingBefore(30.0f);
    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", mediumfontBU));
    paragraph.setSpacingBefore(20.0f);
    document.add(paragraph);

    /*
     * Start of Office of Licensing Information generation
     */
    table = new PdfPTable(2);
    // format the table
    headerwidths = new int[] { 60, 40 }; // percentage
    table.setWidths(headerwidths); // percentage
    table.setWidthPercentage(100);
    table.setSpacingBefore(pageSeparatorSpace);
    table.getDefaultCell().setPadding(0);
    table.getDefaultCell().setBorder(Rectangle.NO_BORDER);
    table.getDefaultCell().setVerticalAlignment(Element.ALIGN_TOP);
    table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
    paragraph = new Paragraph(fixedLeadingLarge);
    paragraph.add(new Phrase("TYPE OF TRANSACTION: NFUF", largefontB));
    paragraph.add(Chunk.NEWLINE);
    paragraph.add(new Phrase("REASON FINGERPRINTED: UCA 62A-2-120", largefontB));
    paragraph.add(Chunk.NEWLINE);
    paragraph.add(new Phrase("BILLING CODE: B1591", largefontB));
    table.addCell(paragraph);
    paragraph = new Paragraph(fixedLeadingSmall);
    Calendar cal = Calendar.getInstance();
    cal.setTime(screeningLetter.getLetterDate());
    cal.add(Calendar.DAY_OF_MONTH, 16);
    paragraph.add(new Phrase("This Authorization Expires: " + df.format(cal.getTime()), smallfont));
    table.getDefaultCell().setVerticalAlignment(Element.ALIGN_MIDDLE);
    table.addCell(paragraph);
    document.add(table);

    // Add Fee information
    paragraph = new Paragraph(fixedLeadingSmall);
    if (screeningLetter.getTrackingRecordScreening().getTrsDpsFbi() != null
            && screeningLetter.getTrackingRecordScreening().getTrsDpsFbi().getScanFee() != null) {
        paragraph.add(new Phrase("Scan Fee = ", smallfont));
        paragraph
                .add(new Phrase(
                        CommonUtils.fromDoubleToCurrency(
                                screeningLetter.getTrackingRecordScreening().getTrsDpsFbi().getScanFee()),
                        smallfontB));
    } else {
        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.setSpacingBefore(pageSeparatorSpace);
    document.add(paragraph);

    // Add Authorized Signature line
    paragraph = new Paragraph(fixedLeadingSmall);
    paragraph.add(new Phrase(
            "Office of Licensing Authorized Signature ___________________________________________________  Date ________________",
            smallfont));
    paragraph.setSpacingBefore(18.0f);
    document.add(paragraph);

    // Stamp the document date over the Date line above
    // NOTE: Use showColumnBorders as a diagnostic to display borders of column where date will be placed on document.
    //showColumnBorders(over);
    ColumnText ct = new ColumnText(over);
    ct.setLeading(fixedLeadingSmall);
    ct.addText(new Phrase(df.format(screeningLetter.getLetterDate()), smallfont));
    // Write column to document
    ct.setAlignment(Element.ALIGN_CENTER);
    ct.setSimpleColumn(COLUMNS[0][0], COLUMNS[0][1], COLUMNS[0][2], COLUMNS[0][3]);
    ct.go();

    over.setLineWidth(3.0f);
    over.setCMYKColorStroke(166, 92, 0, 145);
    over.moveTo(document.getPageSize().getLeft(65), BOTTOM_SEPARATOR_EDGE);
    over.lineTo(document.getPageSize().getRight(65), BOTTOM_SEPARATOR_EDGE);
    over.stroke();

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

    /*
     * 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(pageSeparatorSpace);
    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: ", smallfontB));
    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: ", smallfontB));
    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: ", smallfontB));
    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 Application program line
    paragraph = new Paragraph(fixedLeadingSmall);
    sb = new StringBuilder();
    sb.append("Applicant Program: ");
    if (screeningLetter.getTrackingRecordScreening().getFacility() != null
            && StringUtils.isNotBlank(screeningLetter.getTrackingRecordScreening().getFacility().getName())) {
        sb.append(screeningLetter.getTrackingRecordScreening().getFacility().getName().toUpperCase());
    }
    paragraph.add(new Phrase(sb.toString(), smallfontB));
    paragraph.setSpacingBefore(pageSeparatorSpace);
    document.add(paragraph);

    // Add Payment information line
    paragraph = new Paragraph(fixedLeadingSmall);
    sb = new StringBuilder();
    sb.append("Payment issued by: ");
    if (screeningLetter.getTrackingRecordScreening().getTrsDpsFbi() != null && StringUtils
            .isNotBlank(screeningLetter.getTrackingRecordScreening().getTrsDpsFbi().getIssuedBy())) {
        sb.append(screeningLetter.getTrackingRecordScreening().getTrsDpsFbi().getIssuedBy().toUpperCase());
    }
    sb.append("    ");
    sb.append("Check Number: ");
    if (screeningLetter.getTrackingRecordScreening().getTrsDpsFbi() != null && StringUtils
            .isNotBlank(screeningLetter.getTrackingRecordScreening().getTrsDpsFbi().getMoNumber())) {
        sb.append(screeningLetter.getTrackingRecordScreening().getTrsDpsFbi().getMoNumber().toUpperCase());
    }
    paragraph.add(new Phrase(sb.toString(), smallfontB));
    paragraph.setSpacingBefore(pageSeparatorSpace);
    document.add(paragraph);

    // Add READ THIS CAREFULLY
    paragraph = new Paragraph(fixedLeadingMedium);
    paragraph.add(new Phrase("READ THIS CAREFULLY", largefontBU));
    paragraph.setAlignment(Element.ALIGN_CENTER);
    paragraph.setSpacingBefore(pageSeparatorSpace + fixedLeadingLarge);
    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. Each site charges a fee for the electronic fingerprint scan. ",
            smallfont));
    item.add(new Phrase(
            "Scanning fees vary from site to site. This is a separate fee from the one submitted to the Department of Human Services for ",
            smallfont));
    item.add(new Phrase("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. Refund requests require a letter of explanation ",
            smallfontB));
    item.add(new Phrase(
            "from the licensed program accompanied by this original authorization letter. Failure to complete electronic ",
            smallfontB));
    item.add(new Phrase(
            "fingerprint submission within this time will result in the denial of the background screening clearance and ",
            smallfontB));
    item.add(new Phrase(
            "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 I.D. 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("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(
            "Applicant Signature ___________________________________________________  Date ________________",
            smallfont));
    item.setSpacingBefore(page1ListSpace);
    blist.add(item);
    document.add(blist);
    /*
     * End of instructions list section
     */

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

    paragraph = new Paragraph(fixedLeadingMedium);
    paragraph.add(new Phrase("Live Scan Operator: Keep this original for auditing purposes.", mediumfontB));
    paragraph.setAlignment(Element.ALIGN_CENTER);
    paragraph.setSpacingBefore(pageSeparatorSpace);
    document.add(paragraph);
}

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

private static void generateDocumentPage1(TrackingRecordScreeningLetter screeningLetter, Document document,
        PdfWriter writer) throws BadElementException, DocumentException, Exception {
    PdfPTable table = null;//  ww w  .  jav  a  2 s . c  om
    int headerwidths[] = {};
    Paragraph paragraph = null;
    List blist = null;
    ListItem item = null;
    ListItem subItem = null;
    SimpleDateFormat df = new SimpleDateFormat("MM/dd/yyyy");
    StringBuilder sb;
    PdfContentByte over = writer.getDirectContent();

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

    paragraph = new Paragraph(fixedLeadingLarge);
    paragraph.add(new Phrase("Office of Licensing Livescan Authorization", largefontB));
    paragraph.setAlignment(Element.ALIGN_CENTER);
    paragraph.setSpacingBefore(30.0f);
    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", mediumfontBU));
    paragraph.setSpacingBefore(20.0f);
    document.add(paragraph);

    /*
     * Start of Office of Licensing Information generation
     */
    table = new PdfPTable(2);
    // format the table
    headerwidths = new int[] { 60, 40 }; // percentage
    table.setWidths(headerwidths); // percentage
    table.setWidthPercentage(100);
    table.setSpacingBefore(pageSeparatorSpace);
    table.getDefaultCell().setPadding(0);
    table.getDefaultCell().setBorder(Rectangle.NO_BORDER);
    table.getDefaultCell().setVerticalAlignment(Element.ALIGN_TOP);
    table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
    paragraph = new Paragraph(fixedLeadingLarge);
    paragraph.add(new Phrase("TYPE OF TRANSACTION: FANC", largefontB));
    paragraph.add(Chunk.NEWLINE);
    paragraph.add(new Phrase("REASON FINGERPRINTED: UCA 53-10-108", largefontB));
    paragraph.add(Chunk.NEWLINE);
    paragraph.add(new Phrase("BILLING CODE: B1606", largefontB));
    table.addCell(paragraph);
    paragraph = new Paragraph(fixedLeadingSmall);
    Calendar cal = Calendar.getInstance();
    cal.setTime(screeningLetter.getLetterDate());
    cal.add(Calendar.DAY_OF_MONTH, 16);
    paragraph.add(new Phrase("This Authorization Expires: " + df.format(cal.getTime()), smallfont));
    table.getDefaultCell().setVerticalAlignment(Element.ALIGN_MIDDLE);
    table.addCell(paragraph);
    document.add(table);

    // Add Fee information
    paragraph = new Paragraph(fixedLeadingSmall);
    if (screeningLetter.getTrackingRecordScreening().getTrsDpsFbi() != null
            && screeningLetter.getTrackingRecordScreening().getTrsDpsFbi().getScanFee() != null) {
        paragraph.add(new Phrase("Scan Fee = ", smallfont));
        paragraph
                .add(new Phrase(
                        CommonUtils.fromDoubleToCurrency(
                                screeningLetter.getTrackingRecordScreening().getTrsDpsFbi().getScanFee()),
                        smallfontB));
    } else {
        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.setSpacingBefore(pageSeparatorSpace);
    document.add(paragraph);

    // Add Authorized Signature line
    paragraph = new Paragraph(fixedLeadingSmall);
    paragraph.add(new Phrase(
            "Office of Licensing Authorized Signature ___________________________________________________  Date ________________",
            smallfont));
    paragraph.setSpacingBefore(18.0f);
    document.add(paragraph);

    // Stamp the document date over the Date line above
    // NOTE: Use showColumnBorders as a diagnostic to display borders of column where date will be placed on document.
    //showColumnBorders(over);
    ColumnText ct = new ColumnText(over);
    ct.setLeading(fixedLeadingSmall);
    ct.addText(new Phrase(df.format(screeningLetter.getLetterDate()), smallfont));
    // Write column to document
    ct.setAlignment(Element.ALIGN_CENTER);
    ct.setSimpleColumn(COLUMNS[0][0], COLUMNS[0][1], COLUMNS[0][2], COLUMNS[0][3]);
    ct.go();

    over.setLineWidth(3.0f);
    over.setCMYKColorStroke(166, 92, 0, 145);
    over.moveTo(document.getPageSize().getLeft(65), BOTTOM_SEPARATOR_EDGE);
    over.lineTo(document.getPageSize().getRight(65), BOTTOM_SEPARATOR_EDGE);
    over.stroke();

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

    /*
     * 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(pageSeparatorSpace);
    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: ", smallfontB));
    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: ", smallfontB));
    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: ", smallfontB));
    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 Application program line
    paragraph = new Paragraph(fixedLeadingSmall);
    sb = new StringBuilder();
    sb.append("Applicant Program: ");
    if (screeningLetter.getTrackingRecordScreening().getFacility() != null
            && StringUtils.isNotBlank(screeningLetter.getTrackingRecordScreening().getFacility().getName())) {
        sb.append(screeningLetter.getTrackingRecordScreening().getFacility().getName().toUpperCase());
    }
    paragraph.add(new Phrase(sb.toString(), smallfontB));
    paragraph.setSpacingBefore(pageSeparatorSpace);
    document.add(paragraph);

    // Add Payment information line
    paragraph = new Paragraph(fixedLeadingSmall);
    sb = new StringBuilder();
    sb.append("Payment issued by: ");
    if (screeningLetter.getTrackingRecordScreening().getTrsDpsFbi() != null && StringUtils
            .isNotBlank(screeningLetter.getTrackingRecordScreening().getTrsDpsFbi().getIssuedBy())) {
        sb.append(screeningLetter.getTrackingRecordScreening().getTrsDpsFbi().getIssuedBy().toUpperCase());
    }
    sb.append("    ");
    sb.append("Check Number: ");
    if (screeningLetter.getTrackingRecordScreening().getTrsDpsFbi() != null && StringUtils
            .isNotBlank(screeningLetter.getTrackingRecordScreening().getTrsDpsFbi().getMoNumber())) {
        sb.append(screeningLetter.getTrackingRecordScreening().getTrsDpsFbi().getMoNumber().toUpperCase());
    }
    paragraph.add(new Phrase(sb.toString(), smallfontB));
    paragraph.setSpacingBefore(pageSeparatorSpace);
    document.add(paragraph);

    // Add READ THIS CAREFULLY
    paragraph = new Paragraph(fixedLeadingMedium);
    paragraph.add(new Phrase("READ THIS CAREFULLY", largefontBU));
    paragraph.setAlignment(Element.ALIGN_CENTER);
    paragraph.setSpacingBefore(pageSeparatorSpace + fixedLeadingLarge);
    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. Each site charges a fee for the electronic fingerprint scan. ",
            smallfont));
    item.add(new Phrase(
            "Scanning fees vary from site to site. This is a separate fee from the one submitted to the Department of Human Services for ",
            smallfont));
    item.add(new Phrase("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. Refund requests require a letter of explanation ",
            smallfontB));
    item.add(new Phrase(
            "from the licensed program accompanied by this original authorization letter. Failure to complete electronic ",
            smallfontB));
    item.add(new Phrase(
            "fingerprint submission within this time will result in the denial of the background screening clearance and ",
            smallfontB));
    item.add(new Phrase(
            "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 I.D. 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("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(
            "Applicant Signature ___________________________________________________  Date ________________",
            smallfont));
    item.setSpacingBefore(page1ListSpace);
    blist.add(item);
    document.add(blist);
    /*
     * End of instructions list section
     */

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

    paragraph = new Paragraph(fixedLeadingMedium);
    paragraph.add(new Phrase("Live Scan Operator: Keep this original for auditing purposes.", mediumfontB));
    paragraph.setAlignment(Element.ALIGN_CENTER);
    paragraph.setSpacingBefore(pageSeparatorSpace);
    document.add(paragraph);
}