Example usage for com.itextpdf.text Rectangle NO_BORDER

List of usage examples for com.itextpdf.text Rectangle NO_BORDER

Introduction

In this page you can find the example usage for com.itextpdf.text Rectangle NO_BORDER.

Prototype

int NO_BORDER

To view the source code for com.itextpdf.text Rectangle NO_BORDER.

Click Source Link

Document

This represents a rectangle without borders.

Usage

From source file:fxml.test.PDFService.java

public PdfPCell getCellForString(String args, int colSpan, boolean border, int vertical, int horizontal,
        Font font, boolean wrap) {

    PdfPCell cell = new PdfPCell(new Paragraph(args, font));
    if (colSpan != 0) {
        cell.setColspan(colSpan);/* ww  w  .j  a va  2s. c o m*/
    }
    cell.setVerticalAlignment(vertical);
    cell.setHorizontalAlignment(horizontal);
    if (!border) {
        cell.setBorder(Rectangle.NO_BORDER);
    }
    if (wrap) {
        cell.setNoWrap(true);
    }
    return cell;
}

From source file:fxml.test.PDFService.java

public PdfPCell getCellForHeaderString(String args, int colSpan, boolean flag, int vertical, int horizontal,
        Font font, boolean wrap) {

    PdfPCell cell = new PdfPCell(new Paragraph(args, font));
    if (colSpan != 0) {
        cell.setColspan(colSpan);//from  ww  w  .j a  v a  2  s  .c o m
    }
    cell.setVerticalAlignment(vertical);
    cell.setHorizontalAlignment(horizontal);
    cell.setPaddingTop(0.8f);
    if (!flag) {
        cell.setBorder(Rectangle.NO_BORDER);
    }

    if (wrap) {
        cell.setNoWrap(true);
    }
    return cell;

}

From source file:fxml.test.PDFService.java

private PdfPCell getNameCell() {

    PdfPTable nameTable = new PdfPTable(2);

    PdfPCell nameCell = new PdfPCell(new Paragraph("Name", font9));
    nameCell.setBorder(Rectangle.NO_BORDER);
    nameCell.setVerticalAlignment(Element.ALIGN_MIDDLE);

    PdfPTable semesterInfo = new PdfPTable(1);
    semesterInfo.addCell(nameCellHelper("Semester="));
    semesterInfo.addCell(nameCellHelper("Course No="));
    semesterInfo.addCell(nameCellHelper("Credit="));

    PdfPCell semesterCell = new PdfPCell(semesterInfo);
    semesterCell.setBorder(Rectangle.NO_BORDER);

    nameTable.addCell(nameCell);/* www.  java2s  . c o  m*/
    nameTable.addCell(semesterCell);

    PdfPCell cell = new PdfPCell(nameTable);

    return cell;
}

From source file:fxml.test.PDFService.java

private PdfPCell nameCellHelper(String args) {

    PdfPCell cell = new PdfPCell(new Paragraph(args, font9));
    cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
    cell.setBorder(Rectangle.NO_BORDER);
    cell.setPaddingBottom(2.5f);//from   w  w  w  . j  av a  2 s.c  o m
    return cell;

}

From source file:fxml.test.PDFService.java

public PdfPTable createTableHeader(int start) {

    PdfPTable table = null;/*from w w  w  .j ava 2  s . c  om*/

    try {

        int colCount = 1;
        List<Float> columnsList = new ArrayList<>();

        columnsList.add(57.5f);
        columnsList.add(159.4f);

        for (int i = start; i < list.size(); i++) {

            if (list.get(i) instanceof Course) {

                columnsList.add(44f);

            } else if (list.get(i).equals("Total Credit")) {

                columnsList.add(30f);

            } else if (list.get(i).equals("Total GPA")) {

                columnsList.add(30f);

            } else if (list.get(i).equals("Letter Grade")) {

                columnsList.add(30f);

            } else if (list.get(i).equals("Cumulative")) {

                columnsList.add(88f);

            } else {

                columnsList.add(66f);

            }

            if (colCount == 12) {
                break;
            }
            colCount++;

        }

        float[] columns = new float[columnsList.size()];

        for (int i = 0; i < columnsList.size(); i++) {
            columns[i] = columnsList.get(i);
        }

        table = new PdfPTable(columns.length);

        System.err.println("table size :" + table.getNumberOfColumns());

        table.setHorizontalAlignment(Element.ALIGN_LEFT);
        table.setTotalWidth(columns);
        table.setLockedWidth(true);

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

    PdfPCell regCell = getCellForString("Reg No.", 0, true, Element.ALIGN_MIDDLE, Element.ALIGN_CENTER, font9,
            false);
    regCell.setPaddingTop(0f);
    table.addCell(regCell);

    PdfPCell nameCell = getNameCell();
    nameCell.setPaddingBottom(2f);
    table.addCell(nameCell);

    int colCount = 1;

    for (int i = start; i < list.size(); i++) {

        if (list.get(i) instanceof Course) {

            Course course = (Course) list.get(i);

            PdfPCell cell3 = new PdfPCell(createCourseInfo(course));
            cell3.setPaddingTop(1f);
            cell3.setPaddingBottom(2f);
            //cell3.setVerticalAlignment(Element.ALIGN_MIDDLE);
            table.addCell(cell3);

        } else if (list.get(i).equals("Total Credit") || list.get(i).equals("Total GPA")
                || list.get(i).equals("Letter Grade")) {

            String str = (String) list.get(i);
            String s[] = str.split(" ");

            PdfPTable totalCredit = new PdfPTable(1);
            totalCredit.setSpacingBefore(12.5f);
            totalCredit.setWidthPercentage(100);
            totalCredit.getDefaultCell().setBorder(Rectangle.NO_BORDER);

            PdfPCell cell1 = getCellForString(s[0], 0, false, 0, Element.ALIGN_CENTER,
                    new Font(Font.FontFamily.TIMES_ROMAN, 10f), false);
            PdfPCell cell2 = getCellForString(s[1], 0, false, 0, Element.ALIGN_CENTER,
                    new Font(Font.FontFamily.TIMES_ROMAN, 10f), false);

            totalCredit.addCell(cell1);
            totalCredit.addCell(cell2);

            PdfPCell grade = new PdfPCell(totalCredit);
            table.addCell(grade);

        } else if (list.get(i).equals("Cumulative")) {

            PdfPTable cumulative = new PdfPTable(1);
            // cumulative.setPaddingTop(count);
            cumulative.addCell(getCellForString("Cumulative", 0, false, Element.ALIGN_MIDDLE,
                    Element.ALIGN_CENTER, font10, true));

            PdfPTable creditGpaGrade = new PdfPTable(3);

            creditGpaGrade.setTotalWidth(88f);
            creditGpaGrade.setLockedWidth(true);
            creditGpaGrade.addCell(getCellForString("Credit", 0, false, Element.ALIGN_MIDDLE,
                    Element.ALIGN_CENTER, font10, true));
            creditGpaGrade.addCell(getCellForString("GPA", 0, false, Element.ALIGN_MIDDLE, Element.ALIGN_CENTER,
                    font10, true));
            creditGpaGrade.addCell(getCellForString("Grade", 0, false, Element.ALIGN_MIDDLE,
                    Element.ALIGN_CENTER, font10, true));

            PdfPTable p = new PdfPTable(1);
            PdfPCell cell1 = new PdfPCell(cumulative);
            cell1.setPaddingBottom(3f);
            cell1.setBorder(Rectangle.NO_BORDER);
            PdfPCell cell2 = new PdfPCell(creditGpaGrade);
            cell2.setBorder(Rectangle.NO_BORDER);
            p.addCell(cell1);
            p.addCell(cell2);
            table.addCell(p);

        } else {

            table.addCell(getCellForString((String) list.get(i), 0, true, Element.ALIGN_MIDDLE,
                    Element.ALIGN_CENTER, font9, true));

        }

        if (colCount == 12) {
            break;
        }
        colCount++;
    }

    return table;

}

From source file:generators.InvoiceEventListener.java

@Override
public void onEndPage(PdfWriter writer, Document document) {

    Font defaultFont = new Font(Font.FontFamily.TIMES_ROMAN, 12);

    try {//from   w  w w  . j  a v  a2 s.  c  om
        PdfPTable footerTable = new PdfPTable(3);
        footerTable.setTotalWidth(document.right(document.leftMargin()));

        footerTable.getDefaultCell().setBorder(Rectangle.TOP);
        footerTable.addCell(new Paragraph("Lionsclub Oegstgeest/Warmond", defaultFont));
        footerTable.completeRow();

        footerTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);
        footerTable.addCell(new Paragraph("Betaalrekening", defaultFont));
        footerTable.addCell(new Paragraph(": ************", defaultFont));
        footerTable.completeRow();
        footerTable.addCell(new Paragraph("Inschrijvnummer KvK Rijnland", defaultFont));
        footerTable.addCell(new Paragraph(": ************ ", defaultFont));
        footerTable.completeRow();
        footerTable.writeSelectedRows(0, -1, document.leftMargin(),
                document.bottom(footerTable.getTotalHeight()) - document.bottomMargin() + 15,
                writer.getDirectContent());

        ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_RIGHT,
                new Phrase(String.format("%d", writer.getPageNumber()), defaultFont), document.right(),
                document.bottom() - document.bottomMargin() + 18, 0);
    } catch (Exception e) {
        e.printStackTrace();
    }

}

From source file:generators.InvoiceGenerator.java

/**
 * Generate Invoice pdf file/*from ww  w  . java  2s.  c o  m*/
 *
 * @param order the order
 * @throws DocumentException the document exception
 * @throws IOException       the io exception
 */
public void generate(Order order) throws DocumentException, IOException {
    Date invoiceDate = order.getDate();
    SimpleDateFormat sdf = new SimpleDateFormat("dd MMMM YYYY");
    //        User guest = order.getGuest();
    User guest = new UserDAO().get(order.getUserId());
    guest.setOrder(order);
    System.out.println("invoice generator orderID: " + order.getId());
    Document document = new Document();
    Font defaultFont = new Font(Font.FontFamily.TIMES_ROMAN, 12);
    System.out.println(System.getProperty("user.dir"));
    PdfWriter writer = PdfWriter.getInstance(document,
            new FileOutputStream(System.getProperty("user.dir") + "/src/main/java/nl/ipsen3/invoice/"
                    + new SimpleDateFormat("dd-MM-yyyy").format(invoiceDate) + " - " + order.getId() + ".pdf"));
    document.setMargins(30, 30, 30, 65);
    writer.setPageEvent(new InvoiceEventListener());
    document.open();
    Paragraph header = new Paragraph("Lionsclub Oegstgeest/Warmond",
            new Font(Font.FontFamily.TIMES_ROMAN, 14, Font.BOLD));
    header.setAlignment(Element.ALIGN_CENTER);
    document.add(header);
    AddressDAO addressDAO = new AddressDAO();
    Address userAddress = addressDAO.get(guest.getAddressId());
    Paragraph address = new Paragraph(guest.getFirstName() + " " + guest.getPrefixLastName() + " "
            + guest.getLastName() + "\n" + userAddress.getStreet() + " " + userAddress.getHouseNumber() + "\n"
            + userAddress.getZipCode() + " " + userAddress.getCity(), defaultFont);
    address.setSpacingBefore(35);
    address.setSpacingAfter(25);
    address.setLeading(15);
    document.add(address);

    Paragraph invoiceDetails = new Paragraph("Factuurdatum: " + sdf.format(invoiceDate) + "\n"
            + "FactuurNummer: " + order.getId() + " \n" + "Debiteurennummer: " + guest.getId(), defaultFont);

    invoiceDetails.setSpacingAfter(15);
    invoiceDetails.setLeading(15);
    document.add(invoiceDetails);

    Paragraph subject = new Paragraph("Betreft: Onderwerp factuur", defaultFont);
    subject.setSpacingAfter(30);
    document.add(subject);

    PdfPTable orderTable = new PdfPTable(10);
    PdfPCell wineCell = new PdfPCell(new Paragraph("Wijn", defaultFont));
    wineCell.setColspan(5);
    wineCell.setBorder(Rectangle.BOTTOM);
    orderTable.getDefaultCell().setPaddingBottom(10);
    orderTable.getDefaultCell().setBorder(Rectangle.BOTTOM);
    ;

    orderTable.addCell(new Paragraph("Code", defaultFont));
    orderTable.addCell(new Paragraph("Aantal", defaultFont));
    orderTable.addCell(wineCell);
    orderTable.addCell(new Paragraph("Jaar", defaultFont));
    orderTable.addCell(new Paragraph("Per Fles", defaultFont));
    orderTable.addCell(new Paragraph("Bedrag", defaultFont));

    orderTable.getDefaultCell().setPaddingBottom(0);
    orderTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);
    wineCell.setBorder(Rectangle.NO_BORDER);

    NumberFormat numberFormat = NumberFormat.getCurrencyInstance(Locale.GERMANY);

    for (WineOrder wineOrder : order.getWineOrders()) {
        orderTable.addCell(new Paragraph("" + wineOrder.getWine().getId(), defaultFont));
        orderTable.addCell(new Paragraph("" + wineOrder.getAmount(), defaultFont));
        wineCell.setPhrase(new Phrase(wineOrder.getWine().getName(), defaultFont));
        orderTable.addCell(wineCell);
        orderTable.addCell(new Paragraph("" + wineOrder.getWine().getYear(), defaultFont));
        orderTable.addCell(new Paragraph(
                " " + numberFormat.format(wineOrder.getWine().getPrice()).replace(" ", ""), defaultFont));
        orderTable.addCell(new Paragraph(" " + numberFormat
                .format(wineOrder.getAmount() * wineOrder.getWine().getPrice()).replace(" ", ""),
                defaultFont));

        orderTable.completeRow();
    }

    orderTable.addCell(" ");
    orderTable.completeRow();
    Font totalFont = new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD);
    PdfPCell totalAmount = new PdfPCell(
            new Paragraph(" " + numberFormat.format(order.getTotalAmount()).replace(" ", ""), totalFont));
    totalAmount.setBorder(Rectangle.TOP);
    totalAmount.setPaddingTop(10);
    PdfPCell totalCell = new PdfPCell(new Paragraph("Totaal", totalFont));
    totalCell.setPaddingTop(10);
    totalCell.setBorder(Rectangle.NO_BORDER);
    orderTable.addCell(totalCell);
    PdfPCell fillerCell = new PdfPCell(new Paragraph(""));
    fillerCell.setColspan(8);
    fillerCell.setBorder(Rectangle.NO_BORDER);
    orderTable.addCell(fillerCell);
    orderTable.addCell(totalAmount);

    orderTable.setSpacingBefore(15);
    orderTable.setSpacingAfter(30);
    orderTable.setWidthPercentage(95);
    orderTable.setHorizontalAlignment(Element.ALIGN_CENTER);
    document.add(orderTable);

    Paragraph retrievalDetails = new Paragraph(
            "Wij verzoeken u vriendelijk het totaalbedrag binnen 7 dagen na factuurdatum over te maken op bankrekening <bankAccountNr> t.n.v <bankAccountName> onder vermelding van het factuurnummer",
            defaultFont);
    retrievalDetails.setLeading(15);
    retrievalDetails.setSpacingAfter(20);
    document.add(retrievalDetails);

    //        document.add(new Paragraph("U kunt uw wijnen ophalen op " +  sdf.format(invoiceDate) , defaultFont));
    //        document.add(new Paragraph("Adres:", defaultFont));
    //
    //        PdfPTable addressTable = new PdfPTable(1);
    //        addressTable.setSpacingBefore(5);
    //        addressTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);
    //        addressTable.getDefaultCell().setPaddingLeft(35);
    //        MerchantService merchantService = new MerchantService();
    //        Merchant merchant = merchantService.find(merchantService.all().get(0).getId());
    //        addressTable.addCell(new Paragraph(merchant.getName(), defaultFont));
    //        addressTable.addCell(new Paragraph(merchant.getAddress().getStreet()
    //                + " " + merchant.getAddress().getHouseNumber(), defaultFont));
    //        addressTable.addCell(new Paragraph(merchant.getAddress().getZipCode() + " " +
    //                merchant.getAddress().getCity(), defaultFont));
    //        addressTable.setHorizontalAlignment(Element.ALIGN_LEFT);
    //        document.add(addressTable);

    document.close();
    System.out.println(
            "Succesfully generated IPSEN2.invoice: " + order.getId() + " on Date: " + sdf.format(invoiceDate));
}

From source file:gov.utah.dts.det.ccl.actions.reports.generators.ExpiredLicensesReport.java

private static PdfPTable getDetailTable() throws DocumentException {
    PdfPTable table = new PdfPTable(5);
    // format the table
    int headerwidths[] = { 41, 17, 8, 24, 10 }; // percentage
    table.setWidths(headerwidths); // percentage
    table.setWidthPercentage(100);/*from  ww w.j  a va2 s .  com*/
    table.getDefaultCell().setLeading(fixedLeading, 0);
    table.getDefaultCell().setPadding(0);
    table.getDefaultCell().setBorder(Rectangle.NO_BORDER);
    table.getDefaultCell().setVerticalAlignment(PdfPTable.ALIGN_BOTTOM);
    table.getDefaultCell().setHorizontalAlignment(PdfPTable.ALIGN_LEFT);

    return table;
}

From source file:gov.utah.dts.det.ccl.actions.reports.generators.ExpiredLicensesReport.java

private static PdfPTable getFacilityDetailsTable() throws DocumentException {
    PdfPTable table = new PdfPTable(3);
    // format the table
    int headerwidths[] = { 33, 33, 33 }; // percentage
    table.setWidths(headerwidths); // percentage
    table.setWidthPercentage(100);//from  w  w w .ja v a  2 s  . com
    table.getDefaultCell().setLeading(fixedLeading, 0);
    table.getDefaultCell().setPadding(0);
    table.getDefaultCell().setBorder(Rectangle.NO_BORDER);
    table.getDefaultCell().setVerticalAlignment(PdfPTable.ALIGN_BOTTOM);
    table.getDefaultCell().setHorizontalAlignment(PdfPTable.ALIGN_LEFT);

    return table;
}

From source file:gov.utah.dts.det.ccl.actions.reports.generators.FacilityLicenseDetailReport.java

private static PdfPTable getFacilityDetailTable() throws DocumentException {
    PdfPTable table = new PdfPTable(4);
    // format the table
    int headerwidths[] = { 11, 18, 29, 42 }; // percentage
    table.setWidths(headerwidths); // percentage
    table.setWidthPercentage(100);//from  www  . j a va2  s. co  m
    table.getDefaultCell().setLeading(fixedLeading, 0);
    table.getDefaultCell().setPadding(0);
    table.getDefaultCell().setBorder(Rectangle.NO_BORDER);
    table.getDefaultCell().setVerticalAlignment(PdfPTable.ALIGN_TOP);
    table.getDefaultCell().setHorizontalAlignment(PdfPTable.ALIGN_LEFT);

    return table;
}