Example usage for com.itextpdf.text Document add

List of usage examples for com.itextpdf.text Document add

Introduction

In this page you can find the example usage for com.itextpdf.text Document add.

Prototype


public boolean add(Element element) throws DocumentException 

Source Link

Document

Adds an Element to the Document.

Usage

From source file:com.solidmaps.webapp.report.LicenseCivilIncludeProductPDF.java

License:Open Source License

private void generateProducts(Document doc, List<LicensePCProductEntity> listProducts)
        throws DocumentException {

    DecimalFormat dc = new DecimalFormat("########0.00");

    // specify column widths
    float[] columnWidths = { 2f, 2f, 2f };
    // create PDF table with the given widths
    PdfPTable table = new PdfPTable(columnWidths);
    // set table width a percentage of the page width
    table.setWidthPercentage(100f);//from w  ww  . j  ava 2 s . c o  m

    // insert column headings
    insertCell(table, "Nome da Substncia de Controle", Element.ALIGN_CENTER, FONT_PARAGRAPH);
    insertCell(table, "Volume mximo de estoque", Element.ALIGN_CENTER, FONT_PARAGRAPH);
    insertCell(table, "Unidade de medida", Element.ALIGN_CENTER, FONT_PARAGRAPH);

    table.setHeaderRows(1);

    for (LicensePCProductEntity product : listProducts) {

        // Cria a tabela com os Produtos
        insertCell(table, product.getProduct().getName(), Element.ALIGN_LEFT, FONT_PARAGRAPH);
        insertCell(table, dc.format(product.getQtdProduct()), Element.ALIGN_LEFT, FONT_PARAGRAPH);
        insertCell(table, product.getTypeQtdProduct(), Element.ALIGN_LEFT, FONT_PARAGRAPH);
    }

    doc.add(Chunk.NEXTPAGE);
    doc.add(table);
}

From source file:com.solidmaps.webapp.report.MapCivilPdfGenerator.java

License:Open Source License

private void createSignature(Document doc) throws DocumentException {

    Calendar currDate = Calendar.getInstance();

    StringBuilder sbSignature = new StringBuilder().append(company.getCity()).append(", ")
            .append(DateUtils.getDay(currDate.getTime())).append(" de ")
            .append(DateUtils.getMonthName(currDate)).append(" de ")
            .append(DateUtils.getYear(currDate.getTime()));

    StringBuilder sbUser = new StringBuilder().append("P.P_________________________________________________ \n")
            .append("Nome: ").append(company.getUserResponsable().getName()).append("\n")
            .append("RG: " + company.getUserResponsable().getRg());

    PdfPTable table = new PdfPTable(1);
    table.setWidthPercentage(100f);// w ww.j  av a  2s. co m
    table.setHeaderRows(0);
    table.getDefaultCell().setBorder(PdfPCell.NO_BORDER);

    insertCell(table, sbSignature.toString(), Element.ALIGN_LEFT, fontHeaderTable, false);
    insertCell(table, sbUser.toString(), Element.ALIGN_LEFT, fontHeaderTable, false);

    doc.add(Chunk.NEWLINE);
    doc.add(table);
}

From source file:com.solidmaps.webapp.report.MapCivilPdfGenerator.java

License:Open Source License

private void createParagraph(Document doc) throws DocumentException {

    float[] columnWidths = { 2f, 2f };
    PdfPTable table = new PdfPTable(columnWidths);
    table.setWidthPercentage(100f);// www.j av a 2s  .  c o m

    StringBuilder sbHeader = new StringBuilder()
            .append("SECRETARIA DE ESTADO DOS NEGCIOS DA SEGURANA PBLICA \n")
            .append("POL?CIA CIVIL DO ESTADO DE ").append(company.getState()).append("\n")
            .append("DEPARTAMENTO DE IDENTIFICAO E REGISTROS DIVERSOS \n")
            .append("DIVISO DE PRODUTOS CONTROLADOS \n");

    StringBuilder sbHeaderMonth = new StringBuilder().append("MAPA TRIMESTRAL DEMONSTRATIVO DO ESTOQUE \n")
            .append("DE COMPRAS, VENDAS E CONSUMO \n").append("REFERENTE AO ")
            .append(mapProduct.getNumTrimester()).append(" TRIMESTRE DO ANO DE ").append(mapProduct.getYear())
            .append(".");

    StringBuilder sbCompany = new StringBuilder().append("Empresa: ").append(company.getName().toUpperCase())
            .append(" estabelecida  ").append(company.getStreet().toUpperCase()).append(" Cidade: ")
            .append(company.getCity()).append(", Estado: ").append(company.getState()).append(", CEP: ")
            .append(company.getCep()).append(", Fone: (").append(company.getUserResponsable().getPhoneDDD())
            .append(") ").append(company.getUserResponsable().getPhoneNumber()).append(", Fax: (")
            .append(company.getUserResponsable().getPhoneDDD()).append(") ")
            .append(company.getUserResponsable().getNumFax());

    // insert column headings
    insertCell(table, sbHeader.toString(), Element.ALIGN_LEFT, fontParagraph);
    insertCell(table, sbHeaderMonth.toString(), Element.ALIGN_LEFT, fontText);

    Paragraph paragraphText = new Paragraph(sbCompany.toString());
    paragraphText.setFont(fontHeaderTable);

    doc.add(Chunk.NEWLINE);
    doc.add(table);
    doc.add(Chunk.NEWLINE);
    doc.add(paragraphText);
    doc.add(Chunk.NEWLINE);
}

From source file:com.solidmaps.webapp.report.MapCivilPdfGenerator.java

License:Open Source License

private void createProductsTable(Document doc) throws DocumentException {

    DecimalFormat dc = new DecimalFormat("########0.00");

    // specify column widths
    float[] columnWidths = { 2f, 2f, 2f, 2f, 2f, 2.5f };
    // create PDF table with the given widths
    PdfPTable table = new PdfPTable(columnWidths);
    // set table width a percentage of the page width
    table.setWidthPercentage(100f);/*w w  w  .ja v a2  s.  com*/

    // insert column headings
    insertCell(table, "PRODUTO", Element.ALIGN_CENTER, fontHeaderTable);
    insertCell(table, "SALDO DO TRIMESTRE ANTERIOR", Element.ALIGN_CENTER, fontHeaderTableSmall);
    insertCell(table, "COMPRAS", Element.ALIGN_CENTER, fontHeaderTable);
    insertCell(table, "VENDAS", Element.ALIGN_CENTER, fontHeaderTable);
    insertCell(table, "CONSUMO", Element.ALIGN_CENTER, fontHeaderTable);
    insertCell(table, "ESTOQUE PARA O TRIMESTRE SEGUINTE", Element.ALIGN_CENTER, fontHeaderTableSmall);

    table.setHeaderRows(1);

    for (InvoiceInventoryMapEntity productMap : listProductMapVO) {

        BigDecimal qtdNextPeriod = productMap.getQtdInventoryPreviusTrimester()
                .add(productMap.getQtdBuyProduct()).subtract(productMap.getQtdSellProduct())
                .subtract(productMap.getQtdUtilization());

        // Cria a tabela com os Produtos
        insertCell(table, productMap.getProduct().getName(), Element.ALIGN_CENTER, fontHeaderTableSmall);
        insertCell(table, dc.format(productMap.getQtdInventoryPreviusTrimester()), Element.ALIGN_CENTER,
                fontHeaderTableSmall);
        insertCell(table, dc.format(productMap.getQtdBuyProduct()), Element.ALIGN_CENTER, fontHeaderTableSmall);
        insertCell(table, dc.format(productMap.getQtdSellProduct()), Element.ALIGN_CENTER,
                fontHeaderTableSmall);
        insertCell(table, dc.format(productMap.getQtdUtilization()), Element.ALIGN_CENTER,
                fontHeaderTableSmall);
        insertCell(table, dc.format(qtdNextPeriod), Element.ALIGN_CENTER, fontHeaderTableSmall);
    }

    doc.add(table);
}

From source file:com.solidmaps.webapp.report.MapCivilPdfGenerator.java

License:Open Source License

private void createInvoiceTable(Document doc) throws DocumentException {

    doc.add(Chunk.NEWLINE);

    // Ajusta o cabealho
    float[] columnHeader = { 1f };
    PdfPTable tableHeader = new PdfPTable(columnHeader);
    tableHeader.setWidthPercentage(100f);
    insertCell(tableHeader, "\n RELAO DE COMPRAS DURANTE  O TRIMESTRE \n", Element.ALIGN_CENTER, fontText);

    doc.add(tableHeader);/* w  ww  .  j  a v a  2  s  . co m*/

    doc.add(Chunk.NEWLINE);

    // specify column widths
    float[] columnWidths = { 2f, 2f, 2f, 2f, 2f, 2f, 2.5f, 2f };
    // create PDF table with the given widths
    PdfPTable table = new PdfPTable(columnWidths);
    // set table width a percentage of the page width
    table.setWidthPercentage(100f);

    // insert column headings
    insertCell(table, "Data:", Element.ALIGN_CENTER, fontHeaderTable);
    insertCell(table, "Empresa Vendedora", Element.ALIGN_CENTER, fontHeaderTable);
    insertCell(table, "Endereo", Element.ALIGN_CENTER, fontHeaderTable);
    insertCell(table, "Cidade/UF", Element.ALIGN_CENTER, fontHeaderTable);
    insertCell(table, "CEP", Element.ALIGN_CENTER, fontHeaderTable);
    insertCell(table, "N. nota Fiscal", Element.ALIGN_CENTER, fontHeaderTable);
    insertCell(table, "Produto", Element.ALIGN_CENTER, fontHeaderTable);
    insertCell(table, "Quantidade", Element.ALIGN_CENTER, fontHeaderTable);

    table.setHeaderRows(1);

    for (InvoiceProductEntity invoiceProduct : this.listInvoices) {
        insertCell(table, DateUtils.format(invoiceProduct.getInvoice().getDateCreate()), Element.ALIGN_CENTER,
                fontHeaderTable);
        insertCell(table, invoiceProduct.getInvoice().getProvider().getCnpj(), Element.ALIGN_CENTER,
                fontHeaderTable);
        insertCell(table, invoiceProduct.getInvoice().getProvider().getStreet(), Element.ALIGN_CENTER,
                fontHeaderTable);
        insertCell(table, invoiceProduct.getInvoice().getProvider().getCity(), Element.ALIGN_CENTER,
                fontHeaderTable);
        insertCell(table, invoiceProduct.getInvoice().getProvider().getCep(), Element.ALIGN_CENTER,
                fontHeaderTable);
        insertCell(table, invoiceProduct.getInvoice().getNumInvoice(), Element.ALIGN_CENTER, fontHeaderTable);
        insertCell(table, invoiceProduct.getProduct().getProductOfficial().getName(), Element.ALIGN_CENTER,
                fontHeaderTable);
        insertCell(table, invoiceProduct.getQtdProduct() + invoiceProduct.getTypeQtdProduct(),
                Element.ALIGN_CENTER, fontHeaderTable);
    }

    doc.add(table);
}

From source file:com.solidmaps.webapp.report.MapExercitoPdfGenerator.java

License:Open Source License

private void createFooter(Document doc) throws DocumentException {

    Calendar cal = Calendar.getInstance();
    PdfPTable table = new PdfPTable(1);
    table.setWidthPercentage(100f);/*from  ww w  .  java  2s  .c o  m*/

    table.setHeaderRows(0);

    table.getDefaultCell().setBorder(PdfPCell.NO_BORDER);

    StringBuilder sbData = new StringBuilder();
    sbData.append(company.getCity()).append(" / ").append(company.getState()).append(", ")
            .append(cal.get(Calendar.DAY_OF_MONTH)).append(" de ").append(DateUtils.getMonthName(cal))
            .append(" de ").append(cal.get(Calendar.YEAR)).append("\n\n");

    insertCell(table, sbData.toString(), Element.ALIGN_RIGHT, fontHeaderTableBig, false);

    insertCell(table, "_________________________________________________ \n Nome: "
            + company.getUserResponsable().getName() + " \n Cargo: " + company.getUserResponsable().getOffice(),
            Element.ALIGN_RIGHT, fontHeaderTable, false);

    doc.add(Chunk.NEWLINE);

    doc.add(table);
}

From source file:com.solidmaps.webapp.report.MapExercitoPdfGenerator.java

License:Open Source License

private void createParagraph(Document doc) throws DocumentException {

    StringBuilder sbParagraph = new StringBuilder().append("EXCELENT?SSIMO SENHOR \n").append("COMANDANTE DA ")
            .append(company.getRegion()).append(" REGIO MILITAR \n").append(company.getCity().toUpperCase())
            .append(", ").append(company.getState());

    Paragraph paragraph = new Paragraph(sbParagraph.toString());
    paragraph.setFont(fontParagraph);// w  w  w  .  j  a  v  a  2  s  .  co  m

    Paragraph paragraphText = new Paragraph("A firma: " + company.getName() + ", estabelecida  "
            + company.getState() + ", na Cidade " + company.getCity()
            + ", portadora do Certificado de Registro N " + license.getNumRegister() + ", vlido at "
            + DateUtils.format(license.getDateExpiration())
            + ", apresenta  V.Exa. o MAPA TRIMESTRAL DE ESTOCAGEM " + "DE PRODUTOS CONTROLADOS referente ao "
            + TrimesterEnum.getById(mapProduct.getNumTrimester()).getId() + " trimestre " + "de "
            + mapProduct.getYear()
            + ", de acordo com o Regulamento aprovado pelo Decreto N 3.665 de 20 de novembro de 2000, "
            + "para Fiscalizao de Produtos Controlados (R-105). CNPJ " + company.getCnpjFormatted());
    paragraphText.setFont(fontText);

    doc.add(paragraph);
    doc.add(Chunk.NEWLINE);
    doc.add(paragraphText);
    doc.add(Chunk.NEWLINE);
}

From source file:com.solidmaps.webapp.report.MapExercitoPdfGenerator.java

License:Open Source License

private void createProductsTable(Document doc) throws DocumentException {

    Paragraph paragraph = new Paragraph("RESUMO GERAL");
    paragraph.setFont(fontText);// w  w w. ja  va 2  s.  c o m

    DecimalFormat dc = new DecimalFormat("########0.00");

    // specify column widths
    float[] columnWidths = { 2f, 2f, 2f, 2f, 2f, 2f, 2.5f };
    // create PDF table with the given widths
    PdfPTable table = new PdfPTable(columnWidths);
    // set table width a percentage of the page width
    table.setWidthPercentage(100f);

    // insert column headings
    insertCell(table, "PRODUTO:", Element.ALIGN_CENTER, fontHeaderTable);
    insertCell(table, "GUIA DE TR?FEGO N:", Element.ALIGN_CENTER, fontHeaderTable);
    insertCell(table, "ENTRADA", Element.ALIGN_CENTER, fontHeaderTable);
    insertCell(table, "ESTOQUE DO TRIMESTRE ANTERIOR", Element.ALIGN_CENTER, fontHeaderTableSmall);
    insertCell(table, "CONSUMO", Element.ALIGN_CENTER, fontHeaderTable);
    insertCell(table, "ESTOQUE PARA O TRIMESTRE SEGUINTE", Element.ALIGN_CENTER, fontHeaderTableSmall);
    insertCell(table, "PROCEDNCIA (RAZO SOCIAL, ENDEREO,CIDADE, CEP, E  N.DO CERTIFICADO DE REGISTRO)",
            Element.ALIGN_CENTER, fontHeaderTableTiny);

    table.setHeaderRows(1);

    for (InvoiceInventoryMapEntity productMap : listProductMapVO) {

        String companyCell = "PROCEDNCIA (" + company.getName() + ", " + company.getStreet() + ", "
                + company.getCity() + ", " + company.getCep() + ", " + license.getNumRegister() + ")";

        // Calcula o estoque para o Trimestre seguinte
        BigDecimal qtdNextPeriod = productMap.getQtdInventoryPreviusTrimester()
                .add(productMap.getQtdBuyProduct()).subtract(productMap.getQtdSellProduct())
                .subtract(productMap.getQtdUtilization());

        // Cria a tabela com os Produtos
        insertCell(table, productMap.getProduct().getName(), Element.ALIGN_CENTER, fontHeaderTableSmall);
        insertCell(table, productMap.getTrafficGuide(), Element.ALIGN_CENTER, fontHeaderTableSmall);
        insertCell(table, dc.format(productMap.getQtdBuyProduct()), Element.ALIGN_CENTER, fontHeaderTableSmall);
        insertCell(table, dc.format(productMap.getQtdInventoryPreviusTrimester()), Element.ALIGN_CENTER,
                fontHeaderTableSmall);
        insertCell(table, dc.format(productMap.getQtdUtilization()), Element.ALIGN_CENTER,
                fontHeaderTableSmall);
        insertCell(table, dc.format(qtdNextPeriod), Element.ALIGN_CENTER, fontHeaderTableSmall);
        insertCell(table, companyCell, Element.ALIGN_CENTER, fontHeaderTableSmall);
    }

    doc.add(paragraph);
    doc.add(table);

    doc.add(Chunk.NEWLINE);
}

From source file:com.solidmaps.webapp.report.RenovationRequireExercitoPDF.java

private void createParagraph(Document doc, LicenseEXEntity license) throws DocumentException {

    StringBuilder sbHeader = new StringBuilder().append("Exmo Sr Comandante da ")
            .append(license.getCompany().getRegion()).append(" Regio Militar");

    StringBuilder sbParagraph = new StringBuilder().append(license.getCompany().getName())
            .append(", estabelecida em ").append(license.getCompany().getCity()).append("/")
            .append(license.getCompany().getState()).append(",  ").append(license.getCompany().getStreet())
            .append(", telefone n ").append(license.getCompany().getUserResponsable().getPhoneDDD())
            .append(" ").append(license.getCompany().getUserResponsable().getPhoneNumber())
            .append(", representada, neste ato, por seu proprietrio (scio ou diretor, etc.), ")
            .append(license.getCompany().getUserResponsable().getName()).append(", ")
            .append(license.getCompany().getUserResponsable().getCountry()).append(", ")
            .append(license.getCompany().getUserResponsable().getMaritalStatus()).append(", ")
            .append(license.getCompany().getUserResponsable().getOffice()).append(", ")
            .append(" (domiciliado ) ").append(license.getCompany().getUserResponsable().getStreet())
            .append(", vem, pelo presente, requerer  V Exa. (concesso ou revalidao) do Certificado de Registro n ")
            .append(license.getNumRegister())
            .append(", de acordo com o art. 84 do Regulamento para a Fiscalizao de ")
            .append("Produtos Controlados (R-105), para importar, comerciar (ou manipular, utilizar industrialmente, ou o que for) ")
            .append("com armas, munies, plvora para caa (ou explosivos, produtos qumicos controlados), durante o trinio ")
            .append(DateUtils.format(license.getDateExpiration())).append(" - ")
            .append(DateUtils.format(DateUtils.addYear(license.getDateExpiration(), 3)));

    // Anexo/*from  w  ww  .  java2 s  .co m*/
    Paragraph paragraphHeaderAnexo = new Paragraph("ANEXO XVI");
    paragraphHeaderAnexo.setFont(FONT_HEADER);
    paragraphHeaderAnexo.setAlignment(Element.ALIGN_CENTER);

    // Texto cabealho
    Paragraph paragraphHeaderText = new Paragraph(
            "REQUERIMENTO PARA CONCESSO E REVALIDAO DE CERTIFICADO DE REGISTRO");
    paragraphHeaderText.setFont(FONT_HEADER);
    paragraphHeaderText.setAlignment(Element.ALIGN_CENTER);

    // Texto Comandante
    Paragraph paragraphComand = new Paragraph(sbHeader.toString());
    paragraphComand.setFont(FONT_PARAGRAPH);

    // Texto impresso
    Paragraph paragraphPrint = new Paragraph("(Impresso em papel liso com 16 espaos simples)");
    paragraphPrint.setFont(FONT_PARAGRAPH);

    // Texto da Empresa
    Paragraph paragraphCompany = new Paragraph(sbParagraph.toString());
    paragraphCompany.setFont(FONT_PARAGRAPH);

    // Texto Footer
    Paragraph paragraphFooter = new Paragraph("Nestes termos, pede deferimento");
    paragraphCompany.setFont(FONT_PARAGRAPH);

    // Texto data
    Paragraph paragraphDate = new Paragraph(DateUtils.format(Calendar.getInstance()));
    paragraphDate.setFont(FONT_PARAGRAPH);

    doc.add(paragraphHeaderAnexo);
    doc.add(Chunk.NEWLINE);
    doc.add(paragraphHeaderText);
    doc.add(Chunk.NEWLINE);
    doc.add(paragraphComand);
    doc.add(Chunk.NEWLINE);
    doc.add(paragraphPrint);
    doc.add(Chunk.NEWLINE);
    doc.add(paragraphCompany);
    doc.add(Chunk.NEWLINE);
    doc.add(Chunk.NEWLINE);
    doc.add(Chunk.NEWLINE);
    doc.add(paragraphFooter);
    doc.add(Chunk.NEWLINE);
    doc.add(paragraphDate);
    doc.add(Chunk.NEWLINE);

}

From source file:com.solidmaps.webapp.report.RequerimentAlterLicenseExercitoPDF.java

private void createParagraph(Document doc, LicenseEXEntity license) throws DocumentException {

    StringBuilder sbHeader = new StringBuilder().append("Exmo Sr Comandante da ")
            .append(license.getCompany().getRegion()).append(" Regio Militar");

    StringBuilder sbParagraph = new StringBuilder().append(license.getCompany().getName().toUpperCase())
            .append(", incrita sob o CNPJ n ").append(license.getCompany().getCnpj())
            .append(", estabelecida na cidade de ").append(license.getCompany().getCity().toUpperCase())
            .append("/").append(license.getCompany().getState()).append(",  ")
            .append(license.getCompany().getStreet()).append(", CEP ").append(license.getCompany().getCep())
            .append(", email: ").append(license.getUserResponsable().getEmail()).append(", fone/fax ")
            .append(license.getUserResponsable().getPhoneDDD()).append(" ")
            .append(license.getUserResponsable().getPhoneNumber()).append(" representada neste ato por seu ")
            .append(license.getCompany().getUserResponsable().getOffice()).append(", Sr ")
            .append(license.getCompany().getUserResponsable().getName()).append(", inscrito sob o CPF: ")
            .append(license.getCompany().getUserResponsable().getCpf())
            .append(", portador da cdula de identidade (RG): ")
            .append(license.getCompany().getUserResponsable().getRg()).append(", de nacionalidade ")
            .append(license.getCompany().getUserResponsable().getCountry()).append(", estado civil ")
            .append(license.getCompany().getUserResponsable().getMaritalStatus())
            .append(" profisso Engenheiro Qumico, domiciliado a ")
            .append(license.getCompany().getUserResponsable().getStreet())
            .append(license.getCompany().getUserResponsable().getStreet()).append(" CEP ")
            .append(license.getCompany().getUserResponsable().getCep());

    if (license.getCompany().getProcuratorEntity() != null) {
        sbParagraph.append(" e seus procuradores, conforme procurao anexo, Sr ")
                .append(license.getCompany().getProcuratorEntity().getName()).append(" inscrito sob o CPF n: ")
                .append(license.getCompany().getProcuratorEntity().getCpf())
                .append(" portador da cdula de identidade (RG) n: ")
                .append(license.getCompany().getProcuratorEntity().getRg()).append(" ")
                .append(license.getCompany().getProcuratorEntity().getRgExpeditionCity());

    }//  ww  w  . ja  va2  s . c o m

    sbParagraph.append(", vem pelo presente, requerer  V Ex.a ");

    // Texto cabealho
    Paragraph paragraphHeaderText = new Paragraph(
            "REQUERIMENTO PARA APOSTILAMENTO DE CERTIFICADO DE REGISTRO - PJ");
    paragraphHeaderText.setFont(FONT_HEADER);
    paragraphHeaderText.setAlignment(Element.ALIGN_CENTER);

    // Texto Comandante
    Paragraph paragraphComand = new Paragraph(sbHeader.toString());
    paragraphComand.setFont(FONT_PARAGRAPH);

    // Texto da Empresa
    Paragraph paragraphCompany = new Paragraph(sbParagraph.toString());
    paragraphCompany.setFont(FONT_PARAGRAPH);

    doc.add(paragraphHeaderText);
    doc.add(Chunk.NEWLINE);
    doc.add(paragraphComand);
    doc.add(Chunk.NEWLINE);
    doc.add(paragraphCompany);
    doc.add(Chunk.NEWLINE);

}