Example usage for com.itextpdf.text.pdf PdfPTable setHeaderRows

List of usage examples for com.itextpdf.text.pdf PdfPTable setHeaderRows

Introduction

In this page you can find the example usage for com.itextpdf.text.pdf PdfPTable setHeaderRows.

Prototype

public void setHeaderRows(int headerRows) 

Source Link

Document

Sets the number of the top rows that constitute the header.

Usage

From source file:com.quix.aia.cn.imo.mapper.ApplicationFormPDFMaintenance.java

License:Open Source License

private static Document familyInformation(Document document, PdfWriter writer, AddressBook addressbook) {
    // TODO Auto-generated method stub
    log.log(Level.INFO, "ApplicationFormPDFMaintenance --> familyInformation ");
    try {/* ww  w.j  a  v a2s  .co m*/

        /*  New Page   */
        document.newPage();

        PdfPTable table = new PdfPTable(3);
        table.setSpacingBefore(10);
        table.setWidthPercentage(100f);
        //Set familylist=addressbook.getCandidateFamilyInfos();

        int i = 0;
        for (Iterator itr = addressbook.getCandidateFamilyInfos().iterator(); itr.hasNext();) {
            CandidateFamilyInfo candidateFamilyInfo = (CandidateFamilyInfo) itr.next();
            if (i != 0) {
                PdfPCell c1 = new PdfPCell(new Phrase(" ", font));
                c1.setBorder(Rectangle.NO_BORDER);
                c1.setLeading(4f, 0f);
                c1.setFixedHeight(15f);
                table.addCell(c1);

                c1 = new PdfPCell(new Phrase(" ", font));
                c1.setBorder(Rectangle.NO_BORDER);
                c1.setLeading(4f, 0f);
                c1.setFixedHeight(15f);
                table.addCell(c1);

                c1 = new PdfPCell(new Phrase(" ", font));
                c1.setBorder(Rectangle.NO_BORDER);
                c1.setLeading(4f, 0f);
                c1.setFixedHeight(15f);
                table.addCell(c1);
            }

            i++;
            PdfPCell c1 = new PdfPCell(new Phrase("FAMILY INFORMATION"));
            c1.setHorizontalAlignment(Element.ALIGN_LEFT);
            c1.setColspan(4);
            c1.setBorder(Rectangle.LEFT | Rectangle.RIGHT | Rectangle.TOP);
            c1.setFixedHeight(30f);
            c1.setBackgroundColor(BaseColor.LIGHT_GRAY);
            c1.setBorder(Rectangle.BOX);
            c1.setFixedHeight(25f);
            table.addCell(c1);
            table.setHeaderRows(1);

            for (int j = 0; j < 3; j++) {
                c1 = new PdfPCell(new Phrase(" ", font));
                c1.setBorder(Rectangle.NO_BORDER);
                c1.setLeading(4f, 0f);
                c1.setFixedHeight(15f);
                table.addCell(c1);

            }

            c1 = new PdfPCell(new Phrase("Name: " + candidateFamilyInfo.getName(), font));
            c1.setBorder(Rectangle.NO_BORDER);
            c1.setLeading(4f, 0f);
            c1.setFixedHeight(15f);
            c1.setBorder(Rectangle.BOTTOM);
            table.addCell(c1);

            c1 = new PdfPCell(new Phrase("Unit: " + candidateFamilyInfo.getUnit(), font));
            c1.setBorder(Rectangle.NO_BORDER);
            c1.setLeading(4f, 0f);
            c1.setFixedHeight(15f);
            c1.setBorder(Rectangle.BOTTOM);
            table.addCell(c1);

            c1 = new PdfPCell(new Phrase("Possition: " + candidateFamilyInfo.getPosition(), font));
            c1.setBorder(Rectangle.NO_BORDER);
            c1.setLeading(4f, 0f);
            c1.setFixedHeight(15f);
            c1.setBorder(Rectangle.BOTTOM);
            table.addCell(c1);

            for (int j = 0; j < 3; j++) {
                c1 = new PdfPCell(new Phrase(" ", font));
                c1.setBorder(Rectangle.NO_BORDER);
                c1.setLeading(4f, 0f);
                c1.setFixedHeight(15f);
                table.addCell(c1);

            }

            c1 = new PdfPCell(new Phrase("Relationship : " + candidateFamilyInfo.getRelationship(), font));
            c1.setBorder(Rectangle.NO_BORDER);
            c1.setLeading(4f, 0f);
            c1.setFixedHeight(15f);
            c1.setBorder(Rectangle.BOTTOM);
            table.addCell(c1);

            c1 = new PdfPCell(new Phrase("Occupation : " + candidateFamilyInfo.getOccupation(), font));
            c1.setBorder(Rectangle.NO_BORDER);
            c1.setLeading(4f, 0f);
            c1.setFixedHeight(15f);
            c1.setBorder(Rectangle.BOTTOM);
            table.addCell(c1);

            c1 = new PdfPCell(new Phrase("Phone : " + candidateFamilyInfo.getPhoneNo(), font));
            c1.setBorder(Rectangle.NO_BORDER);
            c1.setLeading(4f, 0f);
            c1.setFixedHeight(15f);
            c1.setBorder(Rectangle.BOTTOM);
            table.addCell(c1);

        }

        document.add(table);
    } catch (Exception e) {
        // TODO Auto-generated catch block
        log.log(Level.INFO, "ApplicationFormPDFMaintenance --> familyInformation " + e.getMessage());
        e.printStackTrace();
        e.printStackTrace();
        LogsMaintenance logsMain = new LogsMaintenance();
        StringWriter errors = new StringWriter();
        e.printStackTrace(new PrintWriter(errors));
        logsMain.insertLogs("ApplicationFormPDFMaintenance", Level.SEVERE + "", errors.toString());
    }
    return document;
}

From source file:com.quix.aia.cn.imo.mapper.ApplicationFormPDFMaintenance.java

License:Open Source License

private static Document personalInformation(Document document, PdfWriter writer, AddressBook addressbook,
        Font normalFontCH) {//from  w ww  .  ja  va  2s  .co  m
    // TODO Auto-generated method stub
    log.log(Level.INFO, "ApplicationFormPDFMaintenance --> personalInformation ");
    try {

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

        PdfPCell c1 = new PdfPCell(new Phrase("PERSONAL INFORMATION"));
        c1.setHorizontalAlignment(Element.ALIGN_LEFT);
        c1.setColspan(4);
        c1.setBorder(Rectangle.LEFT | Rectangle.RIGHT | Rectangle.TOP);
        c1.setFixedHeight(30f);
        c1.setBackgroundColor(BaseColor.LIGHT_GRAY);
        c1.setBorder(Rectangle.BOX);
        c1.setFixedHeight(25f);
        table.addCell(c1);
        table.setHeaderRows(1);

        for (int j = 0; j < 2; j++) {
            c1 = new PdfPCell(new Phrase(" ", font));
            c1.setBorder(Rectangle.NO_BORDER);
            c1.setLeading(4f, 0f);
            c1.setFixedHeight(15f);
            table.addCell(c1);

        }

        c1 = new PdfPCell(new Phrase("Candidate's Name: " + addressbook.getName(), font));
        c1.setBorder(Rectangle.NO_BORDER);
        c1.setLeading(4f, 0f);
        c1.setFixedHeight(15f);
        //c1.setPaddingLeft(30f);
        c1.setBorder(Rectangle.NO_BORDER);
        table.addCell(c1);

        c1 = new PdfPCell(new Phrase("NRIC: " + addressbook.getNric(), font));
        c1.setFixedHeight(15f);
        c1.setBorder(Rectangle.NO_BORDER);
        c1.setLeading(4f, 0f);
        table.addCell(c1);

        c1 = new PdfPCell(new Phrase("??*  ", normalFontCH));
        c1.setBorder(Rectangle.NO_BORDER);
        c1.setLeading(4f, 0f);
        c1.setFixedHeight(15f);
        c1.setBorder(Rectangle.BOTTOM);
        table.addCell(c1);

        c1 = new PdfPCell(new Phrase("???(*) ", normalFontCH));
        c1.setBorder(Rectangle.NO_BORDER);
        c1.setLeading(4f, 0f);
        c1.setFixedHeight(15f);
        c1.setBorder(Rectangle.BOTTOM);
        table.addCell(c1);

        for (int j = 0; j < 2; j++) {
            c1 = new PdfPCell(new Phrase(" ", font));
            c1.setBorder(Rectangle.NO_BORDER);
            c1.setLeading(4f, 0f);
            c1.setFixedHeight(15f);
            table.addCell(c1);

        }

        c1 = new PdfPCell(new Phrase("Date of Birth: " + format.format(addressbook.getBirthDate()), font));
        c1.setBorder(Rectangle.NO_BORDER);
        c1.setLeading(4f, 0f);
        c1.setFixedHeight(15f);
        //c1.setPaddingLeft(30f);
        c1.setBorder(Rectangle.NO_BORDER);
        table.addCell(c1);

        c1 = new PdfPCell(new Phrase("Gender: " + addressbook.getGender(), font));
        c1.setFixedHeight(15f);
        c1.setBorder(Rectangle.NO_BORDER);
        c1.setLeading(4f, 0f);
        table.addCell(c1);

        c1 = new PdfPCell(new Phrase("*", normalFontCH));
        c1.setBorder(Rectangle.NO_BORDER);
        c1.setLeading(4f, 0f);
        c1.setFixedHeight(15f);
        c1.setBorder(Rectangle.BOTTOM);
        table.addCell(c1);

        c1 = new PdfPCell(new Phrase("*", normalFontCH));
        c1.setBorder(Rectangle.NO_BORDER);
        c1.setLeading(4f, 0f);
        c1.setFixedHeight(15f);
        c1.setBorder(Rectangle.BOTTOM);
        table.addCell(c1);

        for (int j = 0; j < 2; j++) {
            c1 = new PdfPCell(new Phrase(" ", font));
            c1.setBorder(Rectangle.NO_BORDER);
            c1.setLeading(4f, 0f);
            c1.setFixedHeight(15f);
            table.addCell(c1);

        }

        c1 = new PdfPCell(new Phrase("Age: " + addressbook.getAge(), font));
        c1.setBorder(Rectangle.NO_BORDER);
        c1.setLeading(4f, 0f);
        c1.setFixedHeight(15f);
        //c1.setPaddingLeft(30f);
        c1.setBorder(Rectangle.NO_BORDER);
        table.addCell(c1);

        c1 = new PdfPCell(new Phrase("Place of Birth: " + addressbook.getBirthPlace(), font));
        c1.setFixedHeight(15f);
        c1.setBorder(Rectangle.NO_BORDER);
        c1.setLeading(4f, 0f);
        table.addCell(c1);

        c1 = new PdfPCell(new Phrase("(*)", normalFontCH));
        c1.setLeading(4f, 0f);
        c1.setFixedHeight(15f);
        c1.setBorder(Rectangle.BOTTOM);
        table.addCell(c1);

        c1 = new PdfPCell(new Phrase("", normalFontCH));
        c1.setLeading(4f, 0f);
        c1.setFixedHeight(15f);
        c1.setBorder(Rectangle.BOTTOM);
        table.addCell(c1);

        for (int j = 0; j < 2; j++) {
            c1 = new PdfPCell(new Phrase(" ", font));
            c1.setBorder(Rectangle.NO_BORDER);
            c1.setLeading(4f, 0f);
            c1.setFixedHeight(15f);
            table.addCell(c1);

        }

        c1 = new PdfPCell(new Phrase("Education: " + addressbook.getEducation(), font));
        c1.setBorder(Rectangle.NO_BORDER);
        c1.setLeading(4f, 0f);
        c1.setFixedHeight(15f);
        //c1.setPaddingLeft(30f);
        c1.setBorder(Rectangle.NO_BORDER);
        table.addCell(c1);

        c1 = new PdfPCell(new Phrase("Maritial Status: " + addressbook.getMarritalStatus(), font));
        c1.setFixedHeight(15f);
        c1.setBorder(Rectangle.NO_BORDER);
        c1.setLeading(4f, 0f);
        table.addCell(c1);

        c1 = new PdfPCell(new Phrase("*", normalFontCH));
        c1.setLeading(4f, 0f);
        c1.setFixedHeight(15f);
        c1.setBorder(Rectangle.BOTTOM);
        table.addCell(c1);

        c1 = new PdfPCell(new Phrase("*", normalFontCH));
        c1.setLeading(4f, 0f);
        c1.setFixedHeight(15f);
        c1.setBorder(Rectangle.BOTTOM);
        table.addCell(c1);

        for (int j = 0; j < 2; j++) {
            c1 = new PdfPCell(new Phrase(" ", font));
            c1.setBorder(Rectangle.NO_BORDER);
            c1.setLeading(4f, 0f);
            c1.setFixedHeight(15f);
            table.addCell(c1);

        }

        c1 = new PdfPCell(new Phrase("Annual Income: " + addressbook.getYearlyIncome(), font));
        c1.setBorder(Rectangle.NO_BORDER);
        c1.setLeading(4f, 0f);
        c1.setFixedHeight(15f);
        //c1.setPaddingLeft(30f);
        c1.setBorder(Rectangle.NO_BORDER);
        table.addCell(c1);

        c1 = new PdfPCell(new Phrase("Work Experience:  " + addressbook.getWorkingYearExperience(), font));
        c1.setFixedHeight(15f);
        c1.setBorder(Rectangle.NO_BORDER);
        c1.setLeading(4f, 0f);
        table.addCell(c1);

        c1 = new PdfPCell(new Phrase("*", normalFontCH));
        c1.setLeading(4f, 0f);
        c1.setFixedHeight(15f);
        c1.setBorder(Rectangle.BOTTOM);
        table.addCell(c1);

        c1 = new PdfPCell(new Phrase("*", normalFontCH));
        c1.setLeading(4f, 0f);
        c1.setFixedHeight(15f);
        c1.setBorder(Rectangle.BOTTOM);
        table.addCell(c1);

        for (int j = 0; j < 2; j++) {
            c1 = new PdfPCell(new Phrase(" ", font));
            c1.setBorder(Rectangle.NO_BORDER);
            c1.setLeading(4f, 0f);
            c1.setFixedHeight(15f);
            table.addCell(c1);

        }

        c1 = new PdfPCell(new Phrase(
                "Address : " + addressbook.getResidentialAddress1() + " ,"
                        + addressbook.getResidentialAddress2() + " , " + addressbook.getResidentialAddress3(),
                font));
        c1.setBorder(Rectangle.NO_BORDER);
        c1.setLeading(4f, 0f);
        c1.setFixedHeight(15f);
        //c1.setPaddingLeft(30f);
        c1.setBorder(Rectangle.NO_BORDER);
        table.addCell(c1);

        c1 = new PdfPCell(new Phrase(" ", font));
        c1.setBorder(Rectangle.NO_BORDER);
        c1.setLeading(4f, 0f);
        c1.setFixedHeight(15f);
        table.addCell(c1);

        c1 = new PdfPCell(new Phrase("??*", normalFontCH));
        c1.setLeading(4f, 0f);
        c1.setFixedHeight(15f);
        c1.setBorder(Rectangle.BOTTOM);
        table.addCell(c1);

        c1 = new PdfPCell(new Phrase(" ", normalFontCH));
        c1.setLeading(4f, 0f);
        c1.setFixedHeight(15f);
        c1.setBorder(Rectangle.BOTTOM);
        table.addCell(c1);

        for (int j = 0; j < 2; j++) {
            c1 = new PdfPCell(new Phrase(" ", font));
            c1.setBorder(Rectangle.NO_BORDER);
            c1.setLeading(4f, 0f);
            c1.setFixedHeight(15f);
            table.addCell(c1);

        }

        c1 = new PdfPCell(new Phrase("Postal Code: " + addressbook.getResidentialPostalCode(), font));
        c1.setBorder(Rectangle.NO_BORDER);
        c1.setLeading(4f, 0f);
        c1.setFixedHeight(15f);
        //c1.setPaddingLeft(30f);
        c1.setBorder(Rectangle.NO_BORDER);
        table.addCell(c1);

        c1 = new PdfPCell(new Phrase("Mobile Number: " + addressbook.getMobilePhoneNo(), font));
        c1.setFixedHeight(15f);
        c1.setBorder(Rectangle.NO_BORDER);
        c1.setLeading(4f, 0f);
        table.addCell(c1);

        c1 = new PdfPCell(new Phrase("??*", normalFontCH));
        c1.setLeading(4f, 0f);
        c1.setFixedHeight(15f);
        c1.setBorder(Rectangle.BOTTOM);
        table.addCell(c1);

        c1 = new PdfPCell(new Phrase(" ", normalFontCH));
        c1.setLeading(4f, 0f);
        c1.setFixedHeight(15f);
        c1.setBorder(Rectangle.BOTTOM);
        table.addCell(c1);

        for (int j = 0; j < 2; j++) {
            c1 = new PdfPCell(new Phrase(" ", font));
            c1.setBorder(Rectangle.NO_BORDER);
            c1.setLeading(4f, 0f);
            c1.setFixedHeight(15f);
            table.addCell(c1);

        }

        c1 = new PdfPCell(new Phrase("Email Address: " + addressbook.geteMailId(), font));
        c1.setBorder(Rectangle.NO_BORDER);
        c1.setLeading(4f, 0f);
        c1.setFixedHeight(15f);
        //c1.setPaddingLeft(30f);
        c1.setBorder(Rectangle.BOTTOM);
        table.addCell(c1);

        c1 = new PdfPCell(new Phrase(" ", font));
        c1.setFixedHeight(15f);
        c1.setBorder(Rectangle.BOTTOM);
        c1.setLeading(4f, 0f);
        table.addCell(c1);

        document.add(table);
    } catch (Exception e) {
        // TODO Auto-generated catch block
        log.log(Level.INFO, "ApplicationFormPDFMaintenance --> personalInformation " + e.getMessage());
        e.printStackTrace();
        e.printStackTrace();
        LogsMaintenance logsMain = new LogsMaintenance();
        StringWriter errors = new StringWriter();
        e.printStackTrace(new PrintWriter(errors));
        logsMain.insertLogs("ApplicationFormPDFMaintenance", Level.SEVERE + "", errors.toString());
    }
    return document;
}

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   www .j av a 2s.c  om*/

    // 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 w  w. j  av  a  2  s .com*/
    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 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);//from   w w  w .  ja va 2  s  .c  o  m

    // 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);/*from  w  ww  .j a  v  a  2  s .co m*/

    // 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);

    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 www. j ava  2  s  .  co 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 createProductsTable(Document doc) throws DocumentException {

    Paragraph paragraph = new Paragraph("RESUMO GERAL");
    paragraph.setFont(fontText);/*from w  w  w.  jav  a  2s  .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.thomasmore.service.PdfCreateServiceImpl.java

public void readPdf() {
    try {//from w ww. jav a 2s .  c om
        OutputStream file = new FileOutputStream(new File("D:\\SamplePDFje.pdf"));

        Document document = new Document();
        PdfWriter.getInstance(document, file);

        document.open();
        document.add(new Paragraph("First iText PDF"));
        document.add(new Paragraph(new Date().toString()));

        document.addAuthor("Krishna Sfsfsfsn");
        document.addCreationDate();
        document.addCreator("JavaBeat");
        document.addTitle("Sample PDF");

        //Create Paragraph
        Paragraph paragraph = new Paragraph("Title 1", new Font(Font.FontFamily.TIMES_ROMAN, 18, Font.BOLD));

        //New line
        paragraph.add(new Paragraph(" "));
        paragraph.add("Test Paragraph");
        paragraph.add(new Paragraph(" "));
        document.add(paragraph);

        //Create a table in PDF
        PdfPTable pdfTable = new PdfPTable(3);
        PdfPCell cell1 = new PdfPCell(new Phrase("Table Header 1"));
        cell1.setHorizontalAlignment(Element.ALIGN_CENTER);
        pdfTable.addCell(cell1);

        cell1 = new PdfPCell(new Phrase("Table Header 2"));
        cell1.setHorizontalAlignment(Element.ALIGN_CENTER);
        pdfTable.addCell(cell1);

        cell1 = new PdfPCell(new Phrase("Table Header 3"));
        cell1.setHorizontalAlignment(Element.ALIGN_CENTER);
        pdfTable.addCell(cell1);
        pdfTable.setHeaderRows(1);

        pdfTable.addCell("Row 1 Col 1");
        pdfTable.addCell("Row 1 Col 2");
        pdfTable.addCell("Row 1 Col 3");

        pdfTable.addCell("Row 2 Col 1");
        pdfTable.addCell("Row 2 Col 2");
        pdfTable.addCell("Row 2 Col 3");

        document.add(pdfTable);

        document.close();
        file.close();

    } catch (Exception e) {

        e.printStackTrace();
    }
}

From source file:com.vectorprint.report.itext.style.stylers.Table.java

License:Open Source License

private PdfPTable style(PdfPTable t) throws VectorPrintException {
    super.style(t, null);
    t.setWidthPercentage(getRelwidth());

    try {/*from  w w  w .  ja  v a  2  s.c  om*/
        float[] w = getWidths();

        t.setWidths(w);
        t.setTotalWidth(w);
        t.setHeaderRows(getHeaderrows());
        t.setFooterRows(getFooterrows());
    } catch (DocumentException ex) {
        throw new VectorPrintException("number of widths differs from number of columns in table", ex);
    }

    return t;
}