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:org.openlmis.web.view.pdf.requisition.RequisitionCellFactory.java

License:Open Source License

public static PdfPCell headingCell(String value) {
    Chunk chunk = new Chunk(value, H2_FONT);
    PdfPCell cell = new PdfPCell(new Phrase(chunk));
    cell.setPadding(CELL_PADDING);
    cell.setHorizontalAlignment(Element.ALIGN_LEFT);
    return cell;//from ww w .  j  a v a2 s  . c  om
}

From source file:org.openlmis.web.view.pdf.requisition.RequisitionCellFactory.java

License:Open Source License

public static PdfPCell imageCell() throws BadElementException, IOException {
    Resource resource = new ClassPathResource(OK_IMAGE);
    Image image = Image.getInstance(resource.getFile().getAbsolutePath());
    PdfPCell cell = new PdfPCell(image);
    cell.setPadding(CELL_PADDING);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    return cell;//from  www .ja  v  a  2s .c om
}

From source file:org.openlmis.web.view.pdf.requisition.RequisitionCellFactory.java

License:Open Source License

public static PdfPCell categoryRow(Integer visibleColumnsSize, LineItem lineItem) {
    Chunk chunk = new Chunk(lineItem.getCategoryName(), FontFactory.getFont(FontFactory.HELVETICA_BOLD));
    PdfPCell cell = new PdfPCell(new Phrase(chunk));
    cell.setColspan(visibleColumnsSize);
    cell.setBackgroundColor(HEADER_BACKGROUND);
    cell.setPadding(CELL_PADDING);
    return cell;//  ww  w.j a v a2s.  co  m
}

From source file:org.openlmis.web.view.pdf.requisition.RequisitionPdfModel.java

License:Open Source License

private void addHeading(PdfPTable table) throws DocumentException {
    Chunk chunk = new Chunk(String.format(messageService.message("label.requisition") + ": %s (%s)",
            this.requisition.getProgram().getName(),
            this.requisition.getFacility().getFacilityType().getName()), H1_FONT);

    PdfPCell cell = new PdfPCell(new Phrase(chunk));
    cell.setColspan(5);/*  w w  w .j a v a  2s.com*/
    cell.setPadding(10);
    cell.setBorder(0);
    table.addCell(cell);
}

From source file:org.openlmis.web.view.pdf.requisition.RequisitionPdfModel.java

License:Open Source License

public PdfPTable getSummary() throws DocumentException {
    this.requisition.fillFullSupplyCost();
    this.requisition.fillNonFullSupplyCost();

    DecimalFormat formatter = new DecimalFormat("#,##0.00");

    PdfPTable summaryTable = new PdfPTable(2);
    summaryTable.setWidths(new int[] { 30, 20 });
    summaryTable.setSpacingBefore(TABLE_SPACING);
    summaryTable.setWidthPercentage(40);
    summaryTable.setHorizontalAlignment(0);

    PdfPCell summaryHeaderCell = headingCell(messageService.message("label.summary"));
    summaryHeaderCell.setColspan(2);// w  w w  .  j  a  va2s.c  om
    summaryHeaderCell.setPadding(10);
    summaryHeaderCell.setBorder(0);
    summaryTable.addCell(summaryHeaderCell);

    boolean showBudget = !requisition.isEmergency() && requisition.getProgram().getBudgetingApplies();
    if (showBudget) {
        summaryTable.addCell(summaryCell(textCell(messageService.message("label.allocated.budget"))));
        PdfPCell allocatedBudgetCell = requisition.getAllocatedBudget() != null
                ? numberCell(messageService.message(LABEL_CURRENCY_SYMBOL)
                        + formatter.format(new Money(requisition.getAllocatedBudget()).toDecimal()))
                : numberCell(messageService.message("msg.budget.not.allocated"));
        summaryTable.addCell(summaryCell(allocatedBudgetCell));
    }
    summaryTable.addCell(summaryCell(textCell(messageService.message("label.total.cost.full.supply.items"))));
    summaryTable.addCell(summaryCell(numberCell(messageService.message(LABEL_CURRENCY_SYMBOL)
            + formatter.format(requisition.getFullSupplyItemsSubmittedCost().toDecimal()))));
    summaryTable
            .addCell(summaryCell(textCell(messageService.message("label.total.cost.non.full.supply.items"))));
    summaryTable.addCell(summaryCell(numberCell(messageService.message(LABEL_CURRENCY_SYMBOL)
            + formatter.format(requisition.getNonFullSupplyItemsSubmittedCost().toDecimal()))));
    summaryTable.addCell(summaryCell(textCell(messageService.message("label.total.cost"))));
    summaryTable.addCell(summaryCell(numberCell(messageService.message(LABEL_CURRENCY_SYMBOL)
            + formatter.format(this.getTotalCost(requisition).toDecimal()).toString())));
    if (showBudget && requisition.getAllocatedBudget() != null
            && (requisition.getAllocatedBudget().compareTo(this.getTotalCost(requisition).getValue()) == -1)) {
        summaryTable.addCell(summaryCell(textCell(messageService.message("msg.cost.exceeds.budget"))));
        summaryTable.addCell(summaryCell(textCell(" ")));
    }

    summaryTable.addCell(summaryCell(textCell(" ")));
    summaryTable.addCell(summaryCell(textCell(" ")));
    summaryTable.addCell(summaryCell(textCell(" ")));
    summaryTable.addCell(summaryCell(textCell(" ")));

    fillAuditFields(summaryTable);
    return summaryTable;
}

From source file:org.openlmis.web.view.pdf.requisition.RequisitionPdfModel.java

License:Open Source License

private PdfPCell summaryCell(PdfPCell cell) {
    cell.setPadding(15);
    cell.setBorder(0);
    return cell;
}

From source file:org.oscarehr.fax.util.PdfCoverPageCreator.java

License:Open Source License

public byte[] createCoverPage() {

    Document document = new Document();
    ByteArrayOutputStream os = new ByteArrayOutputStream();

    try {/*from w  ww.ja va 2s .c  om*/

        PdfWriter pdfWriter = PdfWriter.getInstance(document, os);
        document.open();

        PdfPTable table = new PdfPTable(1);
        table.setWidthPercentage(95);

        PdfPCell cell = new PdfPCell(table);
        cell.setBorder(0);
        cell.setPadding(3);
        cell.setColspan(1);
        table.addCell(cell);

        ClinicDAO clinicDao = SpringUtils.getBean(ClinicDAO.class);
        Clinic clinic = clinicDao.getClinic();
        BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
        Font headerFont = new Font(bf, 28, Font.BOLD);
        Font infoFont = new Font(bf, 12, Font.NORMAL);

        if (clinic != null) {

            cell = new PdfPCell(new Phrase(
                    String.format("%s\n %s, %s, %s %s", clinic.getClinicName(), clinic.getClinicAddress(),
                            clinic.getClinicCity(), clinic.getClinicProvince(), clinic.getClinicPostal()),
                    headerFont));
        } else {

            cell = new PdfPCell(new Phrase("OSCAR", headerFont));

        }

        cell.setPaddingTop(100);
        cell.setPaddingLeft(25);
        cell.setPaddingBottom(25);
        cell.setBorderWidthBottom(1);
        table.addCell(cell);

        PdfPTable infoTable = new PdfPTable(1);
        cell = new PdfPCell(new Phrase(note, infoFont));
        cell.setPaddingTop(25);
        cell.setPaddingLeft(25);
        infoTable.addCell(cell);
        table.addCell(infoTable);

        document.add(table);

    } catch (DocumentException e) {

        MiscUtils.getLogger().error("PDF COVER PAGE ERROR", e);
        return new byte[] {};

    } catch (IOException e) {

        MiscUtils.getLogger().error("PDF COVER PAGE ERROR", e);
        return new byte[] {};

    } finally {
        document.close();
    }

    return os.toByteArray();
}

From source file:org.patientview.radar.service.impl.PdfDocumentDataBuilder.java

License:Open Source License

private PdfPCell createBaseCell(String text, Font font) {
    PdfPCell cell = new PdfPCell(new Phrase(text, font));
    cell.setHorizontalAlignment(Element.ALIGN_LEFT);
    cell.setPadding(4f);
    return cell;/*from   w  ww.j a  v  a2 s.  c  o  m*/
}

From source file:org.qnot.passtab.PDFOutput.java

License:Open Source License

private void addCell(PdfPTable table, String str, boolean bold, boolean fill, boolean rightBorder,
        boolean bottomBorder) {
    Phrase phrase = withColor ? new Phrase(str, bold ? fontBold : font) : new Phrase(str, font);

    PdfPCell cell = new PdfPCell(phrase);

    cell.setBorder(Rectangle.NO_BORDER);
    cell.setPadding(0f);
    cell.setPaddingTop(2f);//  ww w  . j  a  v  a2 s .  c  om

    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);

    if (rightBorder) {
        cell.setBorderWidthRight(1f);
        cell.setPaddingRight(3f);
        cell.setHorizontalAlignment(Element.ALIGN_LEFT);
    }
    if (bottomBorder) {
        cell.setBorderWidthBottom(1f);
        cell.setPaddingBottom(3f);
    }

    if (fill && this.withColor) {
        cell.setGrayFill(0.80f);
    }

    table.addCell(cell);
}

From source file:org.sakaiproject.attendance.export.PDFEventExporterImpl.java

License:Educational Community License

private PdfPTable signInSheetTable() {

    PdfPTable table = new PdfPTable(2);
    table.setWidthPercentage(100);/*www  .  j  av  a2s.  c  o m*/
    table.setSpacingBefore(12);

    PdfPCell nameHeader = new PdfPCell(new Paragraph("Student Name", tableHeader));
    nameHeader.setPadding(10);

    PdfPCell signatureHeader = new PdfPCell(new Paragraph("Signature", tableHeader));
    signatureHeader.setPadding(10);

    table.addCell(nameHeader);
    table.addCell(signatureHeader);

    Collections.sort(users, new SortNameUserComparator());

    for (User user : users) {

        PdfPCell userCell = new PdfPCell(new Paragraph(user.getSortName(), body));
        userCell.setPadding(10);

        PdfPCell blankCell = new PdfPCell(new Paragraph());
        blankCell.setPadding(10);

        table.addCell(userCell);
        table.addCell(blankCell);
    }

    return table;

}