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

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

Introduction

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

Prototype

public void setSpacingAfter(final float spacing) 

Source Link

Document

Sets the spacing after this table.

Usage

From source file:es.sm2.openppm.front.utils.DocumentUtils.java

License:Open Source License

/**
 * Create PDF for Control Change/*from  w  w  w. j  a va2  s  .c  o m*/
 * @param idioma
 * @param project
 * @param change
 * @param preparedBy
 * @return
 * @throws DocumentException
 * @throws LogicException
 */
public static byte[] toPdf(ResourceBundle idioma, Project project, Changecontrol change, Employee preparedBy,
        final Image headerImg, final Image footerImg) throws DocumentException, LogicException {

    if (change == null) {
        throw new DocumentException("No change control found.");
    }

    if (preparedBy == null || preparedBy.getContact() == null) {
        throw new UserSendingException();
    }

    Document document = new Document(PageSize.A4);
    document.setMargins(70F, 70F, 38F, 38F); // Total Height: 842pt, Total Width: 595pt
    byte[] file = null;

    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    @SuppressWarnings("unused")
    PdfWriter pdfWriter = PdfWriter.getInstance(document, outputStream);

    document.open();

    Font fontHeader = new Font(FontFamily.TIMES_ROMAN, 9, Font.BOLD);
    Font fontCell = new Font(FontFamily.TIMES_ROMAN, 9);
    Font tituloFont = new Font(FontFamily.TIMES_ROMAN, 16, Font.BOLD);

    document.add(new Paragraph(" ", tituloFont));
    document.add(new Paragraph(" ", tituloFont));
    document.add(new Paragraph(" ", fontHeader));
    Paragraph title = new Paragraph(idioma.getString("change_request").toUpperCase(), tituloFont);
    title.setAlignment(Paragraph.ALIGN_CENTER);
    document.add(title);

    // Header Table
    // Project info
    PdfPTable tableHeader = new PdfPTable(3);
    tableHeader.setWidthPercentage(100);
    tableHeader.setSpacingBefore(10);
    tableHeader.setSpacingAfter(15);

    int[] colWidth = new int[3];
    colWidth[0] = 40;
    colWidth[1] = 30;
    colWidth[2] = 30;
    tableHeader.setWidths(colWidth);

    tableHeader.addCell(
            prepareHeaderCell(idioma.getString("change_request.project_name"), fontHeader, 1F, 0F, 0F, 1F));
    tableHeader.addCell(
            prepareHeaderCell(idioma.getString("change_request.prepared_by"), fontHeader, 1F, 0F, 0F, 1F));
    tableHeader.addCell(prepareHeaderCell(idioma.getString("change_request.date"), fontHeader, 1F, 1F, 0F, 1F));

    tableHeader.addCell(prepareCell(project.getProjectName() + " / " + project.getAccountingCode(), fontCell,
            0F, 0F, 0F, 1F));
    tableHeader.addCell(prepareCell(preparedBy.getContact().getFullName(), fontCell, 0F, 0F, 0F, 1F));
    tableHeader.addCell(prepareCell(DateUtil.format(idioma, new Date()), fontCell, 0F, 1F, 0F, 1F));

    tableHeader.addCell(
            prepareHeaderCell(idioma.getString("change_request.customer"), fontHeader, 1F, 0F, 0F, 1F));
    tableHeader.addCell(
            prepareHeaderCell(idioma.getString("change_request.contact_name"), fontHeader, 1F, 0F, 0F, 1F));
    tableHeader.addCell(
            prepareHeaderCell(idioma.getString("change_request.customer_type"), fontHeader, 1F, 1F, 0F, 1F));

    tableHeader.addCell(prepareCell(project.getCustomer() != null ? project.getCustomer().getName() : "",
            fontCell, 0F, 0F, 0F, 1F));
    tableHeader.addCell(prepareCell((project.getCustomer() != null ? project.getCustomer().getName() : "-"),
            fontCell, 0F, 0F, 0F, 1F));

    Customertype cusType = (project.getCustomer() != null ? project.getCustomer().getCustomertype() : null);
    tableHeader.addCell(prepareCell(cusType == null ? "" : cusType.getName(), fontCell, 0F, 1F, 0F, 1F));

    tableHeader.addCell(
            prepareHeaderCell(idioma.getString("change_request.business_manager"), fontHeader, 1F, 0F, 0F, 1F));
    tableHeader.addCell(
            prepareHeaderCell(idioma.getString("change_request.project_manager"), fontHeader, 1F, 0F, 0F, 1F));
    tableHeader.addCell(
            prepareHeaderCell(idioma.getString("change_request.originator"), fontHeader, 1F, 1F, 0F, 1F));

    Employee bm = project.getEmployeeByFunctionalManager();
    Employee pm = project.getEmployeeByProjectManager();

    tableHeader.addCell(prepareCell(bm == null ? "" : bm.getContact().getFullName(), fontCell, 0F, 0F, 1F, 1F));
    tableHeader.addCell(prepareCell(pm == null ? "" : pm.getContact().getFullName(), fontCell, 0F, 0F, 1F, 1F));
    tableHeader.addCell(prepareCell(change.getOriginator(), fontCell, 0F, 1F, 1F, 1F));

    document.add(tableHeader);

    // Change Information
    document.add(new Paragraph(idioma.getString("change_information")));

    PdfPTable tableInfo = new PdfPTable(1);
    tableInfo.setWidthPercentage(100);
    tableInfo.setSpacingBefore(10);
    tableInfo.setSpacingAfter(15);

    tableInfo.addCell(prepareHeaderCell(idioma.getString("change.change_type"), fontHeader, 1F, 1F, 0F, 1F));
    tableInfo.addCell(prepareCell(change.getChangetype().getDescription(), fontCell, 0F, 1F, 0F, 1F));

    String priorityDesc = "";
    if (change.getPriority().equals('H'))
        priorityDesc = idioma.getString("change.priority.high");
    if (change.getPriority().equals('N'))
        priorityDesc = idioma.getString("change.priority.normal");
    if (change.getPriority().equals('L'))
        priorityDesc = idioma.getString("change.priority.low");

    tableInfo.addCell(prepareHeaderCell(idioma.getString("change.priority"), fontHeader, 1F, 1F, 0F, 1F));
    tableInfo.addCell(prepareCell(priorityDesc, fontCell, 0F, 1F, 0F, 1F));

    tableInfo.addCell(prepareHeaderCell(idioma.getString("change.desc"), fontHeader, 1F, 1F, 0F, 1F));
    tableInfo.addCell(prepareCell(change.getDescription(), fontCell, 0F, 1F, 0F, 1F));

    tableInfo.addCell(
            prepareHeaderCell(idioma.getString("change.recommended_solution"), fontHeader, 1F, 1F, 0F, 1F));
    tableInfo.addCell(prepareCell(change.getRecommendedSolution(), fontCell, 0F, 1F, 1F, 1F));

    PdfPTable tableSubInfo = new PdfPTable(3);
    tableSubInfo.setWidthPercentage(100);

    //TODO MIGRACION
    tableSubInfo.addCell(prepareSubCell(idioma.getString("change.wbs_node"), fontHeader));
    tableSubInfo.addCell(prepareSubCell(idioma.getString("change.estimated_effort"), fontHeader));
    tableSubInfo.addCell(prepareSubCell(idioma.getString("change.estimated_cost"), fontHeader));

    tableSubInfo.addCell(
            prepareSubCell((change.getWbsnode() != null ? change.getWbsnode().getName() : ""), fontCell));
    tableSubInfo.addCell(prepareSubCell(
            (change.getEstimatedEffort() != null ? String.valueOf(change.getEstimatedEffort()) : ""),
            fontCell));
    tableSubInfo.addCell(prepareSubCell(
            (change.getEstimatedCost() != null ? ValidateUtil.toCurrency(change.getEstimatedCost()) : ""),
            fontCell));

    PdfPCell subTable = new PdfPCell(tableSubInfo);
    subTable.setBorderWidth(1F);

    tableInfo.addCell(subTable);

    tableInfo.addCell(prepareHeaderCell(idioma.getString("change.impact_desc"), fontHeader, 1F, 1F, 0F, 1F));
    tableInfo.addCell(prepareCell(change.getImpactDescription(), fontCell, 0F, 1F, 1F, 1F));

    document.add(tableInfo);

    document.add(new Paragraph(idioma.getString("change.resolution")));

    PdfPTable tableResolution = new PdfPTable(1);
    tableResolution.setWidthPercentage(100);
    tableResolution.setSpacingBefore(10);
    tableResolution.setSpacingAfter(15);

    tableResolution
            .addCell(prepareHeaderCell(idioma.getString("change.resolution"), fontHeader, 1F, 1F, 0F, 1F));
    tableResolution.addCell(
            prepareCell((change.getResolution() != null && change.getResolution() ? idioma.getString("yes")
                    : idioma.getString("no")), fontCell, 0F, 1F, 0F, 1F));

    tableResolution
            .addCell(prepareHeaderCell(idioma.getString("change.resolution_date"), fontHeader, 1F, 1F, 0F, 1F));
    tableResolution.addCell(
            prepareCell(DateUtil.format(idioma, change.getResolutionDate()), fontCell, 0F, 1F, 0F, 1F));

    tableResolution.addCell(
            prepareHeaderCell(idioma.getString("change.resolution_reason"), fontHeader, 1F, 1F, 0F, 1F));
    tableResolution.addCell(prepareCell(change.getResolutionReason(), fontCell, 0F, 1F, 1F, 1F));

    document.add(tableResolution);

    document.close();

    try {

        PdfReader reader = new PdfReader(outputStream.toByteArray());
        PdfStamper stamper = new PdfStamper(reader, outputStream);

        int numPag = reader.getNumberOfPages();

        for (int i = 1; i <= reader.getNumberOfPages(); i++) {
            setHeaderFooter(i, numPag, headerImg, footerImg, reader, stamper, idioma);
        }

        stamper.close();
    } catch (IOException e) {
        e.printStackTrace();
    }

    file = outputStream.toByteArray();

    return file;
}

From source file:femr.ui.controllers.PDFController.java

License:Open Source License

/**
 * Builds the page header - Title and Empty cell (for border)
 *
 * @return PdfPTable the itext table to add to the document
 *//*www .  ja v a 2  s. c o  m*/
public PdfPTable createHeaderTable() {

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

    Paragraph title = new Paragraph("Medical Record", new Font(Font.FontFamily.TIMES_ROMAN, 18, Font.BOLD));
    PdfPCell cell = new PdfPCell(title);
    cell.setVerticalAlignment(Element.ALIGN_BOTTOM);
    cell.setBorder(PdfPCell.NO_BORDER);
    cell.setBorderColorBottom(BaseColor.BLACK);
    cell.setBorderWidthBottom(1);
    cell.setPaddingBottom(5);
    table.addCell(cell);

    //Paragraph encounterId = new Paragraph("Encounter ID: " + patientEncounter.getId(), new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.NORMAL));
    cell = new PdfPCell(table.getDefaultCell());
    cell.setVerticalAlignment(Element.ALIGN_BOTTOM);
    cell.setBorder(PdfPCell.NO_BORDER);
    cell.setBorderColorBottom(BaseColor.BLACK);
    cell.setBorderWidthBottom(1);
    cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
    cell.setPaddingBottom(5);
    table.addCell(cell);

    return table;
}

From source file:femr.ui.controllers.PDFController.java

License:Open Source License

/**
 * Builds a table with numColumns with the base stylins
 * @param numColumns the number of columns the table will have
 * @return an instantiated PdfPTable object
 *//*from   ww w .j  av a 2s.  c  om*/
private PdfPTable getDefaultTable(int numColumns) {
    PdfPTable table = new PdfPTable(numColumns);
    table.setWidthPercentage(100);
    table.setSpacingAfter(10);
    table.getDefaultCell().setPaddingBottom(5);
    table.getDefaultCell().setBorder(PdfPCell.NO_BORDER);

    return table;
}

From source file:fenix.planner.pdf.PDFGenerator.java

License:Open Source License

private void createAndAddEventTable() throws DocumentException {
    PdfPTable table = new PdfPTable(new float[] { 1, 7, 1.2f });
    table.setWidthPercentage(100f);/*from   w w  w . ja  v  a  2s .  c  o  m*/
    table.getDefaultCell().setUseAscender(true);
    table.getDefaultCell().setUseDescender(true);
    table.setSpacingBefore(20);
    table.setSpacingAfter(20);

    // Header row
    table.getDefaultCell().setBorderWidthLeft(0);
    table.getDefaultCell().setBorderWidthTop(0);
    table.getDefaultCell().setBorderWidthRight(0);
    table.getDefaultCell().setPadding(5);
    table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
    table.addCell(new Phrase("Datum", headerFont));
    table.addCell(new Phrase("mne", headerFont));
    table.addCell(new Phrase("Ansvarig", headerFont));
    table.setHeaderRows(1);
    table.getDefaultCell().setBackgroundColor(null);

    // Events
    for (Event event : program.getSortedCopyOfEvents()) {
        if (event.getDate().getMonthOfYear() % 2 == 0) {
            table.getDefaultCell().setBackgroundColor(new BaseColor(0xdd, 0xdd, 0xdd));
        } else {
            table.getDefaultCell().setBackgroundColor(null);
        }

        if (!event.getType().getBackgroundColor().equals(Color.WHITE)) {
            table.getDefaultCell()
                    .setBackgroundColor(awtColorToBaseColor(event.getType().getBackgroundColor()));
        }

        final BaseColor textColor = awtColorToBaseColor(event.getType().getForegroundColor());

        PdfPCell dateCell = new PdfPCell(table.getDefaultCell());
        dateCell.addElement(
                new Phrase(event.getDate().toString("dd.MM", locale), changeColor(subjectFont, textColor)));
        table.addCell(dateCell);

        PdfPCell subjectCell = new PdfPCell(table.getDefaultCell());
        subjectCell.addElement(new Phrase(event.getSubject(), changeColor(subjectFont, textColor)));
        if (event.getDescription().length() > 0) {
            subjectCell.addElement(new Phrase(event.getDescription(), changeColor(descriptionFont, textColor)));
        }
        if (event.getOrganizer() == null) {
            subjectCell.setColspan(2);
        }
        table.addCell(subjectCell);

        if (event.getOrganizer() != null) {
            PdfPCell organizerCell = new PdfPCell(table.getDefaultCell());
            organizerCell.addElement(
                    new Phrase(event.getOrganizer().getInitials(), changeColor(subjectFont, textColor)));
            table.addCell(organizerCell);
        }
    }

    document.add(table);
}

From source file:file.PDFWriter.java

License:Open Source License

/**
 * Add the page number and line to the PDF
 * @param splitLines the array of line segments to print
 * @param page the page number the line was on
 * @throws DocumentException /*from  ww w .  j  a va  2 s  .  c o  m*/
 */
private void addLineTableToPDF(String[] splitLines, String page) throws DocumentException {
    PdfPTable lineTable = new PdfPTable(2);
    PdfPCell pageCell = new PdfPCell(new Paragraph("Page: " + page, lineFont));
    pageCell.setPadding(20);
    pageCell.setPaddingLeft(0);
    pageCell.setBorder(PdfPCell.NO_BORDER);
    Chunk lineSegment1 = new Chunk(splitLines[0]);
    lineSegment1.setFont(lineFont);
    Chunk error1 = new Chunk(splitLines[1]);
    error1.setFont(lineFontBold);
    Chunk lineSegment2 = new Chunk(splitLines[2]);
    lineSegment2.setFont(lineFont);
    Chunk error2 = new Chunk(splitLines[3]);
    error2.setFont(lineFontBold);
    Chunk lineSegment3 = new Chunk(splitLines[4]);
    lineSegment3.setFont(lineFont);

    Phrase line = new Phrase(lineSegment1);
    line.add(error1);
    line.add(lineSegment2);
    line.add(error2);
    line.add(lineSegment3);

    PdfPCell lineCell = new PdfPCell(line);
    lineCell.setPadding(20);
    lineCell.setBorder(PdfPCell.NO_BORDER);
    lineTable.setWidthPercentage(100);
    lineTable.setWidths(new int[] { 2, 10 });
    lineTable.setSpacingBefore(1f);
    lineTable.setSpacingAfter(1f);

    lineTable.addCell(pageCell);
    lineTable.addCell(lineCell);
    document.add(lineTable);
    document.add(Chunk.NEWLINE);
}

From source file:fr.ybonnel.breizhcamppdf.PdfRenderer.java

License:Apache License

private PdfPTable createBeginningOfPage(Font font, String date) throws DocumentException {
    Paragraph titre;//from  w  w w .ja  va2s  .  c  o m
    document.newPage();
    titre = new Paragraph();
    titre.setFont(font);
    titre.setAlignment(Paragraph.ALIGN_CENTER);
    titre.add(new Phrase("Programme du " + date));
    document.add(titre);

    float[] relativeWidth = new float[service.getRooms(date).size() + 1];
    Arrays.fill(relativeWidth, 1f);
    relativeWidth[0] = 0.5f;

    PdfPTable table = new PdfPTable(relativeWidth);

    table.setWidthPercentage(100);
    table.setSpacingBefore(10);
    table.setSpacingAfter(20);

    table.addCell(createHeaderCell("Heure"));
    for (String room : service.getRooms(date)) {
        table.addCell(createHeaderCell(room));
    }
    return table;
}

From source file:fr.ybonnel.breizhcamppdf.RoomPdfRenderer.java

License:Apache License

private PdfPTable createBeginningOfPage(Font font, String date, String room) throws DocumentException {
    Paragraph titre;//from   w  w  w  .  ja  va 2  s . c om
    document.newPage();
    titre = new Paragraph();
    titre.setFont(font);
    titre.setAlignment(Paragraph.ALIGN_CENTER);
    titre.add(new Phrase("Programme du " + date + " - " + room));
    titre.setSpacingAfter(20);
    document.add(titre);

    float[] relativeWidth = new float[2];
    Arrays.fill(relativeWidth, 1f);
    relativeWidth[0] = 0.2f;

    PdfPTable table = new PdfPTable(relativeWidth);

    table.setWidthPercentage(100);
    table.setSpacingBefore(10);
    table.setSpacingAfter(20);

    table.addCell(createHeaderCell("Heure"));
    table.addCell(createHeaderCell(""));

    return table;
}

From source file:fxml.test.PDFService.java

public void generatePdf() {
    //   Document document = new Document(PageSize.A4.rotate());
    Document document = new Document(new Rectangle(1008, 612));

    try {//from  www .  jav a  2 s .c  om
        PdfWriter.getInstance(document, new FileOutputStream("table.pdf"));

        document.setMargins(90, 80, 35, 40);
        document.open();

        if (!list.isEmpty()) {

            list.add("Total Credit");
            list.add("Total GPA");
            list.add("Letter Grade");
            list.add("Cumulative");
            list.add("Remarks");
            list.add("GC");

            if (inputs.get(1).contains("8th")) {

                list.add("PC. No");
                list.add("OC. No");
                list.add("D/AF. No");
                list.add("Others");
            }

            int totalCoureseSize = list.size();
            int totalCourseLoop = totalCoureseSize / 12;
            int courseLoopVariable = 0;

            if (totalCoureseSize % 12 > 0) {
                totalCourseLoop += 1;
            }

            int totalStudentSize = studentList.size();
            int totalStudentLoop = (totalStudentSize / 15);
            int studentLoopVariable = 0;

            if (totalStudentSize % 15 > 0) {
                totalStudentLoop += 1;
            }

            if (totalStudentLoop > 0) {

                for (studentLoopVariable = 0; studentLoopVariable < totalStudentLoop; studentLoopVariable++) {

                    //start print the courses when it is multiple of 12
                    if (totalCourseLoop > 0) {

                        for (courseLoopVariable = 0; courseLoopVariable < totalCourseLoop; courseLoopVariable++) {

                            int courseStart = courseLoopVariable * 12;
                            int studentStart = studentLoopVariable * 15;

                            //start document header
                            document.add(createDocumentHeader());
                            //end document header

                            //start table header
                            PdfPTable table = createTableHeader(courseStart);
                            //end table header

                            //start table body
                            table = createTableBody(studentStart, courseStart, table);
                            //end table body

                            //adding table and footer
                            table.setSpacingAfter(27);
                            document.add(table);
                            document.add(createFooter1());
                            document.add(createFooter2());
                            //end adding table and footer
                            //go to new page..
                            document.newPage();
                        }
                    }
                }
            }
        }

        document.close();

    } catch (DocumentException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } catch (Exception e) {
        AlertMessage.showAlertMessage(Alert.AlertType.ERROR, "Error creating Pdf document.Please try again");
        e.printStackTrace();
    }
}

From source file:fxml.test.PDFService.java

private PdfPTable createDocumentHeader() throws IOException, BadElementException {

    //start creating header for the document......
    PdfPTable headerTable = new PdfPTable(3);
    headerTable.setHorizontalAlignment(Element.ALIGN_LEFT);
    try {/*w  ww .  j a  va  2 s  .co  m*/
        headerTable.setTotalWidth(new float[] { 57.5f, 531.5f, 183f });
        headerTable.setLockedWidth(true);

    } catch (DocumentException ex) {
        Logger.getLogger(PDFService.class.getName()).log(Level.SEVERE, null, ex);
    }

    Image image = Image.getInstance(getClass().getClassLoader().getResource("img/sust.jpg"));
    image.scalePercent(42f);
    image.setAlignment(Element.ALIGN_LEFT);
    PdfPCell imageCell = new PdfPCell(image, false);
    imageCell.setPaddingTop(6);
    imageCell.setBorder(Rectangle.NO_BORDER);
    headerTable.addCell(imageCell);

    //start info table.....
    PdfPTable infoTable = new PdfPTable(1);
    infoTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);

    String universityText = "SHAHJALAL UNIVERSITY OF SCIENCE & TECHNOLOGY SYLHET, BANGLADESH";
    String tabulationText = "TABULATION SHEET";
    String deptText = inputs.get(0).trim();

    String s1 = inputs.get(1).trim();
    String s2 = inputs.get(2).trim();
    String semesterText = ("B.Sc (Engg.) " + s1 + " SEMESTER EXAMINATION " + s2);

    String session = inputs.get(3).trim();
    String date = inputs.get(4).trim();

    String sessionDateText = ("SESSION:" + session + " EXAMINATION HELD IN: " + date);

    infoTable.addCell(getCellForHeaderString(universityText, 0, false, 0, Element.ALIGN_CENTER, font10, true));
    infoTable.addCell(getCellForHeaderString(tabulationText, 0, false, 0, Element.ALIGN_CENTER, font10, false));
    infoTable.addCell(getCellForHeaderString(deptText, 0, false, 0, Element.ALIGN_CENTER, font10, false));
    infoTable.addCell(getCellForHeaderString(semesterText, 0, false, 0, Element.ALIGN_CENTER, font10, false));
    infoTable
            .addCell(getCellForHeaderString(sessionDateText, 0, false, 0, Element.ALIGN_CENTER, font10, false));
    //end info table.....

    PdfPCell infoCell = new PdfPCell(infoTable);
    infoCell.setBorder(Rectangle.NO_BORDER);
    headerTable.addCell(infoCell);

    PdfPCell resultPublishDateCell = new PdfPCell(
            new Paragraph("Result Published On............................",
                    new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.BOLD)));
    resultPublishDateCell.setBorder(Rectangle.NO_BORDER);
    resultPublishDateCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    resultPublishDateCell.setHorizontalAlignment(Element.ALIGN_RIGHT);
    headerTable.addCell(resultPublishDateCell);
    headerTable.setSpacingAfter(17.5f);
    // System.err.println("completed header table");
    return headerTable;
    //end creating header for the document......
}

From source file:fxml.test.PDFService.java

public PdfPTable createFooter1() {

    //String[] names = new String[]{"Md. Eamin Rahman", "Md. Mujibur Rahman", "Md Masum", "Md. Saiful Islam", "Husne Ara Chowdhury", "Sabir Ismail"};
    PdfPTable table = new PdfPTable(5);
    table.setHorizontalAlignment(Element.ALIGN_LEFT);

    try {// ww w  .  j  a  va  2  s .com
        table.setTotalWidth(new float[] { 161f, 161f, 133f, 167f, 161f });
        table.setLockedWidth(true);

    } catch (DocumentException ex) {
        Logger.getLogger(PDFService.class.getName()).log(Level.SEVERE, null, ex);
    }
    //table.setWidthPercentage(100);
    PdfPCell chairmanSIgnature = new PdfPCell(new Paragraph("Signature of the Chairman:", font9));
    chairmanSIgnature.setBorder(Rectangle.NO_BORDER);
    chairmanSIgnature.setPaddingLeft(0f);
    chairmanSIgnature.setPaddingTop(5);
    table.addCell(chairmanSIgnature);

    PdfPCell underLine = new PdfPCell(new Paragraph("_______________________"));
    underLine.setBorder(Rectangle.NO_BORDER);
    table.addCell(underLine);

    PdfPCell blankColumn = new PdfPCell(new Paragraph(" "));
    blankColumn.setBorder(Rectangle.NO_BORDER);
    table.addCell(blankColumn);

    Paragraph p = new Paragraph("Signature of The Controller of Examinations:", font9);
    p.setLeading(0, 1.3f);
    PdfPCell controllerSignature = new PdfPCell();
    controllerSignature.addElement(p);
    controllerSignature.setBorder(Rectangle.NO_BORDER);
    table.addCell(controllerSignature);
    table.addCell(underLine);

    PdfPCell cell1 = new PdfPCell(new Paragraph(inputs.get(5).trim(), font9));
    cell1.setPaddingTop(0f);
    cell1.setBorder(Rectangle.NO_BORDER);

    PdfPCell cell2 = new PdfPCell(new Paragraph(inputs.get(6).trim(), font9));
    cell2.setPaddingTop(0f);
    cell2.setBorder(Rectangle.NO_BORDER);

    PdfPCell nameColumn = new PdfPCell(new Paragraph("Name :", font9));
    nameColumn.setBorder(Rectangle.NO_BORDER);
    nameColumn.setPaddingLeft(0f);
    nameColumn.setPaddingTop(0f);

    PdfPCell nameColumn2 = new PdfPCell(new Paragraph("Name :", font9));
    nameColumn2.setBorder(Rectangle.NO_BORDER);
    nameColumn2.setPaddingTop(0f);

    table.addCell(nameColumn);
    table.addCell(cell1);
    table.addCell(blankColumn);
    table.addCell(nameColumn2);
    table.addCell(cell2);

    table.setSpacingAfter(23.5f);
    return table;
}