Example usage for com.itextpdf.text.pdf PdfPCell setPadding

List of usage examples for com.itextpdf.text.pdf PdfPCell setPadding

Introduction

In this page you can find the example usage for com.itextpdf.text.pdf PdfPCell setPadding.

Prototype

public void setPadding(float padding) 

Source Link

Document

Sets the padding of the contents in the cell (space between content and border).

Usage

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

private void insertCell(PdfPTable table, String text, Integer colSpan) {

     if (text == null) {
         text = "";
     }/*from w  w  w .  jav  a 2 s  .c  o m*/

     // create a new cell with the specified Text and Font
     PdfPCell cell = new PdfPCell(new Phrase(text.trim(), FONT_PARAGRAPH));
     // set the cell alignment
     // in case there is no text and you wan to create an empty row
     if (text.trim().equalsIgnoreCase("")) {
         cell.setMinimumHeight(10f);
     }

     cell.setHorizontalAlignment(Element.ALIGN_LEFT);
     cell.setColspan(colSpan);
     cell.setPadding(5f);

     // add the call to the table
     table.addCell(cell);
 }

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

private void insertCellAlteracao(PdfPTable table, String text) {

     if (text == null) {
         text = "";
     }//  ww w. j  a  v a2s  .  c  o  m

     // create a new cell with the specified Text and Font
     PdfPCell cell = new PdfPCell(new Phrase(text.trim(), FONT_HEADER));
     // set the cell alignment
     // in case there is no text and you wan to create an empty row
     if (text.trim().equalsIgnoreCase("")) {
         cell.setMinimumHeight(10f);
     }

     cell.setHorizontalAlignment(Element.ALIGN_CENTER);
     cell.setColspan(2);
     cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
     cell.setBorderWidth(2);
     cell.setPadding(3f);

     // add the call to the table
     table.addCell(cell);
 }

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

private void insertHeaderCell(PdfPTable table, String text, Integer colSpan) {

     if (text == null) {
         text = "";
     }/*from   ww w  . ja va  2s .  c o m*/

     // create a new cell with the specified Text and Font
     PdfPCell cell = new PdfPCell(new Phrase(text.trim(), FONT_HEADER));
     // set the cell alignment
     // in case there is no text and you wan to create an empty row
     if (text.trim().equalsIgnoreCase("")) {
         cell.setMinimumHeight(10f);
     }

     cell.setVerticalAlignment(Element.ALIGN_CENTER);
     cell.setHorizontalAlignment(Element.ALIGN_CENTER);
     cell.setColspan(colSpan);
     cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
     cell.setBorderWidth(2);
     cell.setPadding(3f);

     // add the call to the table
     table.addCell(cell);
 }

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

private void insertCell(PdfPTable table, String text, Integer colSpan) {

    if (text == null) {
        text = "";
    }/*from  ww  w . j a v  a  2  s.c  o m*/

    // create a new cell with the specified Text and Font
    PdfPCell cell = new PdfPCell(new Phrase(text.trim(), FONT_PARAGRAPH));
    // set the cell alignment
    // in case there is no text and you wan to create an empty row
    if (text.trim().equalsIgnoreCase("")) {
        cell.setMinimumHeight(10f);
    }

    cell.setHorizontalAlignment(Element.ALIGN_LEFT);
    cell.setColspan(colSpan);
    cell.setPadding(5f);

    // add the call to the table
    table.addCell(cell);
}

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

private void insertCellProtocol(PdfPTable table, LicensePFEntity license) {

    PdfPTable tableProtocol = new PdfPTable(1);
    tableProtocol.setWidthPercentage(100f);

    Paragraph officialPhrase = new Paragraph("USO OFICIAL" + SEPARATOR, FONT_PARAGRAPH);
    officialPhrase.setAlignment(Element.ALIGN_LEFT);

    Paragraph protocolPhrase = new Paragraph("ETIQUETA PROTOCOLO" + SEPARATOR_DOUBLE + SEPARATOR_DOUBLE
            + SEPARATOR_DOUBLE + SEPARATOR_DOUBLE + SEPARATOR_DOUBLE + SEPARATOR, FONT_PROTOCOL);
    protocolPhrase.setAlignment(Element.ALIGN_LEFT);

    Paragraph obsPhrase = new Paragraph("Observao Importante!" + SEPARATOR, FONT_HEADER);

    Paragraph obsStringPhrase = new Paragraph(
            "Protocolar este Anexo somente quando no conjugado com a alterao efetiva ou a renovao da licena.",
            FONT_PARAGRAPH);//w  w w.java  2 s.c o  m

    Paragraph fullPhrase = new Paragraph();
    fullPhrase.add(officialPhrase);
    fullPhrase.add(protocolPhrase);
    fullPhrase.add(obsPhrase);
    fullPhrase.add(obsStringPhrase);

    PdfPCell cell = new PdfPCell(fullPhrase);

    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setPadding(5f);

    tableProtocol.addCell(cell);

    PdfPCell cellProtocol = new PdfPCell(tableProtocol);
    cellProtocol.setColspan(2);

    table.addCell(cellProtocol);
    table.addCell(this.createCellEtiqueta(license));
}

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

private void insertHeaderCell(PdfPTable table, String text, Integer colSpan) {

    if (text == null) {
        text = "";
    }/*  w w w. ja  v a  2 s .co  m*/

    // create a new cell with the specified Text and Font
    PdfPCell cell = new PdfPCell(new Phrase(text.trim(), FONT_HEADER));
    // set the cell alignment
    // in case there is no text and you wan to create an empty row
    if (text.trim().equalsIgnoreCase("")) {
        cell.setMinimumHeight(10f);
    }

    cell.setVerticalAlignment(Element.ALIGN_CENTER);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setColspan(colSpan);
    cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
    cell.setBorderWidth(2);
    cell.setPadding(3f);

    // add the call to the table
    table.addCell(cell);
}

From source file:com.systemevent.jsfclass.util.PdfEvento.java

public PdfPTable Tabla_compleja() {
    //creamos una tabla con 3 columnas
    PdfPTable mitablacompleja = new PdfPTable(3);
    //aadimos texto con formato a la primera celda
    PdfPCell celda = new PdfPCell(new Paragraph("Historial de Observaciones", FontFactory.getFont("arial", // fuente
            22, // tamao
            Font.BOLD, // estilo
            BaseColor.RED))); // color
    //unimos esta celda con otras 2
    celda.setColspan(3);/*w w  w .jav  a2  s. c o m*/
    //alineamos el contenido al centro
    celda.setHorizontalAlignment(Element.ALIGN_CENTER);
    // aadimos un espaciado
    celda.setPadding(12.0f);
    //colocamos un color de fondo
    celda.setBackgroundColor(BaseColor.GRAY);
    //se aade a la tabla
    mitablacompleja.addCell(celda);

    //fila 2
    celda = new PdfPCell(new Paragraph("AUDITORIA DE SISTEMAS"));
    celda.setColspan(2);
    celda.setBackgroundColor(BaseColor.GREEN);
    mitablacompleja.addCell(celda);
    celda = new PdfPCell(new Paragraph("Aprobado"));
    celda.setBackgroundColor(BaseColor.LIGHT_GRAY);
    mitablacompleja.addCell(celda);
    //fila 3        
    celda = new PdfPCell(new Paragraph("COMPILADORES"));
    celda.setColspan(2);
    celda.setBackgroundColor(BaseColor.YELLOW);
    mitablacompleja.addCell(celda);
    celda = new PdfPCell(new Paragraph("Reprobado"));
    celda.setBackgroundColor(BaseColor.LIGHT_GRAY);
    mitablacompleja.addCell(celda);
    //fila 4        
    celda = new PdfPCell(new Paragraph("Prog. Bajo Nivel"));
    celda.setColspan(2);
    celda.setBackgroundColor(BaseColor.CYAN);
    mitablacompleja.addCell(celda);
    celda = new PdfPCell(new Paragraph("Eximido"));
    celda.setBackgroundColor(BaseColor.LIGHT_GRAY);
    mitablacompleja.addCell(celda);
    //fila 5
    mitablacompleja.addCell("Conclusion");
    celda = new PdfPCell(new Paragraph("GET A LIFE!!!"));
    celda.setHorizontalAlignment(Element.ALIGN_RIGHT);
    celda.setColspan(2);
    celda.setBackgroundColor(BaseColor.ORANGE);
    mitablacompleja.addCell(celda);
    // se retorna la tabla

    return mitablacompleja;
}

From source file:com.timesheet.export.PdfGenerator.java

@Override
protected void buildPdfDocument(Map<String, Object> model, Document document, PdfWriter writer,
        HttpServletRequest request, HttpServletResponse response) throws Exception {

    /* Add header*/
    Font fontHeader = FontFactory.getFont(FontFactory.TIMES_ROMAN, 22, Font.BOLD);
    Paragraph headerPara = new Paragraph("Time sheet report", fontHeader);
    headerPara.setSpacingAfter(20f);/*from w w  w.ja  v  a2 s  .  c  om*/
    document.add(headerPara);

    /*Add user info*/
    User userProfile = (User) model.get("userprofile");
    Font fontUserInfo = FontFactory.getFont(FontFactory.TIMES_ROMAN, 16, Font.BOLD);
    document.add(new Paragraph("Name : " + userProfile.getName(), fontUserInfo));
    document.add(new Paragraph("User no. : " + userProfile.getUserIdentifier(), fontUserInfo));
    document.add(new Paragraph("Department : " + userProfile.getDepartment(), fontUserInfo));
    document.add(new Paragraph("Email : " + userProfile.getEmail(), fontUserInfo));
    Paragraph spacing = new Paragraph("");
    spacing.setSpacingAfter(20f);
    document.add(spacing);

    PdfPTable table = new PdfPTable(5);
    table.setWidthPercentage(100.0f);
    table.setWidths(new float[] { 5.0f, 3.0f, 3.0f, 3.0f, 10.0f });
    table.setSpacingBefore(10);

    // define font for table header row
    Font font = FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.BOLD);
    //font.setColor(BaseColor.WHITE);

    // define table header cell
    PdfPCell cell = new PdfPCell();
    //cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
    cell.setPadding(5);
    cell.setBorderWidth(2.0f);
    cell.setBorder(Rectangle.BOTTOM);
    // get data model which is passed by the Spring container
    List<Booking> bookings = (List<Booking>) model.get("bookings");

    // write table header
    cell.setPhrase(new Phrase("Project", font));
    table.addCell(cell);
    // write table header
    cell.setPhrase(new Phrase("Option", font));
    table.addCell(cell);
    // write table header
    cell.setPhrase(new Phrase("Date", font));
    table.addCell(cell);
    // write table header
    cell.setPhrase(new Phrase("Duration", font));
    table.addCell(cell);
    // write table header
    cell.setPhrase(new Phrase("Description", font));
    table.addCell(cell);

    int sum = 0;

    Font fontData = FontFactory.getFont(FontFactory.TIMES_ROMAN, 11);

    for (Booking booking : bookings) {
        PdfPCell cell1 = new PdfPCell(new Phrase(
                booking.getProject().getProjectId() + "-" + booking.getProject().getName(), fontData));
        cell1.setBorder(Rectangle.BOTTOM);
        cell1.setPadding(5);
        table.addCell(cell1);
        PdfPCell cell2 = new PdfPCell(new Phrase(booking.getBookingOption().getOptionLabel(), fontData));
        cell2.setBorder(Rectangle.BOTTOM);
        cell2.setPadding(5);
        table.addCell(cell2);
        PdfPCell cell3 = new PdfPCell(new Phrase(formatDate(booking.getBookingDate()), fontData));
        cell3.setBorder(Rectangle.BOTTOM);
        cell3.setPadding(5);
        table.addCell(cell3);
        int hh = booking.getDuration() / 60;
        int mm = booking.getDuration() % 60;
        PdfPCell cell4 = new PdfPCell(new Phrase(hh + ":" + mm, fontData));
        cell4.setBorder(Rectangle.BOTTOM);
        cell4.setPadding(5);
        table.addCell(cell4);
        PdfPCell cell5 = new PdfPCell(
                new Phrase(StringEscapeUtils.escapeHtml(booking.getDescription()), fontData));
        cell5.setBorder(Rectangle.BOTTOM);
        cell5.setPadding(5);
        table.addCell(cell5);

        sum += booking.getDuration();
    }

    document.add(table);

    int sumHH = sum / 60;
    int sumMM = sum % 60;

    document.add(new Paragraph("Sum : " + sumHH + ":" + sumMM, fontUserInfo));
    //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}

From source file:cz.zcu.kiv.eegdatabase.logic.pdf.ReservationPDF.java

License:Apache License

public static PdfPTable formatReservation(Reservation reservation) {
    int padding = 5;

    GregorianCalendar created = new GregorianCalendar();
    created.setTime(reservation.getCreationTime());
    GregorianCalendar startTime = new GregorianCalendar();
    startTime.setTime(reservation.getStartTime());
    GregorianCalendar endTime = new GregorianCalendar();
    endTime.setTime(reservation.getEndTime());

    String personName = BookingRoomUtils.formatPersonName(reservation.getPerson());

    Font title = FontFactory.getFont("Trebuchet MS", "utf-8", 15, Font.BOLD, new BaseColor(59, 70, 00));
    Font header = FontFactory.getFont(FontFactory.TIMES_BOLD, 13, Font.BOLD, BaseColor.BLACK);
    Font value = FontFactory.getFont(FontFactory.TIMES, 13);

    PdfPTable table = new PdfPTable(2);
    PdfPCell cell;
    Phrase phrase;/* ww w  .j  a  va 2  s . co  m*/

    phrase = new Phrase("Reservation by " + personName);
    phrase.setFont(title);
    cell = new PdfPCell(phrase);
    cell.setColspan(2);
    cell.setBorder(0);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setBorderWidthTop(1);
    cell.setBorderWidthLeft(1);
    cell.setBorderWidthRight(1);
    cell.setPadding(padding);
    cell.setPaddingBottom(5);
    table.addCell(cell);

    phrase = new Phrase("Date: ");
    phrase.setFont(header);
    cell = new PdfPCell(phrase);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setBorder(0);
    cell.setBorderWidthLeft(1);
    cell.setPadding(padding);
    table.addCell(cell);

    phrase = new Phrase(BookingRoomUtils.getDate(startTime));
    phrase.setFont(value);
    cell = new PdfPCell(phrase);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setBorder(0);
    cell.setBorderWidthRight(1);
    cell.setPadding(padding);
    table.addCell(cell);

    phrase = new Phrase("Start: ");
    phrase.setFont(header);
    cell = new PdfPCell(phrase);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setBorder(0);
    cell.setBorderWidthLeft(1);
    cell.setPadding(padding);
    table.addCell(cell);

    phrase = new Phrase(BookingRoomUtils.getHoursAndMinutes(startTime));
    phrase.setFont(value);
    cell = new PdfPCell(phrase);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setBorder(0);
    cell.setBorderWidthRight(1);
    cell.setPadding(padding);
    table.addCell(cell);

    phrase = new Phrase("End: ");
    phrase.setFont(header);
    cell = new PdfPCell(phrase);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setBorder(0);
    cell.setBorderWidthLeft(1);
    cell.setBorderWidthBottom(1);
    cell.setPadding(padding);
    table.addCell(cell);

    phrase = new Phrase(BookingRoomUtils.getHoursAndMinutes(endTime));
    phrase.setFont(value);
    cell = new PdfPCell(phrase);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setBorder(0);
    cell.setBorderWidthRight(1);
    cell.setBorderWidthBottom(1);
    cell.setPadding(padding);
    table.addCell(cell);

    table.setSpacingBefore(10);
    table.setSpacingAfter(10);

    return table;
}

From source file:dbms_prj.Display.java

public void create_pdf() throws Exception {
    Document doc = new Document();
    PdfWriter.getInstance(doc, new FileOutputStream(S1 + ".pdf"));
    Image image = Image.getInstance("src/Travel partners.png");
    image.scaleAbsolute(500f, 200f);// ww  w.j ava  2 s  . c o m
    Image ima = Image.getInstance("src/images.jpg");
    ima.scaleAbsolute(100f, 100f);
    ima.setAlignment(Element.ALIGN_CENTER);
    PdfPTable table = new PdfPTable(9);
    PdfPCell cell = new PdfPCell(new Paragraph("Ticket"));
    cell.setColspan(9);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setPadding(10.0f);
    cell.setBackgroundColor(new BaseColor(140, 221, 8));
    table.addCell(cell);
    table.addCell("PNR");
    table.addCell("BOOK_ID");
    table.addCell("FLIGHT_NO");
    table.addCell("NAME");
    table.addCell("SOURCE");
    table.addCell("DESTINATION");
    table.addCell("STATUS");
    table.addCell("FARE");
    table.addCell("Date");
    table.addCell(S1);
    table.addCell(S11);
    table.addCell(S4);
    table.addCell(S6 + " " + S7);
    table.addCell(S8);
    table.addCell(S9);
    table.addCell(S5);
    table.addCell(S10);
    table.addCell(S12);
    table.setSpacingBefore(30.0f); // Space Before table starts, like margin-top in CSS
    table.setSpacingAfter(30.0f);
    doc.open();
    //doc.add(new Paragraph("Hello!! Yo this is my first pdf!"));
    doc.add(image);
    doc.add(new Paragraph("Ticket created on " + new Date().toString()));
    doc.add(table);
    //doc.add(list);
    doc.add(ima);
    doc.close();
}