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

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

Introduction

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

Prototype

public void setWidthPercentage(final float widthPercentage) 

Source Link

Document

Sets the width percentage that the table will occupy in the page.

Usage

From source file:com.dexter.fms.mbean.ReportsMBean.java

@SuppressWarnings("deprecation")
private PdfPTable exportPDFTable(int type) {
    int numberOfColumns = 0;
    PdfPTable pdfTable = null;
    switch (type) {
    case 1: // all users report
    {//from   w  ww .  ja  v  a  2 s .  c om
        numberOfColumns = 7;
        pdfTable = new PdfPTable(numberOfColumns);

        BaseFont helvetica = null;
        try {
            helvetica = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.EMBEDDED);
        } catch (Exception e) {
        }
        Font font = new Font(helvetica, 8, Font.BOLDITALIC);

        pdfTable.addCell(new Paragraph("User name", font));
        pdfTable.addCell(new Paragraph("Full name", font));
        pdfTable.addCell(new Paragraph("Email", font));
        pdfTable.addCell(new Paragraph("Department", font));
        pdfTable.addCell(new Paragraph("Region", font));
        pdfTable.addCell(new Paragraph("Phone", font));
        pdfTable.addCell(new Paragraph("Position", font));

        font = new Font(helvetica, 8, Font.NORMAL);

        if (getAllUsers() != null) {
            for (PartnerUser e : getAllUsers()) {
                pdfTable.addCell(new Paragraph(e.getUsername(), font));
                pdfTable.addCell(new Paragraph(
                        e.getPersonel().getFirstname() + " " + e.getPersonel().getLastname(), font));
                pdfTable.addCell(new Paragraph(e.getPersonel().getEmail(), font));
                pdfTable.addCell(new Paragraph(
                        (e.getPersonel().getDepartment() != null) ? e.getPersonel().getDepartment().getName()
                                : "N/A",
                        font));
                pdfTable.addCell(new Paragraph(
                        (e.getPersonel().getRegion() != null) ? e.getPersonel().getRegion().getName() : "N/A",
                        font));
                pdfTable.addCell(new Paragraph(e.getPersonel().getPhone(), font));
                pdfTable.addCell(new Paragraph(e.getPersonel().getPosition(), font));
            }
        }
        break;
    }
    case 2: // due driver's license
    {
        numberOfColumns = 6;
        pdfTable = new PdfPTable(numberOfColumns);

        BaseFont helvetica = null;
        try {
            helvetica = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.EMBEDDED);
        } catch (Exception e) {
        }
        Font font = new Font(helvetica, 8, Font.BOLDITALIC);

        pdfTable.addCell(new Paragraph("Full Name", font));
        pdfTable.addCell(new Paragraph("Dept", font));
        pdfTable.addCell(new Paragraph("Region", font));
        pdfTable.addCell(new Paragraph("Phone", font));
        pdfTable.addCell(new Paragraph("Position", font));
        pdfTable.addCell(new Paragraph("License Due Date", font));

        font = new Font(helvetica, 8, Font.NORMAL);

        if (getDueDriversLic() != null) {
            for (DriverLicense e : getDueDriversLic()) {
                pdfTable.addCell(new Paragraph(e.getDriver().getPersonel().getFirstname() + " "
                        + e.getDriver().getPersonel().getLastname(), font));
                pdfTable.addCell(new Paragraph(e.getDriver().getPersonel().getDepartment() != null
                        ? e.getDriver().getPersonel().getDepartment().getName()
                        : "N/A", font));
                pdfTable.addCell(new Paragraph(e.getDriver().getPersonel().getRegion() != null
                        ? e.getDriver().getPersonel().getRegion().getName()
                        : "N/A", font));
                pdfTable.addCell(new Paragraph(e.getDriver().getPersonel().getPhone(), font));
                pdfTable.addCell(new Paragraph(e.getDriver().getPersonel().getPosition(), font));
                pdfTable.addCell(new Paragraph(e.getLic_end_dt().toLocaleString(), font));
            }
        }
        break;
    }
    case 3: // accidents
    {
        numberOfColumns = 8;
        pdfTable = new PdfPTable(numberOfColumns);

        BaseFont helvetica = null;
        try {
            helvetica = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.EMBEDDED);
        } catch (Exception e) {
        }
        Font font = new Font(helvetica, 8, Font.BOLDITALIC);

        pdfTable.addCell(new Paragraph("Reg No.", font));
        pdfTable.addCell(new Paragraph("Accident Date", font));
        pdfTable.addCell(new Paragraph("Description", font));
        pdfTable.addCell(new Paragraph("Driver", font));
        pdfTable.addCell(new Paragraph("Driver Comment", font));
        pdfTable.addCell(new Paragraph("Police Officer", font));
        pdfTable.addCell(new Paragraph("Police Station", font));
        pdfTable.addCell(new Paragraph("Police Comment", font));

        font = new Font(helvetica, 8, Font.NORMAL);

        if (getVehicleAccidents() != null) {
            for (VehicleAccident e : getVehicleAccidents()) {
                pdfTable.addCell(new Paragraph(e.getVehicle().getRegistrationNo(), font));
                pdfTable.addCell(new Paragraph(e.getAccident_dt().toLocaleString(), font));
                pdfTable.addCell(new Paragraph(e.getAccidentDescription(), font));
                pdfTable.addCell(new Paragraph(e.getDriver_name(), font));
                pdfTable.addCell(new Paragraph(e.getDriverComment(), font));
                pdfTable.addCell(new Paragraph(e.getPoliceOfficer(), font));
                pdfTable.addCell(new Paragraph(e.getPoliceStation(), font));
                pdfTable.addCell(new Paragraph(e.getPoliceComment(), font));
            }
        }
        break;
    }
    case 4: // vehicles by brand
    {
        numberOfColumns = 4;
        pdfTable = new PdfPTable(numberOfColumns);

        BaseFont helvetica = null;
        try {
            helvetica = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.EMBEDDED);
        } catch (Exception e) {
        }
        Font font = new Font(helvetica, 8, Font.BOLDITALIC);

        pdfTable.addCell(new Paragraph("Make", font));
        pdfTable.addCell(new Paragraph("Model", font));
        pdfTable.addCell(new Paragraph("Year", font));
        pdfTable.addCell(new Paragraph("Reg No.", font));

        font = new Font(helvetica, 8, Font.NORMAL);

        if (getVehiclesByBrand() != null) {
            for (Vehicle e : getVehiclesByBrand()) {
                pdfTable.addCell(new Paragraph(e.getModel().getMaker().getName(), font));
                pdfTable.addCell(new Paragraph(e.getModel().getName(), font));
                pdfTable.addCell(new Paragraph(e.getModel().getYear(), font));
                pdfTable.addCell(new Paragraph(e.getRegistrationNo(), font));
            }
        }
        break;
    }
    case 5: // routine maintenance
    {
        numberOfColumns = 8;
        pdfTable = new PdfPTable(numberOfColumns);

        BaseFont helvetica = null;
        try {
            helvetica = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.EMBEDDED);
        } catch (Exception e) {
        }
        Font font = new Font(helvetica, 8, Font.BOLDITALIC);

        pdfTable.addCell(new Paragraph("Reg No.", font));
        pdfTable.addCell(new Paragraph("Requester", font));
        pdfTable.addCell(new Paragraph("Description", font));
        pdfTable.addCell(new Paragraph("Start Date", font));
        pdfTable.addCell(new Paragraph("Initial Cost", font));
        pdfTable.addCell(new Paragraph("Status", font));
        pdfTable.addCell(new Paragraph("Close Date", font));
        pdfTable.addCell(new Paragraph("Final Cost", font));

        font = new Font(helvetica, 8, Font.NORMAL);

        if (getRmaints() != null) {
            for (VehicleRoutineMaintenance e : getRmaints()) {
                pdfTable.addCell(new Paragraph(e.getVehicle().getRegistrationNo(), font));
                pdfTable.addCell(new Paragraph(e.getCreatedBy().getPersonel().getFirstname() + " "
                        + e.getCreatedBy().getPersonel().getLastname(), font));
                pdfTable.addCell(new Paragraph(e.getDescription(), font));
                pdfTable.addCell(new Paragraph(e.getStart_dt().toLocaleString(), font));
                pdfTable.addCell(new Paragraph(e.getInitial_amount().toPlainString(), font));
                pdfTable.addCell(new Paragraph(e.getStatus(), font));
                pdfTable.addCell(new Paragraph(e.getClose_dt().toLocaleString(), font));
                pdfTable.addCell(new Paragraph(e.getClosed_amount().toPlainString(), font));
            }
        }
        break;
    }
    case 6: // ad hoc maintenance
    {
        numberOfColumns = 8;
        pdfTable = new PdfPTable(numberOfColumns);

        BaseFont helvetica = null;
        try {
            helvetica = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.EMBEDDED);
        } catch (Exception e) {
        }
        Font font = new Font(helvetica, 8, Font.BOLDITALIC);

        pdfTable.addCell(new Paragraph("Reg No.", font));
        pdfTable.addCell(new Paragraph("Requester", font));
        pdfTable.addCell(new Paragraph("Description", font));
        pdfTable.addCell(new Paragraph("Start Date", font));
        pdfTable.addCell(new Paragraph("Initial Cost", font));
        pdfTable.addCell(new Paragraph("Status", font));
        pdfTable.addCell(new Paragraph("Close Date", font));
        pdfTable.addCell(new Paragraph("Final Cost", font));

        font = new Font(helvetica, 8, Font.NORMAL);

        if (getAdhocmaints() != null) {
            for (VehicleAdHocMaintenance e : getAdhocmaints()) {
                pdfTable.addCell(new Paragraph(e.getVehicle().getRegistrationNo(), font));
                pdfTable.addCell(new Paragraph(e.getCreatedBy().getPersonel().getFirstname() + " "
                        + e.getCreatedBy().getPersonel().getLastname(), font));
                pdfTable.addCell(new Paragraph(e.getDescription(), font));
                pdfTable.addCell(new Paragraph(e.getStart_dt().toLocaleString(), font));
                pdfTable.addCell(new Paragraph(e.getInitial_cost().toPlainString(), font));
                pdfTable.addCell(new Paragraph(e.getStatus(), font));
                pdfTable.addCell(new Paragraph(e.getClose_dt().toLocaleString(), font));
                pdfTable.addCell(new Paragraph(e.getClosed_cost().toPlainString(), font));
            }
        }
        break;
    }
    case 7: // active accidents
    {
        numberOfColumns = 8;
        pdfTable = new PdfPTable(numberOfColumns);

        BaseFont helvetica = null;
        try {
            helvetica = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.EMBEDDED);
        } catch (Exception e) {
        }
        Font font = new Font(helvetica, 8, Font.BOLDITALIC);

        pdfTable.addCell(new Paragraph("Reg No.", font));
        pdfTable.addCell(new Paragraph("Accident Date", font));
        pdfTable.addCell(new Paragraph("Description", font));
        pdfTable.addCell(new Paragraph("Driver Name", font));
        pdfTable.addCell(new Paragraph("Driver Comment", font));
        pdfTable.addCell(new Paragraph("Police Name", font));
        pdfTable.addCell(new Paragraph("Station Name", font));
        pdfTable.addCell(new Paragraph("Police Comment", font));

        font = new Font(helvetica, 8, Font.NORMAL);

        if (getActiveAccidents() != null) {
            for (VehicleAccident e : getActiveAccidents()) {
                pdfTable.addCell(new Paragraph(e.getVehicle().getRegistrationNo(), font));
                pdfTable.addCell(new Paragraph(e.getAccident_dt().toLocaleString(), font));
                pdfTable.addCell(new Paragraph(e.getAccidentDescription(), font));
                pdfTable.addCell(new Paragraph(e.getDriver_name(), font));
                pdfTable.addCell(new Paragraph(e.getDriverComment(), font));
                pdfTable.addCell(new Paragraph(e.getPoliceOfficer(), font));
                pdfTable.addCell(new Paragraph(e.getPoliceStation(), font));
                pdfTable.addCell(new Paragraph(e.getPoliceComment(), font));
            }
        }
        break;
    }
    case 8: // coporate trips
    {
        numberOfColumns = 9;
        pdfTable = new PdfPTable(numberOfColumns);

        BaseFont helvetica = null;
        try {
            helvetica = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.EMBEDDED);
        } catch (Exception e) {
        }
        Font font = new Font(helvetica, 6, Font.BOLDITALIC);

        pdfTable.addCell(new Paragraph("Requester", font));
        pdfTable.addCell(new Paragraph("Department", font));
        pdfTable.addCell(new Paragraph("Reg No.", font));
        pdfTable.addCell(new Paragraph("Departure Location", font));
        pdfTable.addCell(new Paragraph("Arrival Location", font));
        pdfTable.addCell(new Paragraph("Departure Date and Time", font));
        pdfTable.addCell(new Paragraph("Est. Arrival Date and Time", font));
        pdfTable.addCell(new Paragraph("Act. Arrival Date and Time", font));
        pdfTable.addCell(new Paragraph("Status", font));

        font = new Font(helvetica, 6, Font.NORMAL);

        if (getCorTrips() != null) {
            for (CorporateTrip e : getCorTrips()) {
                pdfTable.addCell(
                        new Paragraph(e.getStaff().getFirstname() + " " + e.getStaff().getLastname(), font));
                pdfTable.addCell(new Paragraph(
                        (e.getStaff().getDepartment() != null) ? e.getStaff().getDepartment().getName() : "N/A",
                        font));
                pdfTable.addCell(new Paragraph(
                        e.getVehicle() != null ? e.getVehicle().getRegistrationNo() : "N/A", font));
                pdfTable.addCell(new Paragraph(e.getDepartureLocation(), font));
                pdfTable.addCell(new Paragraph(e.getArrivalLocation(), font));
                pdfTable.addCell(new Paragraph(e.getDepartureDateTime().toLocaleString(), font));
                pdfTable.addCell(new Paragraph(e.getEstimatedArrivalDateTime().toLocaleString(), font));
                pdfTable.addCell(new Paragraph(
                        e.getCompleteRequestDateTime() != null ? e.getCompleteRequestDateTime().toLocaleString()
                                : "N/A",
                        font));
                pdfTable.addCell(new Paragraph(e.getTripStatus(), font));
            }
        }
        break;
    }
    case 9: // expense report
    {
        numberOfColumns = 4;
        pdfTable = new PdfPTable(numberOfColumns);

        BaseFont helvetica = null;
        try {
            helvetica = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.EMBEDDED);
        } catch (Exception e) {
        }
        Font font = new Font(helvetica, 8, Font.BOLDITALIC);

        pdfTable.addCell(new Paragraph("Type", font));
        pdfTable.addCell(new Paragraph("Date", font));
        pdfTable.addCell(new Paragraph("Amount", font));
        pdfTable.addCell(new Paragraph("Detail", font));

        font = new Font(helvetica, 8, Font.NORMAL);

        if (getExpenses() != null) {
            for (Expense e : getExpenses()) {
                pdfTable.addCell(new Paragraph(e.getType().getName(), font));
                pdfTable.addCell(new Paragraph(e.getExpense_dt().toLocaleString(), font));
                pdfTable.addCell(new Paragraph("" + e.getAmount(), font));
                pdfTable.addCell(new Paragraph(e.getRemarks(), font));
            }
        }
        break;
    }
    case 10: // vehicle ages
    {
        numberOfColumns = 6;
        pdfTable = new PdfPTable(numberOfColumns);

        BaseFont helvetica = null;
        try {
            helvetica = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.EMBEDDED);
        } catch (Exception e) {
        }
        Font font = new Font(helvetica, 8, Font.BOLDITALIC);

        pdfTable.addCell(new Paragraph("Make", font));
        pdfTable.addCell(new Paragraph("Model", font));
        pdfTable.addCell(new Paragraph("Year", font));
        pdfTable.addCell(new Paragraph("Reg No.", font));
        pdfTable.addCell(new Paragraph("Date of Purchase", font));
        pdfTable.addCell(new Paragraph("Age (in years)", font));

        font = new Font(helvetica, 8, Font.NORMAL);

        if (getVehiclesAges() != null) {
            for (Vehicle e : getVehiclesAges()) {
                pdfTable.addCell(new Paragraph(
                        e.getModel().getMaker() != null ? e.getModel().getMaker().getName() : "N/A", font));
                pdfTable.addCell(new Paragraph(e.getModel() != null ? e.getModel().getName() : "N/A", font));
                pdfTable.addCell(new Paragraph(e.getModel() != null ? e.getModel().getYear() : "N/A", font));
                pdfTable.addCell(new Paragraph(e.getRegistrationNo(), font));
                pdfTable.addCell(new Paragraph(
                        e.getPurchaseDate() != null ? e.getPurchaseDate().toLocaleString() : "N/A", font));
                pdfTable.addCell(new Paragraph("" + e.getAge(), font));
            }
        }
        break;
    }
    case 11: // vehicle fuelings
    {
        numberOfColumns = 5;
        pdfTable = new PdfPTable(numberOfColumns);

        BaseFont helvetica = null;
        try {
            helvetica = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.EMBEDDED);
        } catch (Exception e) {
        }
        Font font = new Font(helvetica, 8, Font.BOLDITALIC);

        pdfTable.addCell(new Paragraph("Date", font));
        pdfTable.addCell(new Paragraph("Reg No.", font));
        pdfTable.addCell(new Paragraph("Litres", font));
        pdfTable.addCell(new Paragraph("Amount", font));
        pdfTable.addCell(new Paragraph("Source", font));

        font = new Font(helvetica, 8, Font.NORMAL);

        if (getFuelings() != null) {
            for (VehicleFueling e : getFuelings()) {
                pdfTable.addCell(new Paragraph(e.getCaptured_dt().toLocaleString(), font));
                pdfTable.addCell(new Paragraph(e.getVehicle().getRegistrationNo(), font));
                pdfTable.addCell(new Paragraph("" + e.getLitres(), font));
                pdfTable.addCell(new Paragraph("" + e.getAmt(), font));
                pdfTable.addCell(new Paragraph(e.getSource(), font));
            }
        }
        break;
    }
    case 12: // due vehicle licenses
    {
        numberOfColumns = 5;
        pdfTable = new PdfPTable(numberOfColumns);

        BaseFont helvetica = null;
        try {
            helvetica = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.EMBEDDED);
        } catch (Exception e) {
        }
        Font font = new Font(helvetica, 8, Font.BOLDITALIC);

        pdfTable.addCell(new Paragraph("Reg No.", font));
        pdfTable.addCell(new Paragraph("Fleet", font));
        pdfTable.addCell(new Paragraph("Make", font));
        pdfTable.addCell(new Paragraph("Model", font));
        pdfTable.addCell(new Paragraph("License Due Date", font));

        font = new Font(helvetica, 8, Font.NORMAL);

        if (getDueVehicleLicenses() != null) {
            for (VehicleLicense e : getDueVehicleLicenses()) {
                pdfTable.addCell(new Paragraph(e.getVehicle().getRegistrationNo(), font));
                pdfTable.addCell(new Paragraph(e.getVehicle().getFleet().getName(), font));
                pdfTable.addCell(new Paragraph(
                        e.getVehicle().getModel() != null ? e.getVehicle().getModel().getMaker().getName()
                                : "N/A",
                        font));
                pdfTable.addCell(new Paragraph(
                        e.getVehicle().getModel() != null ? e.getVehicle().getModel().getName() : "N/A", font));
                pdfTable.addCell(new Paragraph(e.getLic_end_dt().toLocaleString(), font));
            }
        }
        break;
    }
    }

    pdfTable.setWidthPercentage(100);

    return pdfTable;
}

From source file:com.dexter.fuelcard.mbean.UtilMBean.java

public byte[] createInvoicePDF(int pageType, String title, String dateperiod, String amount, String chargeType,
        String chargeAmount, String total) {
    try {//w  w w  .j a v  a  2s. c  o  m
        Document document = new Document();
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        PdfWriter writer = PdfWriter.getInstance(document, baos);
        writer.setPageEvent(new HeaderFooter());
        writer.setBoxSize("footer", new Rectangle(36, 54, 559, 788));
        if (!document.isOpen()) {
            document.open();
        }

        switch (pageType) {
        case 1:
            document.setPageSize(PageSize.A4);
            break;
        case 2:
            document.setPageSize(PageSize.A4.rotate());
            break;
        }
        document.addAuthor("FUELCARD");
        document.addCreationDate();
        document.addCreator("FUELCARD");
        document.addSubject("Invoice");
        document.addTitle(title);

        PdfPTable headerTable = new PdfPTable(1);

        ServletContext servletContext = (ServletContext) FacesContext.getCurrentInstance().getExternalContext()
                .getContext();
        String logo = servletContext.getRealPath("") + File.separator + "resources" + File.separator + "images"
                + File.separator + "satraklogo.jpg";

        PdfPCell c = new PdfPCell(Image.getInstance(logo));
        c.setBorder(0);
        c.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        headerTable.addCell(c);

        Paragraph stars = new Paragraph(20);
        stars.add(Chunk.NEWLINE);
        stars.setSpacingAfter(20);

        c = new PdfPCell(stars);
        c.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        c.setBorder(0);
        headerTable.addCell(c);

        BaseFont helvetica = null;
        try {
            helvetica = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.EMBEDDED);
        } catch (Exception e) {
            //font exception
        }
        Font font = new Font(helvetica, 16, Font.NORMAL | Font.BOLD);

        c = new PdfPCell(new Paragraph(title, font));
        c.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        c.setBorder(0);
        headerTable.addCell(c);

        if (dateperiod != null) {
            stars = new Paragraph(20);
            stars.add(Chunk.NEWLINE);
            stars.setSpacingAfter(10);

            c = new PdfPCell(stars);
            c.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
            c.setBorder(0);
            headerTable.addCell(c);

            new Font(helvetica, 12, Font.NORMAL);
            Paragraph ch = new Paragraph("For " + dateperiod, font);
            c = new PdfPCell(ch);
            c.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
            headerTable.addCell(c);
        }
        stars = new Paragraph(20);
        stars.add(Chunk.NEWLINE);
        stars.setSpacingAfter(20);

        c = new PdfPCell(stars);
        c.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        c.setBorder(0);
        headerTable.addCell(c);
        document.add(headerTable);

        PdfPTable pdfTable = new PdfPTable(4);
        try {
            helvetica = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.EMBEDDED);
        } catch (Exception e) {
        }
        font = new Font(helvetica, 8, Font.BOLDITALIC);

        pdfTable.addCell(new Paragraph("Charge Type", font)); // % per transaction or flat per license
        pdfTable.addCell(new Paragraph("Charge Amount", font)); // the amount of the charge setting

        if (chargeType.equalsIgnoreCase("Percent-Per-Tran")) {
            pdfTable.addCell(new Paragraph("Total Amount", font)); // the amount of the charge setting
        } else {
            pdfTable.addCell(new Paragraph("Total License", font)); // the amount of the charge setting
        }
        //pdfTable.addCell(new Paragraph("Description", font)); // the 
        pdfTable.addCell(new Paragraph("Amount Due", font));

        font = new Font(helvetica, 8, Font.NORMAL);
        pdfTable.addCell(new Paragraph(chargeType, font));
        pdfTable.addCell(new Paragraph(chargeAmount, font));
        pdfTable.addCell(new Paragraph(total, font));
        pdfTable.addCell(new Paragraph(amount, font));

        pdfTable.setWidthPercentage(100);
        if (pdfTable != null)
            document.add(pdfTable);

        //Keep modifying your pdf file (add pages and more)

        document.close();

        return baos.toByteArray();
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}

From source file:com.docdoku.server.extras.TitleBlockGenerator.java

License:Open Source License

protected void generateTable(Paragraph preface, ResourceBundle bundle) {
    // Author + date
    PdfPTable table = new PdfPTable(2);
    table.setWidthPercentage(TABLE_PERCENT_WIDTH);

    PdfPCell cell;//from www. j  a v  a  2 s  . c om

    cell = new PdfPCell(new Phrase(authorName, NORMAL_12));
    cell.setBorder(Rectangle.NO_BORDER);
    cell.setHorizontalAlignment(Element.ALIGN_LEFT);
    table.addCell(cell);

    cell = new PdfPCell(new Phrase(creationDate, NORMAL_12));
    cell.setBorder(Rectangle.NO_BORDER);
    cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
    table.addCell(cell);

    preface.add(table);

    addEmptyLine(preface, 1);

    preface.add(new Paragraph(bundle.getString("iteration"), BOLD_12));
    addEmptyLine(preface, 1);

    PdfPTable iterationTable = new PdfPTable(5);
    iterationTable.setWidthPercentage(TABLE_PERCENT_WIDTH);

    // Table header
    cell = new PdfPCell(new Phrase(bundle.getString("iteration.version"), BOLD_12));
    cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
    iterationTable.addCell(cell);
    cell = new PdfPCell(new Phrase(bundle.getString("iteration.iteration"), BOLD_12));
    cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
    iterationTable.addCell(cell);
    cell = new PdfPCell(new Phrase(bundle.getString("iteration.date"), BOLD_12));
    cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
    iterationTable.addCell(cell);
    cell = new PdfPCell(new Phrase(bundle.getString("iteration.author"), BOLD_12));
    cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
    iterationTable.addCell(cell);
    cell = new PdfPCell(new Phrase(bundle.getString("iteration.Notes"), BOLD_12));
    cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
    iterationTable.addCell(cell);

    // Table body
    cell = new PdfPCell(new Phrase(version, NORMAL_12));
    iterationTable.addCell(cell);
    cell = new PdfPCell(new Phrase(currentIteration, NORMAL_12));
    iterationTable.addCell(cell);
    cell = new PdfPCell(new Phrase(iterationDate, NORMAL_12));
    iterationTable.addCell(cell);
    cell = new PdfPCell(new Phrase(authorName, NORMAL_12));
    iterationTable.addCell(cell);
    cell = new PdfPCell(new Phrase(revisionNote, NORMAL_12));
    iterationTable.addCell(cell);

    preface.add(iterationTable);
}

From source file:com.docdoku.server.extras.TitleBlockGenerator.java

License:Open Source License

public void generateAttribute(Paragraph preface, ResourceBundle bundle) {

    // Table title
    preface.add(new Paragraph(bundle.getString("attributes"), BOLD_12));
    addEmptyLine(preface, 1);/*from w w  w  .  j a v a2s. c  om*/

    PdfPTable attributesTable = new PdfPTable(2);
    attributesTable.setWidthPercentage(100f);

    // Table head
    PdfPCell cell = new PdfPCell(new Phrase(bundle.getString("attributes.name"), BOLD_12));
    cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
    attributesTable.addCell(cell);
    cell = new PdfPCell(new Phrase(bundle.getString("attributes.value"), BOLD_12));
    cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
    attributesTable.addCell(cell);

    // Table body

    for (InstanceAttribute attr : instanceAttributes) {
        cell = new PdfPCell(new Phrase(attr.getName(), NORMAL_12));
        attributesTable.addCell(cell);
        Object value = attr.getValue();
        cell = new PdfPCell(new Phrase(value != null ? String.valueOf(value) : "", NORMAL_12));
        attributesTable.addCell(cell);
    }

    preface.add(attributesTable);

}

From source file:com.docdoku.server.extras.TitleBlockGenerator.java

License:Open Source License

private void generateLyfeCycleState(Paragraph preface, ResourceBundle bundle) {
    // Table title
    preface.add(new Paragraph(bundle.getString("lifecycle") + " : " + lifeCycleState, BOLD_12));
    addEmptyLine(preface, 1);//  w w w  .ja v a2 s .  c om

    PdfPTable lifeCycleTable = new PdfPTable(5);
    lifeCycleTable.setWidthPercentage(100f);
    PdfPCell cell;
    for (Activity activity : workflow.getActivities()) {

        boolean headerRendered = false;

        for (Task task : activity.getTasks()) {

            if (task.isApproved() || task.isRejected()) {

                if (!headerRendered) {
                    // Table head
                    cell = new PdfPCell(new Phrase(activity.getLifeCycleState(), BOLD_12));
                    cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
                    cell.setColspan(5);
                    lifeCycleTable.addCell(cell);

                    cell = new PdfPCell(new Phrase(bundle.getString("lifecycle.task"), BOLD_12));
                    cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
                    lifeCycleTable.addCell(cell);

                    cell = new PdfPCell(new Phrase(bundle.getString("lifecycle.date"), BOLD_12));
                    cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
                    lifeCycleTable.addCell(cell);

                    cell = new PdfPCell(new Phrase(bundle.getString("lifecycle.author"), BOLD_12));
                    cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
                    lifeCycleTable.addCell(cell);

                    cell = new PdfPCell(new Phrase(bundle.getString("lifecycle.comments"), BOLD_12));
                    cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
                    lifeCycleTable.addCell(cell);

                    cell = new PdfPCell(new Phrase(bundle.getString("lifecycle.signature"), BOLD_12));
                    cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
                    lifeCycleTable.addCell(cell);

                    headerRendered = true;
                }

                // Table body
                cell = new PdfPCell(new Phrase(task.getTitle(), NORMAL_12));
                lifeCycleTable.addCell(cell);

                SimpleDateFormat simpleFormat = new SimpleDateFormat(bundle.getString("date.format"));
                cell = new PdfPCell(new Phrase(simpleFormat.format(task.getClosureDate()), NORMAL_12));
                lifeCycleTable.addCell(cell);

                cell = new PdfPCell(new Phrase(task.getWorker().getName(), NORMAL_12));
                lifeCycleTable.addCell(cell);

                cell = new PdfPCell(new Phrase(task.getClosureComment(), NORMAL_12));
                lifeCycleTable.addCell(cell);

                if (task.getSignature() != null) {
                    try {
                        byte[] imageByte;
                        int indexOfFirstComma = task.getSignature().indexOf(",");
                        String base64 = task.getSignature().substring(indexOfFirstComma + 1,
                                task.getSignature().length());
                        imageByte = DatatypeConverter.parseBase64Binary(base64);
                        Image image = Image.getInstance(imageByte);
                        image.setCompressionLevel(Image.ORIGINAL_NONE);
                        image.scaleToFit(SIGNATURE_SIZE_W, SIGNATURE_SIZE_H);
                        cell = new PdfPCell(image);
                        lifeCycleTable.addCell(cell);
                    } catch (Exception e) {
                        cell = new PdfPCell(new Phrase(bundle.getString("signature.error"), NORMAL_12));
                        lifeCycleTable.addCell(cell);
                    }

                } else {
                    cell = new PdfPCell(new Phrase(""));
                    lifeCycleTable.addCell(cell);
                }

            }
        }

    }

    preface.add(lifeCycleTable);
}

From source file:com.empatkepala.view.MyPdfView.java

@Override
protected void buildPdfDocument(Map<String, Object> model, Document document, PdfWriter writer,
        HttpServletRequest request, HttpServletResponse response) throws Exception {
    List<CV> cvs = (List<CV>) model.get("cv");
    List<String> cvValue = new ArrayList<>();
    List<String> namaAtribut = new ArrayList<>();

    namaAtribut.add("ID CV :");
    cvValue.add(Long.toString(cvs.get(0).getIdCV()));
    namaAtribut.add("Uid :");
    cvValue.add(cvs.get(0).getUid());/*from   w  w  w  .j a  v a 2  s  .  co  m*/
    namaAtribut.add("Title :");
    cvValue.add(cvs.get(0).getTitle());
    // <<<<<<< feature/mpp
    //         namaAtribut.add("Department :"); cvValue.add(cvs.get(0).getDepartment().toString());
    // =======
    namaAtribut.add("Department :");
    cvValue.add(cvs.get(0).getDepartment());
    // >>>>>>> dev
    namaAtribut.add("Job Title :");
    cvValue.add(cvs.get(0).getJobTitle());
    namaAtribut.add("Full Name :");
    cvValue.add(cvs.get(0).getFullName());
    namaAtribut.add("Place Date Of Birth :");
    cvValue.add(cvs.get(0).getPlaceDateOfBirth());
    namaAtribut.add("Id Card Number :");
    cvValue.add(cvs.get(0).getIdCardNumber());
    namaAtribut.add("Driving License :");
    cvValue.add(cvs.get(0).getDrivingLicense().toString());

    namaAtribut.add("Email :");
    cvValue.add(cvs.get(0).getEmailAddress());
    namaAtribut.add("twitter :");
    cvValue.add(cvs.get(0).getTwitter());
    namaAtribut.add("facebook :");
    cvValue.add(cvs.get(0).getFacebook());
    namaAtribut.add("linkedIn :");
    cvValue.add(cvs.get(0).getLinkedIn());
    namaAtribut.add("blog :");
    cvValue.add(cvs.get(0).getBlog());
    namaAtribut.add("handphone :");
    cvValue.add(cvs.get(0).getHandphone());
    namaAtribut.add("religion :");
    cvValue.add(cvs.get(0).getReligion());
    namaAtribut.add("ethnicty :");
    cvValue.add(cvs.get(0).getEthnicity());

    namaAtribut.add("Marital Status :");
    cvValue.add(cvs.get(0).getMaritalStatus());
    namaAtribut.add("Current Address :");
    cvValue.add(cvs.get(0).getCurrentAddress());
    namaAtribut.add("Home Address :");
    cvValue.add(cvs.get(0).getHomeAddress());
    namaAtribut.add("Home Phone :");
    cvValue.add(cvs.get(0).getHomePhone());
    namaAtribut.add("Emergency Call :");
    cvValue.add(cvs.get(0).getEmergencyCall());
    namaAtribut.add("Father Name :");
    cvValue.add(cvs.get(0).getFatherName());
    namaAtribut.add("Father Birthday :");
    cvValue.add(cvs.get(0).getFatherBirthday());
    namaAtribut.add("Father Latest Education :");
    cvValue.add(cvs.get(0).getFatherLatestEducation());
    namaAtribut.add("Father CurrentJob :");
    cvValue.add(cvs.get(0).getFatherCurrentJob());
    namaAtribut.add("Mother Name :");
    cvValue.add(cvs.get(0).getMotherName());
    namaAtribut.add("Mother Birthday :");
    cvValue.add(cvs.get(0).getMotherBirthday());
    namaAtribut.add("Mother Latest Education :");
    cvValue.add(cvs.get(0).getMotherLatestEducation());
    namaAtribut.add("Mother Current Job :");
    cvValue.add(cvs.get(0).getmotherCurrentJob());
    namaAtribut.add("Spouse Name :");
    cvValue.add(cvs.get(0).getSpouseName());
    namaAtribut.add("Spouse BirthDay :");
    cvValue.add(cvs.get(0).getSpousebirthDay());
    namaAtribut.add("SpouseLatestEducation :");
    cvValue.add(cvs.get(0).getSpouseLatestEducation());
    namaAtribut.add("SpouseCurrentJob() :");
    cvValue.add(cvs.get(0).getSpouseCurrentJob());
    namaAtribut.add("Responsibilities :");
    cvValue.add(cvs.get(0).getResponsibilities());
    namaAtribut.add("Responsibilities Type :");
    cvValue.add(cvs.get(0).getResponsibilitiesType());

    namaAtribut.add("School :");
    cvValue.add(cvs.get(0).getSchool().get(0).getSchoolName());
    namaAtribut.add("Major :");
    cvValue.add(cvs.get(0).getSchool().get(0).getMajor());
    namaAtribut.add("City :");
    cvValue.add(cvs.get(0).getSchool().get(0).getCity());
    namaAtribut.add("Periode :");
    cvValue.add(cvs.get(0).getSchool().get(0).getPeriode());
    namaAtribut.add("GPA :");
    cvValue.add(cvs.get(0).getSchool().get(0).getGpa().toString());
    namaAtribut.add("School :");
    cvValue.add(cvs.get(0).getSchool().get(1).getSchoolName());
    namaAtribut.add("Major :");
    cvValue.add(cvs.get(0).getSchool().get(1).getMajor());
    namaAtribut.add("City :");
    cvValue.add(cvs.get(0).getSchool().get(1).getCity());
    namaAtribut.add("Periode :");
    cvValue.add(cvs.get(0).getSchool().get(1).getPeriode());
    namaAtribut.add("GPA :");
    cvValue.add(cvs.get(0).getSchool().get(1).getGpa().toString());

    namaAtribut.add("Reason Major :");
    cvValue.add(cvs.get(0).getReasonMajor());
    namaAtribut.add("mother titleThesis :");
    cvValue.add(cvs.get(0).getTitleThesis());

    namaAtribut.add("Non Formal Course");
    cvValue.add(cvs.get(0).getNonFrmlCrs().get(0).getNameOfCourse());
    namaAtribut.add("Organizer");
    cvValue.add(cvs.get(0).getNonFrmlCrs().get(0).getOrganizer());
    namaAtribut.add("Year");
    cvValue.add(String.valueOf(cvs.get(0).getNonFrmlCrs().get(0).getYear()));
    namaAtribut.add("Notes");
    cvValue.add(cvs.get(0).getNonFrmlCrs().get(0).getNotes());
    namaAtribut.add("Non Formal Course");
    cvValue.add(cvs.get(0).getNonFrmlCrs().get(1).getNameOfCourse());
    namaAtribut.add("Organizer");
    cvValue.add(cvs.get(0).getNonFrmlCrs().get(0).getOrganizer());
    namaAtribut.add("Year");
    cvValue.add(String.valueOf(cvs.get(0).getNonFrmlCrs().get(1).getYear()));
    namaAtribut.add("Notes");
    cvValue.add(cvs.get(0).getNonFrmlCrs().get(1).getNotes());
    namaAtribut.add("Non Formal Course");
    cvValue.add(cvs.get(0).getNonFrmlCrs().get(2).getNameOfCourse());
    namaAtribut.add("Organizer");
    cvValue.add(cvs.get(0).getNonFrmlCrs().get(2).getOrganizer());
    namaAtribut.add("Year");
    cvValue.add(String.valueOf(cvs.get(0).getNonFrmlCrs().get(2).getYear()));
    namaAtribut.add("Notes");
    cvValue.add(cvs.get(0).getNonFrmlCrs().get(2).getNotes());

    namaAtribut.add("Achievements");
    cvValue.add(cvs.get(0).getAchievements().get(0).getAchievement());
    namaAtribut.add("year");
    cvValue.add(String.valueOf(cvs.get(0).getAchievements().get(0).getYear()));
    namaAtribut.add("notes");
    cvValue.add(cvs.get(0).getAchievements().get(0).getNotes());

    namaAtribut.add("Achievements");
    cvValue.add(cvs.get(0).getAchievements().get(1).getAchievement());
    namaAtribut.add("year");
    cvValue.add(String.valueOf(cvs.get(0).getAchievements().get(1).getYear()));
    namaAtribut.add("notes");
    cvValue.add(cvs.get(0).getAchievements().get(1).getNotes());

    namaAtribut.add("Social Activity");
    cvValue.add(cvs.get(0).getSocialact().get(0).getNameOrganization());
    namaAtribut.add("FieldOfOrganization");
    cvValue.add(String.valueOf(cvs.get(0).getSocialact().get(0).getFieldOfOrganization()));
    namaAtribut.add("AttendancePeriod");
    cvValue.add(String.valueOf(cvs.get(0).getSocialact().get(0).getAttendancePeriod()));
    namaAtribut.add("Notes");
    cvValue.add(cvs.get(0).getSocialact().get(0).getNotes());

    namaAtribut.add("Social Activity");
    cvValue.add(cvs.get(0).getSocialact().get(1).getNameOrganization());
    namaAtribut.add("FieldOfOrganization");
    cvValue.add(String.valueOf(cvs.get(0).getSocialact().get(1).getFieldOfOrganization()));
    namaAtribut.add("AttendancePeriod");
    cvValue.add(String.valueOf(cvs.get(0).getSocialact().get(1).getAttendancePeriod()));
    namaAtribut.add("Notes");
    cvValue.add(cvs.get(0).getSocialact().get(1).getNotes());

    namaAtribut.add("Language");
    cvValue.add(cvs.get(0).getLanguage().get(0).getNameOfLanguage());
    namaAtribut.add("spokenLanguage");
    cvValue.add(String.valueOf(cvs.get(0).getLanguage().get(0).getspokenLanguage()));
    namaAtribut.add("writtenLanguage");
    cvValue.add(String.valueOf(cvs.get(0).getLanguage().get(0).getwrittenLanguage()));

    namaAtribut.add("Reason Interested In GDN :");
    cvValue.add(cvs.get(0).getReasonInterestedInGDN());
    namaAtribut.add("Reason Apply On That Position :");
    cvValue.add(cvs.get(0).getReasonApplyOnThatPosition());
    namaAtribut.add("Factor Encourage You On That Job :");
    cvValue.add(cvs.get(0).getFactorEncourageYouOnThatJob());
    namaAtribut.add("Kind Of Environtment :");
    cvValue.add(cvs.get(0).getKindOfEnvirontment());
    namaAtribut.add("LifeValue :");
    cvValue.add(cvs.get(0).getLifeValue());
    namaAtribut.add("SpesificSkill :");
    cvValue.add(cvs.get(0).getSpesificSkill());
    namaAtribut.add("Hobbies :");
    cvValue.add(cvs.get(0).getHobbies());
    namaAtribut.add("Describe About You :");
    cvValue.add(cvs.get(0).getDescribeAboutYou());
    namaAtribut.add("PlaceGetInformationGDN :");
    cvValue.add(cvs.get(0).getPlaceGetInformationGDN());
    namaAtribut.add("Relative Working On GDN :");
    cvValue.add(cvs.get(0).getRelativeWorkingOnGDN());
    namaAtribut.add("Have Applied On GDN :");
    cvValue.add(cvs.get(0).getHaveAppliedOnGDN());
    namaAtribut.add("Have Part Time Job :");
    cvValue.add(cvs.get(0).getHavePartTimejob());
    namaAtribut.add("Time Start Work :");
    cvValue.add(cvs.get(0).getTimeStartWork());
    namaAtribut.add("Applicant Status :");
    cvValue.add(cvs.get(0).getApplicantStatus());

    namaAtribut.add("Children");
    cvValue.add(cvs.get(0).getChil().get(0).getChildrenName());
    namaAtribut.add("Children Birthday");
    cvValue.add(String.valueOf(cvs.get(0).getChil().get(0).getChildrenBirthday()));
    namaAtribut.add("Children Current Job");
    cvValue.add(String.valueOf(cvs.get(0).getChil().get(0).getChildrenCurrentJob()));
    namaAtribut.add("Children Last Education");
    cvValue.add(String.valueOf(cvs.get(0).getChil().get(0).getChilLatestEdu()));

    namaAtribut.add("Children");
    cvValue.add(cvs.get(0).getChil().get(0).getChildrenName());
    namaAtribut.add("Children Birthday");
    cvValue.add(String.valueOf(cvs.get(0).getChil().get(0).getChildrenBirthday()));
    namaAtribut.add("Children Current Job");
    cvValue.add(String.valueOf(cvs.get(0).getChil().get(0).getChildrenCurrentJob()));
    namaAtribut.add("Children Latest Education");
    cvValue.add(String.valueOf(cvs.get(0).getChil().get(0).getChilLatestEdu()));

    namaAtribut.add("Brothers");
    cvValue.add(String.valueOf(cvs.get(0).getBro().get(0).getBrothersName()));
    namaAtribut.add("Brother Birthday");
    cvValue.add(String.valueOf(cvs.get(0).getBro().get(0).getBrothersBirthday()));
    namaAtribut.add("Brother Latest Education");
    cvValue.add(String.valueOf(cvs.get(0).getBro().get(0).getBrotherLatestEducation()));
    namaAtribut.add("Brother Current Job");
    cvValue.add(String.valueOf(cvs.get(0).getBro().get(0).getBrotherCurrentJob()));

    namaAtribut.add("Work Experience");
    cvValue.add(cvs.get(0).getWorkExp().get(0).getCompanyName());
    namaAtribut.add("Company Field");
    cvValue.add(String.valueOf(cvs.get(0).getWorkExp().get(0).getCompanyField()));
    namaAtribut.add("Position");
    cvValue.add(String.valueOf(cvs.get(0).getWorkExp().get(0).getPosition()));
    namaAtribut.add("Period");
    cvValue.add(String.valueOf(cvs.get(0).getWorkExp().get(0).getPeriod()));
    namaAtribut.add("Work Experience");
    cvValue.add(String.valueOf(cvs.get(0).getWorkExp().get(0).getJobDescription()));
    namaAtribut.add("Reason to Leave");
    cvValue.add(String.valueOf(cvs.get(0).getWorkExp().get(0).getReasonToLeave()));
    namaAtribut.add("References Name");
    cvValue.add(String.valueOf(cvs.get(0).getWorkExp().get(0).getReferenceName()));
    namaAtribut.add("Reference Position");
    cvValue.add(String.valueOf(cvs.get(0).getWorkExp().get(0).getReferencePosition()));
    namaAtribut.add("Reference Phone Number");
    cvValue.add(String.valueOf(cvs.get(0).getWorkExp().get(0).getReferencePhoneNumber()));
    namaAtribut.add("Organization Chart");
    cvValue.add(String.valueOf(cvs.get(0).getWorkExp().get(0).getOrganizationalChart()));

    namaAtribut.add("Work Experience");
    cvValue.add(cvs.get(0).getWorkExp().get(1).getCompanyName());
    namaAtribut.add("Company Field");
    cvValue.add(String.valueOf(cvs.get(0).getWorkExp().get(1).getCompanyField()));
    namaAtribut.add("Position");
    cvValue.add(String.valueOf(cvs.get(0).getWorkExp().get(1).getPosition()));
    namaAtribut.add("Period");
    cvValue.add(String.valueOf(cvs.get(0).getWorkExp().get(1).getPeriod()));
    namaAtribut.add("Work Experience");
    cvValue.add(String.valueOf(cvs.get(0).getWorkExp().get(1).getJobDescription()));
    namaAtribut.add("Reason to Leave");
    cvValue.add(String.valueOf(cvs.get(0).getWorkExp().get(1).getReasonToLeave()));
    namaAtribut.add("References Name");
    cvValue.add(String.valueOf(cvs.get(0).getWorkExp().get(1).getReferenceName()));
    namaAtribut.add("Reference Position");
    cvValue.add(String.valueOf(cvs.get(0).getWorkExp().get(1).getReferencePosition()));
    namaAtribut.add("Reference Phone Number");
    cvValue.add(String.valueOf(cvs.get(0).getWorkExp().get(1).getReferencePhoneNumber()));
    namaAtribut.add("Organization Chart");
    cvValue.add(String.valueOf(cvs.get(0).getWorkExp().get(1).getOrganizationalChart()));

    //

    PdfPTable table = new PdfPTable(2);
    table.setWidthPercentage(85);
    table.setWidths(new int[] { 3, 4 });

    Font headFont = FontFactory.getFont(FontFactory.HELVETICA_BOLD);
    for (CV cv : cvs) {
        for (int i = 0; i < namaAtribut.size(); i++) {
            PdfPCell hcell;
            hcell = new PdfPCell(new Phrase("  " + namaAtribut.get(i), headFont));
            hcell.setHorizontalAlignment(Element.ALIGN_LEFT);
            table.addCell(hcell);

            hcell = new PdfPCell(new Phrase("   " + cvValue.get(i)));
            hcell.setHorizontalAlignment(Element.ALIGN_LEFT);
            table.addCell(hcell);

        }
    }

    //        PdfPTable table = new PdfPTable(1);
    //        table.setWidthPercentage(60);
    //        table.setWidths(new int[] {4});
    //
    //        Font headFont = FontFactory.getFont(FontFactory.HELVETICA_BOLD);

    //        PdfPCell hcell;
    //        hcell = new PdfPCell(new Phrase("Data", headFont));
    //        hcell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    //        hcell.setHorizontalAlignment(Element.ALIGN_CENTER);
    //        table.addCell(hcell);

    for (CV cv : cvs) {

        //            PdfPCell cell;
        //
        //            cell = new PdfPCell(new Phrase("ID CV :"));
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase(Long.toString(cv.getIdCV())));
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase("Uid :"));
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase(cv.getUid()));
        //            cell.setPaddingLeft(5);
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase("Title :"));
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase(cv.getTitle()));
        //            cell.setPaddingLeft(5);
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase("Job Title :"));
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase(cv.getJobTitle()));
        //            cell.setPaddingLeft(5);
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase("Full Name :"));
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase(cv.getFullName()));
        //            cell.setPaddingLeft(5);
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase("Place Date Of Birth :"));
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase(cv.getTitle()));
        //            cell.setPaddingLeft(5);
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase("idCardNumber :"));
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase(cv.getIdCardNumber()));
        //            cell.setPaddingLeft(5);
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase("Driving License :"));
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            ArrayList<String> sim = new ArrayList<String>();
        //            sim = cv.getDrivingLicense();
        //            cell = new PdfPCell(new Phrase(sim.toString()));
        //            cell.setPaddingLeft(5);
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase("Email :"));
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase(cv.getEmailAddress()));
        //            cell.setPaddingLeft(5);
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase("twitter :"));
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase(cv.getTwitter()));
        //            cell.setPaddingLeft(5);
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase("facebook :"));
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase(cv.getFacebook()));
        //            cell.setPaddingLeft(5);
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase("linkedIn :"));
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase(cv.getLinkedIn()));
        //            cell.setPaddingLeft(5);
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase("blog :"));
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase(cv.getBlog()));
        //            cell.setPaddingLeft(5);
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase("handphone :"));
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase(cv.getHandphone()));
        //            cell.setPaddingLeft(5);
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase("religion :"));
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase(cv.getReligion()));
        //            cell.setPaddingLeft(5);
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase("ethnicty :"));
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase(cv.getEthnicity()));
        //            cell.setPaddingLeft(5);
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase("Marital Status :"));
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase(cv.getMaritalStatus()));
        //            cell.setPaddingLeft(5);
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase("Content Address :"));
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase(cv.getCurrentAddress()));
        //            cell.setPaddingLeft(5);
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase("Home Address :"));
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase(cv.getEmailAddress()));
        //            cell.setPaddingLeft(5);
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase("Home Phone :"));
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase(cv.getHomePhone()));
        //            cell.setPaddingLeft(5);
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase("emergency Call :"));
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase(cv.getEmergencyCall()));
        //            cell.setPaddingLeft(5);
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase("Father Name :"));
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase(cv.getFatherName()));
        //            cell.setPaddingLeft(5);
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase("Father Birthday :"));
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase(cv.getFatherBirthday()));
        //            cell.setPaddingLeft(5);
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase("Father Latest Education :"));
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase(cv.getFatherLatestEducation()));
        //            cell.setPaddingLeft(5);
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase("Father Current Job :"));
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase(cv.getFatherCurrentJob()));
        //            cell.setPaddingLeft(5);
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase("Mother Name :"));
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase(cv.getMotherName()));
        //            cell.setPaddingLeft(5);
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase("Mother Birthday :"));
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase(cv.getMotherBirthday()));
        //            cell.setPaddingLeft(5);
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase("Mother Latest Education :"));
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase(cv.getEmailAddress()));
        //            cell.setPaddingLeft(5);
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase("Mother Current Job :"));
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase(cv.getEmailAddress()));
        //            cell.setPaddingLeft(5);
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase("Spouse name :"));
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase(cv.getSpouseName()));
        //            cell.setPaddingLeft(5);
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase("Spouse Birthday :"));
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase(cv.getSpousebirthDay()));
        //            cell.setPaddingLeft(5);
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase("Spouse Latest Education :"));
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase(cv.getSpouseLatestEducation()));
        //            cell.setPaddingLeft(5);
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase("Spouse Current Job :"));
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase(cv.getSpouseCurrentJob()));
        //            cell.setPaddingLeft(5);
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase("Responsibilities :"));
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase(cv.getResponsibilities()));
        //            cell.setPaddingLeft(5);
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase("Responsibilities Type :"));
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase(cv.getResponsibilitiesType()));
        //            cell.setPaddingLeft(5);
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase("Responsibilities :"));
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase(cv.getResponsibilities()));
        //            cell.setPaddingLeft(5);
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);

    }

    document.add(table);
}

From source file:com.etest.pdfgenerator.InventoryCasesReportPDF.java

public InventoryCasesReportPDF() {
    Document document = null;/*from   ww w.  ja  v a2 s  . c o m*/
    Date date = new Date();

    try {
        document = new Document(PageSize.LETTER, 50, 50, 50, 50);
        PdfWriter.getInstance(document, outputStream);
        document.open();

        Font header = FontFactory.getFont("Times-Roman", 12, Font.BOLD);
        Font content = FontFactory.getFont("Times-Roman", 10);
        Font dateFont = FontFactory.getFont("Times-Roman", 8);

        Image img = null;
        try {
            img = Image.getInstance("C:\\eTest-images\\SUCN_seal.png");
            img.scaleToFit(60, 60);
            img.setAbsolutePosition(500, 700);
        } catch (BadElementException | IOException ex) {
            Logger.getLogger(TQCoveragePDF.class.getName()).log(Level.SEVERE, null, ex);
        }
        document.add(img);

        Paragraph reportTitle = new Paragraph();
        reportTitle.setAlignment(Element.ALIGN_CENTER);
        reportTitle.add(new Phrase("Inventory of Cases Report", header));
        document.add(reportTitle);

        Paragraph datePrinted = new Paragraph();
        datePrinted.setSpacingAfter(20f);
        datePrinted.setAlignment(Element.ALIGN_CENTER);
        datePrinted.add(
                new Phrase("Date printed: " + new SimpleDateFormat("dd MMMM yyyy").format(date), dateFont));
        document.add(datePrinted);

        PdfPTable table = new PdfPTable(4);
        table.setWidthPercentage(100);
        table.setWidths(new int[] { 100, 300, 100, 100 });
        table.setSpacingAfter(5f);

        PdfPCell cellOne = new PdfPCell(new Phrase("Subject"));
        cellOne.setBorder(Rectangle.NO_BORDER);
        cellOne.setPaddingLeft(10);
        cellOne.setHorizontalAlignment(Element.ALIGN_JUSTIFIED);
        cellOne.setVerticalAlignment(Element.ALIGN_MIDDLE);

        PdfPCell cellTwo = new PdfPCell(new Phrase("Descriptive Title"));
        cellTwo.setBorder(Rectangle.NO_BORDER);
        cellTwo.setPaddingLeft(10);
        cellTwo.setHorizontalAlignment(Element.ALIGN_JUSTIFIED);
        cellTwo.setVerticalAlignment(Element.ALIGN_MIDDLE);

        PdfPCell cellThree = new PdfPCell(new Phrase("No. of Cases"));
        cellThree.setBorder(Rectangle.NO_BORDER);
        cellThree.setPaddingLeft(10);
        cellThree.setHorizontalAlignment(Element.ALIGN_CENTER);
        cellThree.setVerticalAlignment(Element.ALIGN_MIDDLE);

        PdfPCell cellFour = new PdfPCell(new Phrase("No. of Items"));
        cellFour.setBorder(Rectangle.NO_BORDER);
        cellFour.setPaddingLeft(10);
        cellFour.setHorizontalAlignment(Element.ALIGN_CENTER);
        cellFour.setVerticalAlignment(Element.ALIGN_MIDDLE);

        table.addCell(cellOne);
        table.addCell(cellTwo);
        table.addCell(cellThree);
        table.addCell(cellFour);

        table.getDefaultCell().setBorderWidth(0f);
        document.add(table);

        for (InventoryOfCasesReport report : service.getInventoryOfCases()) {
            PdfPTable table2 = new PdfPTable(4);
            table2.setWidthPercentage(100);
            table2.setWidths(new int[] { 100, 300, 100, 100 });
            table2.setSpacingBefore(3f);
            table2.setSpacingAfter(3f);

            if (!service.getListOfSyllabusIdByCurriculumId(report.getCurriculumId()).isEmpty()) {
                if (!service
                        .getListOfCellCaseIdBySyllabusId(
                                service.getListOfSyllabusIdByCurriculumId(report.getCurriculumId()))
                        .isEmpty()) {
                    PdfPCell cell1 = new PdfPCell(new Paragraph(report.getSubject(), content));
                    cell1.setBorder(0);
                    cell1.setPaddingLeft(10);
                    cell1.setHorizontalAlignment(Element.ALIGN_JUSTIFIED);
                    cell1.setVerticalAlignment(Element.ALIGN_MIDDLE);

                    PdfPCell cell2 = new PdfPCell(new Paragraph(report.getDescriptiveTitle(), content));
                    cell2.setBorder(0);
                    cell2.setPaddingLeft(10);
                    cell2.setHorizontalAlignment(Element.ALIGN_JUSTIFIED);
                    cell2.setVerticalAlignment(Element.ALIGN_MIDDLE);

                    PdfPCell cell3 = new PdfPCell(new Paragraph(
                            String.valueOf(service.getTotalCellCasesBySyllabus(
                                    service.getListOfSyllabusIdByCurriculumId(report.getCurriculumId()))),
                            content));
                    cell3.setBorder(0);
                    cell3.setPaddingLeft(10);
                    cell3.setHorizontalAlignment(Element.ALIGN_CENTER);
                    cell3.setVerticalAlignment(Element.ALIGN_MIDDLE);

                    PdfPCell cell4 = new PdfPCell(new Paragraph(
                            String.valueOf(service.getTotalCellItemsByCellCaseId(
                                    service.getListOfCellCaseIdBySyllabusId(service
                                            .getListOfSyllabusIdByCurriculumId(report.getCurriculumId())))),
                            content));
                    cell4.setBorder(0);
                    cell4.setPaddingLeft(10);
                    cell4.setHorizontalAlignment(Element.ALIGN_CENTER);
                    cell4.setVerticalAlignment(Element.ALIGN_MIDDLE);

                    table2.addCell(cell1);
                    table2.addCell(cell2);
                    table2.addCell(cell3);
                    table2.addCell(cell4);
                    document.add(table2);
                }
            }
        }
    } catch (DocumentException ex) {
        Logger.getLogger(InventoryItemsReportPDF.class.getName()).log(Level.SEVERE, null, ex);
    } finally {
        document.close();
    }
}

From source file:com.etest.pdfgenerator.InventoryItemsReportPDF.java

public InventoryItemsReportPDF() {
    Document document = null;//  www  .  j  av  a 2 s. com
    Date date = new Date();

    try {
        document = new Document(PageSize.LETTER.rotate(), 50, 50, 50, 50);
        PdfWriter.getInstance(document, outputStream);
        document.open();

        Font header = FontFactory.getFont("Times-Roman", 12, Font.BOLD);
        Font content = FontFactory.getFont("Times-Roman", 10);
        Font dateFont = FontFactory.getFont("Times-Roman", 8);

        Image img = null;
        try {
            img = Image.getInstance("C:\\eTest-images\\SUCN_seal.png");
            img.scaleToFit(60, 60);
            img.setAbsolutePosition(650, 500);
        } catch (BadElementException | IOException ex) {
            Logger.getLogger(TQCoveragePDF.class.getName()).log(Level.SEVERE, null, ex);
        }
        document.add(img);

        Paragraph title1 = new Paragraph();
        title1.setAlignment(Element.ALIGN_CENTER);
        title1.add(new Phrase("Inventory of Items Report"));
        document.add(title1);

        Paragraph title2 = new Paragraph();
        title2.setAlignment(Element.ALIGN_CENTER);
        title2.add(new Phrase("Grouped According to the Revised Bloom's Taxonomy"));
        document.add(title2);

        Paragraph datePrinted = new Paragraph();
        datePrinted.setSpacingAfter(20f);
        datePrinted.setAlignment(Element.ALIGN_CENTER);
        datePrinted
                .add(new Phrase("Date printed: " + new SimpleDateFormat("dd MMMM yyyy").format(date), content));
        document.add(datePrinted);

        PdfPTable table = new PdfPTable(8);
        table.setWidthPercentage(100);
        table.setSpacingAfter(5f);

        for (int i = 0; i < tableHeader.length; i++) {
            PdfPCell cell = new PdfPCell(new Phrase(tableHeader[i], header));
            cell.setBorder(Rectangle.NO_BORDER);
            cell.setPaddingLeft(10);
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            if (tableHeader[i].equals("Subject")) {
                cell.setHorizontalAlignment(Element.ALIGN_JUSTIFIED);
            } else {
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            }
            table.addCell(cell);
        }

        document.add(table);

        for (InventoryOfCasesReport report : service.getInventoryOfCases()) {
            PdfPTable table2 = new PdfPTable(8);
            table2.setWidthPercentage(100);
            table2.setSpacingBefore(3f);
            table2.setSpacingAfter(3f);

            if (!service.getListOfSyllabusIdByCurriculumId(report.getCurriculumId()).isEmpty()) {
                if (!service
                        .getListOfCellCaseIdBySyllabusId(
                                service.getListOfSyllabusIdByCurriculumId(report.getCurriculumId()))
                        .isEmpty()) {
                    PdfPCell cell1 = new PdfPCell(new Paragraph(report.getSubject(), content));
                    cell1.setBorder(0);
                    cell1.setPaddingLeft(10);
                    cell1.setHorizontalAlignment(Element.ALIGN_JUSTIFIED);
                    cell1.setVerticalAlignment(Element.ALIGN_MIDDLE);

                    PdfPCell cell2 = new PdfPCell(
                            new Paragraph(String.valueOf(service.getTotalItemsByBloomsTaxonomy(
                                    service.getListOfCellCaseIdBySyllabusId(service
                                            .getListOfSyllabusIdByCurriculumId(report.getCurriculumId())),
                                    tq.getBloomsClassId(BloomsClass.Remember.toString()))), content));
                    cell2.setBorder(0);
                    cell2.setPaddingLeft(10);
                    cell2.setHorizontalAlignment(Element.ALIGN_CENTER);
                    cell2.setVerticalAlignment(Element.ALIGN_MIDDLE);

                    PdfPCell cell3 = new PdfPCell(
                            new Paragraph(String.valueOf(service.getTotalItemsByBloomsTaxonomy(
                                    service.getListOfCellCaseIdBySyllabusId(service
                                            .getListOfSyllabusIdByCurriculumId(report.getCurriculumId())),
                                    tq.getBloomsClassId(BloomsClass.Understand.toString()))), content));
                    cell3.setBorder(0);
                    cell3.setPaddingLeft(10);
                    cell3.setHorizontalAlignment(Element.ALIGN_CENTER);
                    cell3.setVerticalAlignment(Element.ALIGN_MIDDLE);

                    PdfPCell cell4 = new PdfPCell(
                            new Paragraph(String.valueOf(service.getTotalItemsByBloomsTaxonomy(
                                    service.getListOfCellCaseIdBySyllabusId(service
                                            .getListOfSyllabusIdByCurriculumId(report.getCurriculumId())),
                                    tq.getBloomsClassId(BloomsClass.Apply.toString()))), content));
                    cell4.setBorder(0);
                    cell4.setPaddingLeft(10);
                    cell4.setHorizontalAlignment(Element.ALIGN_CENTER);
                    cell4.setVerticalAlignment(Element.ALIGN_MIDDLE);

                    PdfPCell cell5 = new PdfPCell(
                            new Paragraph(String.valueOf(service.getTotalItemsByBloomsTaxonomy(
                                    service.getListOfCellCaseIdBySyllabusId(service
                                            .getListOfSyllabusIdByCurriculumId(report.getCurriculumId())),
                                    tq.getBloomsClassId(BloomsClass.Analyze.toString()))), content));
                    cell5.setBorder(0);
                    cell5.setPaddingLeft(10);
                    cell5.setHorizontalAlignment(Element.ALIGN_CENTER);
                    cell5.setVerticalAlignment(Element.ALIGN_MIDDLE);

                    PdfPCell cell6 = new PdfPCell(
                            new Paragraph(String.valueOf(service.getTotalItemsByBloomsTaxonomy(
                                    service.getListOfCellCaseIdBySyllabusId(service
                                            .getListOfSyllabusIdByCurriculumId(report.getCurriculumId())),
                                    tq.getBloomsClassId(BloomsClass.Evaluate.toString()))), content));
                    cell6.setBorder(0);
                    cell6.setPaddingLeft(10);
                    cell6.setHorizontalAlignment(Element.ALIGN_CENTER);
                    cell6.setVerticalAlignment(Element.ALIGN_MIDDLE);

                    PdfPCell cell7 = new PdfPCell(
                            new Paragraph(String.valueOf(service.getTotalItemsByBloomsTaxonomy(
                                    service.getListOfCellCaseIdBySyllabusId(service
                                            .getListOfSyllabusIdByCurriculumId(report.getCurriculumId())),
                                    tq.getBloomsClassId(BloomsClass.Create.toString()))), content));
                    cell7.setBorder(0);
                    cell7.setPaddingLeft(10);
                    cell7.setHorizontalAlignment(Element.ALIGN_CENTER);
                    cell7.setVerticalAlignment(Element.ALIGN_MIDDLE);

                    PdfPCell cell8 = new PdfPCell(new Paragraph(
                            String.valueOf(service.getTotalCellItemsByCellCaseId(
                                    service.getListOfCellCaseIdBySyllabusId(service
                                            .getListOfSyllabusIdByCurriculumId(report.getCurriculumId())))),
                            content));
                    cell8.setBorder(0);
                    cell8.setPaddingLeft(10);
                    cell8.setHorizontalAlignment(Element.ALIGN_CENTER);
                    cell8.setVerticalAlignment(Element.ALIGN_MIDDLE);

                    table2.addCell(cell1);
                    table2.addCell(cell2);
                    table2.addCell(cell3);
                    table2.addCell(cell4);
                    table2.addCell(cell5);
                    table2.addCell(cell6);
                    table2.addCell(cell7);
                    table2.addCell(cell8);
                    document.add(table2);
                }
            }
        }
    } catch (DocumentException ex) {
        Logger.getLogger(InventoryItemsReportPDF.class.getName()).log(Level.SEVERE, null, ex);
    } finally {
        document.close();
    }
}

From source file:com.etest.pdfgenerator.ItemAnalysisOfSubjectReportPDF.java

public ItemAnalysisOfSubjectReportPDF(int curriculumId) {
    this.curriculumId = curriculumId;

    Document document = null;/*from   w w  w .  j av  a  2s. co  m*/

    try {
        document = new Document(PageSize.A4, 50, 50, 50, 50);
        PdfWriter.getInstance(document, outputStream);
        document.open();

        Font header1 = FontFactory.getFont("Times-Roman", 14, Font.BOLD);
        Font header2 = FontFactory.getFont("Times-Roman", 12, Font.BOLD);
        Font content = FontFactory.getFont("Times-Roman", 10);

        Paragraph title1 = new Paragraph();
        title1.setSpacingAfter(10f);
        title1.setAlignment(Element.ALIGN_CENTER);
        title1.add(new Phrase("Interactive Querying", header1));
        document.add(title1);

        Paragraph title2 = new Paragraph();
        title2.setSpacingAfter(10f);
        title2.setAlignment(Element.ALIGN_CENTER);
        title2.add(new Phrase("View Item Analysis of a Subject", content));
        document.add(title2);

        Paragraph subject = new Paragraph();
        subject.setAlignment(Element.ALIGN_LEFT);
        subject.add(new Phrase("Subject: " + cs.getCurriculumById(getCurriculumId()).getSubject().toUpperCase(),
                content));
        document.add(subject);

        Paragraph descriptiveTitle = new Paragraph();
        descriptiveTitle.setAlignment(Element.ALIGN_LEFT);
        descriptiveTitle.add(new Phrase(
                "Descriptive Title: " + cs.getCurriculumById(getCurriculumId()).getDescriptiveTitle(),
                content));
        document.add(descriptiveTitle);

        Paragraph term = new Paragraph();
        term.setSpacingAfter(20f);
        term.setAlignment(Element.ALIGN_LEFT);
        term.add(new Phrase("Normal Course Offering: 2nd Semester", content));
        document.add(term);

        PdfPTable table = new PdfPTable(2);
        table.setWidthPercentage(75);

        PdfPCell cellOne = new PdfPCell(new Phrase("Difficulty"));
        cellOne.setBorder(0);
        cellOne.setHorizontalAlignment(Element.ALIGN_CENTER);
        cellOne.setVerticalAlignment(Element.ALIGN_MIDDLE);

        PdfPCell cellTwo = new PdfPCell(new Phrase("Discrimination"));
        cellTwo.setBorder(0);
        cellTwo.setHorizontalAlignment(Element.ALIGN_CENTER);
        cellTwo.setVerticalAlignment(Element.ALIGN_MIDDLE);

        PdfPCell cellThree = new PdfPCell(new Phrase(String
                .valueOf(rs.getIndexesOfAllTestForASubject(getCurriculumId(), "DifficultIndex", 0.00, 0.19))
                + " Very difficult item(s)", content));
        cellThree.setBorder(0);
        cellThree.setPaddingLeft(50);
        cellThree.setHorizontalAlignment(Element.ALIGN_JUSTIFIED);
        cellThree.setVerticalAlignment(Element.ALIGN_MIDDLE);

        PdfPCell cellFour = new PdfPCell(new Phrase(String.valueOf(
                rs.getIndexesOfAllTestForASubject(getCurriculumId(), "DiscriminationIndex", 0.00, 0.19))
                + " Poor items(s)", content));
        cellFour.setBorder(0);
        cellFour.setHorizontalAlignment(Element.ALIGN_CENTER);
        cellFour.setVerticalAlignment(Element.ALIGN_MIDDLE);

        PdfPCell cellFive = new PdfPCell(new Phrase(String
                .valueOf(rs.getIndexesOfAllTestForASubject(getCurriculumId(), "DifficultIndex", 0.20, 0.39))
                + " difficult item(s)", content));
        cellFive.setBorder(0);
        cellFive.setPaddingLeft(50);
        cellFive.setHorizontalAlignment(Element.ALIGN_JUSTIFIED);
        cellFive.setVerticalAlignment(Element.ALIGN_MIDDLE);

        PdfPCell cellSix = new PdfPCell(new Phrase(String.valueOf(
                rs.getIndexesOfAllTestForASubject(getCurriculumId(), "DiscriminationIndex", 0.20, 0.29))
                + " Marginal items(s)", content));
        cellSix.setBorder(0);
        cellSix.setHorizontalAlignment(Element.ALIGN_CENTER);
        cellSix.setVerticalAlignment(Element.ALIGN_MIDDLE);

        PdfPCell cellSeven = new PdfPCell(new Phrase(String
                .valueOf(rs.getIndexesOfAllTestForASubject(getCurriculumId(), "DifficultIndex", 0.40, 0.60))
                + " Average item(s)", content));
        cellSeven.setBorder(0);
        cellSeven.setPaddingLeft(50);
        cellSeven.setHorizontalAlignment(Element.ALIGN_JUSTIFIED);
        cellSeven.setVerticalAlignment(Element.ALIGN_MIDDLE);

        PdfPCell cellEight = new PdfPCell(new Phrase(String.valueOf(
                rs.getIndexesOfAllTestForASubject(getCurriculumId(), "DiscriminationIndex", 0.30, 0.39))
                + " Reasonably Good items(s)", content));
        cellEight.setBorder(0);
        cellEight.setHorizontalAlignment(Element.ALIGN_CENTER);
        cellEight.setVerticalAlignment(Element.ALIGN_MIDDLE);

        PdfPCell cellNine = new PdfPCell(new Phrase(String
                .valueOf(rs.getIndexesOfAllTestForASubject(getCurriculumId(), "DifficultIndex", 0.61, 0.80))
                + " Easy item(s)", content));
        cellNine.setBorder(0);
        cellNine.setPaddingLeft(50);
        cellNine.setHorizontalAlignment(Element.ALIGN_JUSTIFIED);
        cellNine.setVerticalAlignment(Element.ALIGN_MIDDLE);

        PdfPCell cellTen = new PdfPCell(new Phrase(String
                .valueOf(rs.getIndexesOfAllTestForASubject(getCurriculumId(), "DiscriminationIndex", 0.41, 1))
                + " Very good items(s)", content));
        cellTen.setBorder(0);
        cellTen.setHorizontalAlignment(Element.ALIGN_CENTER);
        cellTen.setVerticalAlignment(Element.ALIGN_MIDDLE);

        PdfPCell cellEleven = new PdfPCell(new Phrase(
                String.valueOf(rs.getIndexesOfAllTestForASubject(getCurriculumId(), "DifficultIndex", 0.81, 1))
                        + " Very Easy item(s)",
                content));
        cellEleven.setBorder(0);
        cellEleven.setPaddingLeft(50);
        cellEleven.setHorizontalAlignment(Element.ALIGN_JUSTIFIED);
        cellEleven.setVerticalAlignment(Element.ALIGN_MIDDLE);

        PdfPCell cellTwelve = new PdfPCell(new Phrase(""));
        cellTwelve.setBorder(0);
        cellTwelve.setHorizontalAlignment(Element.ALIGN_CENTER);
        cellTwelve.setVerticalAlignment(Element.ALIGN_MIDDLE);

        table.addCell(cellOne);
        table.addCell(cellTwo);
        table.addCell(cellThree);
        table.addCell(cellFour);
        table.addCell(cellFive);
        table.addCell(cellSix);
        table.addCell(cellSeven);
        table.addCell(cellEight);
        table.addCell(cellNine);
        table.addCell(cellTen);
        table.addCell(cellEleven);
        table.addCell(cellTwelve);

        document.add(table);
    } catch (DocumentException ex) {
        Logger.getLogger(ItemAnalysisOfSubjectReportPDF.class.getName()).log(Level.SEVERE, null, ex);
    } finally {
        if (document != null) {
            document.close();
        }
    }
}

From source file:com.etest.pdfgenerator.ItemAnalysisReportPDF.java

public ItemAnalysisReportPDF(int tqCoverageId) {
    this.tqCoverageId = tqCoverageId;

    Document document = null;/*from  www  .j  a v a 2s  . c om*/
    Date date = new Date();

    try {
        document = new Document(PageSize.A4, 50, 50, 50, 50);
        PdfWriter.getInstance(document, outputStream);
        document.open();

        Font header = FontFactory.getFont("Times-Roman", 12, Font.BOLD);
        Font content = FontFactory.getFont("Times-Roman", 10);
        Font dateFont = FontFactory.getFont("Times-Roman", 8);

        Image img = null;
        try {
            img = Image.getInstance("C:\\eTest-images\\SUCN_seal.png");
            img.scaleToFit(60, 60);
            img.setAbsolutePosition(450, 730);
        } catch (BadElementException | IOException ex) {
            Logger.getLogger(TQCoveragePDF.class.getName()).log(Level.SEVERE, null, ex);
        }
        document.add(img);

        Paragraph reportTitle = new Paragraph();
        reportTitle.setAlignment(Element.ALIGN_CENTER);
        reportTitle.add(new Phrase("Item Analysis Report", header));
        document.add(reportTitle);

        Paragraph datePrinted = new Paragraph();
        datePrinted.setSpacingAfter(20f);
        datePrinted.setAlignment(Element.ALIGN_CENTER);
        datePrinted.add(
                new Phrase("Date printed: " + new SimpleDateFormat("dd MMMM yyyy").format(date), dateFont));
        document.add(datePrinted);

        Paragraph subject = new Paragraph();
        subject.setAlignment(Element.ALIGN_LEFT);
        subject.add(new Phrase(
                "Subject: " + cs.getCurriculumById(tq.getTQCoverageById(getTqCoverageId()).getCurriculumId())
                        .getSubject().toUpperCase(),
                content));
        document.add(subject);

        Paragraph term = new Paragraph();
        term.setAlignment(Element.ALIGN_LEFT);
        term.add(new Phrase("SY and Semester Administered: 2015-16 2nd Semester", content));
        document.add(term);

        Paragraph type = new Paragraph();
        type.setSpacingAfter(20f);
        type.setAlignment(Element.ALIGN_LEFT);
        type.add(
                new Phrase("Type of Test: " + tq.getTQCoverageById(getTqCoverageId()).getExamTitle(), content));
        document.add(type);

        PdfPTable table = new PdfPTable(5);
        table.setWidthPercentage(100);
        table.setWidths(new int[] { 130, 300, 300, 300, 300 });
        //            table.setSpacingAfter(5f);             

        PdfPCell cellOne = new PdfPCell(new Phrase("Item No."));
        cellOne.setBorderWidthTop(1);
        cellOne.setBorderWidthLeft(1);
        cellOne.setBorderWidthRight(1);
        cellOne.setBorderWidthBottom(1);
        cellOne.setPaddingLeft(10);
        cellOne.setPaddingRight(10);
        cellOne.setHorizontalAlignment(Element.ALIGN_JUSTIFIED);
        cellOne.setVerticalAlignment(Element.ALIGN_MIDDLE);

        PdfPCell cellTwo = new PdfPCell(new Phrase("Difficulty"));
        cellTwo.setBorderWidthTop(1);
        cellTwo.setBorderWidthLeft(1);
        cellTwo.setBorderWidthRight(1);
        cellTwo.setBorderWidthBottom(1);
        cellTwo.setHorizontalAlignment(Element.ALIGN_CENTER);
        cellTwo.setVerticalAlignment(Element.ALIGN_MIDDLE);

        PdfPCell cellThree = new PdfPCell(new Phrase("Interpretation"));
        cellThree.setBorderWidthTop(1);
        cellThree.setBorderWidthLeft(1);
        cellThree.setBorderWidthRight(1);
        cellThree.setBorderWidthBottom(1);
        cellThree.setHorizontalAlignment(Element.ALIGN_CENTER);
        cellThree.setVerticalAlignment(Element.ALIGN_MIDDLE);

        PdfPCell cellFour = new PdfPCell(new Phrase("Discrimination"));
        cellFour.setBorderWidthTop(1);
        cellFour.setBorderWidthLeft(1);
        cellFour.setBorderWidthRight(1);
        cellFour.setBorderWidthBottom(1);
        cellFour.setHorizontalAlignment(Element.ALIGN_CENTER);
        cellFour.setVerticalAlignment(Element.ALIGN_MIDDLE);

        PdfPCell cellFive = new PdfPCell(new Phrase("Interpretation"));
        cellFive.setBorderWidthTop(1);
        cellFive.setBorderWidthLeft(1);
        cellFive.setBorderWidthRight(1);
        cellFive.setBorderWidthBottom(1);
        cellFive.setHorizontalAlignment(Element.ALIGN_CENTER);
        cellFive.setVerticalAlignment(Element.ALIGN_MIDDLE);

        table.addCell(cellOne);
        table.addCell(cellTwo);
        table.addCell(cellThree);
        table.addCell(cellFour);
        table.addCell(cellFive);

        table.getDefaultCell().setBorderWidth(0f);
        document.add(table);

        PdfPTable table2 = new PdfPTable(5);
        table2.setWidthPercentage(100);
        table2.setWidths(new int[] { 130, 300, 300, 300, 300 });

        int itemNo = 1;
        for (CellItem ci : cis.getItemAnalysisResult(tqCoverageId)) {
            PdfPCell cell1 = new PdfPCell(new Paragraph(String.valueOf(itemNo), content));
            cell1.setBorderWidthTop(1);
            cell1.setBorderWidthLeft(1);
            cell1.setBorderWidthRight(1);
            cell1.setBorderWidthBottom(1);
            cell1.setPaddingLeft(10);
            cell1.setHorizontalAlignment(Element.ALIGN_JUSTIFIED);
            cell1.setVerticalAlignment(Element.ALIGN_MIDDLE);

            PdfPCell cell2 = new PdfPCell(new Paragraph(String.valueOf(ci.getDifficultIndex()), content));
            cell2.setBorderWidthTop(1);
            cell2.setBorderWidthLeft(1);
            cell2.setBorderWidthRight(1);
            cell2.setBorderWidthBottom(1);
            cell2.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell2.setVerticalAlignment(Element.ALIGN_MIDDLE);

            PdfPCell cell3 = new PdfPCell(new Paragraph(
                    ItemAnalysisInterpretation.getDifficultyInterpretation(ci.getDifficultIndex()), content));
            cell3.setBorderWidthTop(1);
            cell3.setBorderWidthLeft(1);
            cell3.setBorderWidthRight(1);
            cell3.setBorderWidthBottom(1);
            cell3.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell3.setVerticalAlignment(Element.ALIGN_MIDDLE);

            PdfPCell cell4 = new PdfPCell(new Paragraph(String.valueOf(ci.getDiscriminationIndex()), content));
            cell4.setBorderWidthTop(1);
            cell4.setBorderWidthLeft(1);
            cell4.setBorderWidthRight(1);
            cell4.setBorderWidthBottom(1);
            cell4.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell4.setVerticalAlignment(Element.ALIGN_MIDDLE);

            PdfPCell cell5 = new PdfPCell(new Paragraph(
                    ItemAnalysisInterpretation.getDiscriminationInterpretation(ci.getDiscriminationIndex()),
                    content));
            cell5.setBorderWidthTop(1);
            cell5.setBorderWidthLeft(1);
            cell5.setBorderWidthRight(1);
            cell5.setBorderWidthBottom(1);
            cell5.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell5.setVerticalAlignment(Element.ALIGN_MIDDLE);

            table2.addCell(cell1);
            table2.addCell(cell2);
            table2.addCell(cell3);
            table2.addCell(cell4);
            table2.addCell(cell5);

            itemNo++;
        }
        table.getDefaultCell().setBorderWidth(0f);
        document.add(table2);

    } catch (DocumentException ex) {
        Logger.getLogger(ItemAnalysisReportPDF.class.getName()).log(Level.SEVERE, null, ex);
    } finally {
        document.close();
    }
}