Example usage for com.itextpdf.text Font BOLD

List of usage examples for com.itextpdf.text Font BOLD

Introduction

In this page you can find the example usage for com.itextpdf.text Font BOLD.

Prototype

int BOLD

To view the source code for com.itextpdf.text Font BOLD.

Click Source Link

Document

this is a possible style.

Usage

From source file:Tables.Printer.java

public Printer() {
    this.companyNameFont = new Font(Font.FontFamily.TIMES_ROMAN, 17, Font.BOLD, new BaseColor(0, 0, 128));
    this.reportTitleFont = new Font(Font.FontFamily.TIMES_ROMAN, 15, Font.BOLD, new BaseColor(51, 102, 13));
    bigHeading = new Font(FontFamily.TIMES_ROMAN, 16, Font.BOLD, new BaseColor(34, 90, 148));
    smallFooter = new Font(FontFamily.TIMES_ROMAN, 12, Font.ITALIC, new BaseColor(0, 0, 0));
    unpaid = new Font(FontFamily.TIMES_ROMAN, 13, Font.BOLD, new BaseColor(98, 45, 46));

    datOnly = new SimpleDateFormat("yyyy-MM-dd");
    timOnly = new SimpleDateFormat("hh:mm:ss");
    datTim = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
    datForFile = new SimpleDateFormat("yyyy-MM-dd __ hh mm ss");

}

From source file:Tables.Printer.java

public void genTrans(TableView gentab, TableColumn name, TableColumn desc, TableColumn amt, TableColumn date,
        long total, String incOrExp) {
    try {//  w w  w .  jav a  2  s.  c om
        //            Image im = Image.getInstance("src/njeiaccount/njei_img/accountcreation-icon.png");
        //            im.scaleAbsolute(150f, 150f);
        //            im.setAbsolutePosition(25,50);
        //            im.setBackgroundColor(BaseColor.PINK);

        dNow = new Date();
        String app = this.datForFile.format(dNow);
        String file = "\\Documents\\NjieAB_receipts\\general transactions\\GenTransRec" + app + ".pdf";
        System.out.println("file is " + file);
        fs = new FileOutputStream(System.getProperties().getProperty("user.home") + file); //this is for windows. since am developing on linux, i will use the next line. But for production version, i will enable the first optionand comment the second option as most users will be on the windows system. Or, will detect the OS and decide where to keept the files. Better idea
        //fs = new FileOutputStream(System.getProperties().getProperty("user.home")+"root/Desktop/reciept.pdf");

        Document doc = new Document(PageSize.A4, 20, 20, 20, 20);
        PdfWriter writer = PdfWriter.getInstance(doc, fs);
        //specify column widths    
        float[] columnWidths = { 4f, 5f, 1.5f, 2f };
        PdfPTable table = new PdfPTable(columnWidths);

        //special font sizes    
        Font bfBold12 = new Font(FontFamily.TIMES_ROMAN, 12, Font.BOLD, new BaseColor(0, 0, 0));
        Font bf12 = new Font(FontFamily.TIMES_ROMAN, 10);
        // set table width a percentage of the page width    
        table.setWidthPercentage(90f);

        PdfPCell cell = new PdfPCell(new Phrase("\nRECIEPT FOR "));
        cell.setColspan(6);
        cell.setHorizontalAlignment(2);
        doc.open();
        //doc.add(im);

        header(doc, "General " + incOrExp + " Transaction Table");

        doc.add(cell);
        System.out.println(doc.leftMargin());

        //insert column headings    
        insertTableHeading(table, "Transaction Name ", Element.ALIGN_MIDDLE, 1, bfBold12);
        insertTableHeading(table, "Description of Transaction", Element.ALIGN_MIDDLE, 1, bfBold12);
        insertTableHeading(table, "Amount", Element.ALIGN_MIDDLE, 1, bfBold12);
        insertTableHeading(table, "Date ", Element.ALIGN_MIDDLE, 1, bfBold12);
        table.setHeaderRows(1);

        /*Now i have to fill the table  */

        for (int i = 0; i < gentab.getItems().size(); i++) {
            insertCell(table, name.getCellData(i).toString(), Element.ALIGN_LEFT, 1, bf12);
            insertCell(table, desc.getCellData(i).toString(), Element.ALIGN_LEFT, 1, bf12);
            insertCell(table, amt.getCellData(i).toString(), Element.ALIGN_LEFT, 1, bf12);
            insertCell(table, date.getCellData(i).toString(), Element.ALIGN_RIGHT, 1, bf12);
        }

        insertCell(table, "Total ", Element.ALIGN_RIGHT, 2, bfBold12);
        insertCell(table, String.valueOf(total), Element.ALIGN_LEFT, 3, bfBold12);
        insertCell(table, "", Element.ALIGN_RIGHT, 4, bfBold12);
        doc.add(table);

        footer(doc); // this is rgw footer of the page

        doc.addCreationDate();
        doc.close();
        System.out.println("finished the printing job");

        //Desktop.getDesktop().open(new File(System.getProperties().getProperty("user.home")+"root/Desktop/reciept.pdf"));
        try {
            Desktop.getDesktop().open(new File(System.getProperties().getProperty("user.home") + file));
        } catch (IOException iOException) {
            System.out.println("failed opening the file");
            iOException.printStackTrace();
        }
    } catch (Exception sd) {
        sd.printStackTrace();
        Dialogs.create().title("Printer Error").masthead("Errro In Printing File").message(
                sd.getMessage() + " : " + sd.getCause() + " Caused By " + sd.getCause() + "--" + sd.toString())
                .showError();
    } finally {
    }
}

From source file:Tables.Printer.java

public void overdraft(TableView ovTab, TableColumn name, TableColumn amtIssued, TableColumn monthlyDeduction,
        TableColumn dateIssued, TableColumn startDeduction, TableColumn expDate, TableColumn payStatus,
        TableColumn expStatus, long totIssue, long totDeduction) {

    try {//from w  w w .jav a2  s.  c o m
        //            Image im = Image.getInstance("src/njeiaccount/njei_img/accountcreation-icon.png");
        //            im.scaleAbsolute(150f, 150f);
        //            im.setAbsolutePosition(25,50);
        //            im.setBackgroundColor(BaseColor.PINK);

        dNow = new Date();
        String app = this.datForFile.format(dNow);
        String file = "\\Documents\\NjieAB_receipts\\Overdraft\\GenTransRec" + app + ".pdf";
        System.out.println("file is " + file);
        fs = new FileOutputStream(System.getProperties().getProperty("user.home") + file); //this is for windows. since am developing on linux, i will use the next line. But for production version, i will enable the first optionand comment the second option as most users will be on the windows system. Or, will detect the OS and decide where to keept the files. Better idea
        //fs = new FileOutputStream(System.getProperties().getProperty("user.home")+"root/Desktop/reciept.pdf");

        Document doc = new Document();
        PdfWriter writer = PdfWriter.getInstance(doc, fs);
        //specify column widths    
        float[] columnWidths = { 2f, 2f, 2f, 3f, 3f, 2f, 1.5f, 1.5f };
        PdfPTable table = new PdfPTable(columnWidths);

        //special font sizes    
        Font bfBold12 = new Font(FontFamily.TIMES_ROMAN, 12, Font.BOLD, new BaseColor(0, 0, 0));
        Font bf12 = new Font(FontFamily.TIMES_ROMAN, 10);
        // set table width a percentage of the page width    
        table.setWidthPercentage(90f);

        PdfPCell cell = new PdfPCell(new Phrase("\nRECIEPT FOR "));
        cell.setColspan(6);
        cell.setHorizontalAlignment(2);
        doc.open();
        //doc.add(im);

        header(doc, "Staff Overdraft Reports");

        doc.add(cell);
        System.out.println(doc.leftMargin());

        //insert column headings    
        insertTableHeading(table, "Staff Name ", Element.ALIGN_MIDDLE, 1, bfBold12);
        insertTableHeading(table, "Amount Issued", Element.ALIGN_MIDDLE, 1, bfBold12);
        insertTableHeading(table, "Monthly Deduction", Element.ALIGN_MIDDLE, 1, bfBold12);
        insertTableHeading(table, "Date Issued ", Element.ALIGN_MIDDLE, 1, bfBold12);
        insertTableHeading(table, "Start Deduction", Element.ALIGN_MIDDLE, 1, bfBold12);
        insertTableHeading(table, "Expiry Date", Element.ALIGN_MIDDLE, 1, bfBold12);
        insertTableHeading(table, "Pay Status", Element.ALIGN_MIDDLE, 1, bfBold12);
        insertTableHeading(table, "Expiry Status", Element.ALIGN_MIDDLE, 1, bfBold12);
        table.setHeaderRows(1);

        /*Now i have to fill the table  */

        for (int i = 0; i < ovTab.getItems().size(); i++) {
            insertCell(table, name.getCellData(i).toString(), Element.ALIGN_LEFT, 1, bf12);
            insertCell(table, amtIssued.getCellData(i).toString(), Element.ALIGN_LEFT, 1, bf12);
            insertCell(table, monthlyDeduction.getCellData(i).toString(), Element.ALIGN_LEFT, 1, bf12);
            insertCell(table, dateIssued.getCellData(i).toString(), Element.ALIGN_RIGHT, 1, bf12);
            insertCell(table, startDeduction.getCellData(i).toString(), Element.ALIGN_LEFT, 1, bf12);
            insertCell(table, expDate.getCellData(i).toString(), Element.ALIGN_LEFT, 1, bf12);
            insertCell(table, payStatus.getCellData(i).toString(), Element.ALIGN_LEFT, 1, bf12);
            insertCell(table, expStatus.getCellData(i).toString(), Element.ALIGN_RIGHT, 1, bf12);
        }

        insertCell(table, "Total ", Element.ALIGN_RIGHT, 1, bfBold12);
        insertCell(table, String.valueOf(totIssue), Element.ALIGN_LEFT, 1, bfBold12);
        insertCell(table, String.valueOf(totDeduction), Element.ALIGN_LEFT, 1, bfBold12);
        insertCell(table, "", Element.ALIGN_LEFT, 1, bfBold12);
        insertCell(table, "", Element.ALIGN_LEFT, 1, bfBold12);
        insertCell(table, "", Element.ALIGN_LEFT, 1, bfBold12);
        insertCell(table, "", Element.ALIGN_LEFT, 1, bfBold12);
        insertCell(table, "", Element.ALIGN_LEFT, 1, bfBold12);
        doc.add(table);

        footer(doc); // this is rgw footer of the page

        doc.addCreationDate();
        doc.close();
        System.out.println("finished the printing job");

        //Desktop.getDesktop().open(new File(System.getProperties().getProperty("user.home")+"root/Desktop/reciept.pdf"));
        try {
            Desktop.getDesktop().open(new File(System.getProperties().getProperty("user.home") + file));
        } catch (IOException iOException) {
            System.out.println("failed opening the file");
        }
    } catch (DocumentException | FileNotFoundException sd) {
        Action showError = Dialogs
                .create().title("Printer Error").masthead("Errro In Printing File").message(sd.getMessage()
                        + " : " + sd.getCause() + " Caused By " + sd.getCause() + "--" + sd.toString())
                .showError();
    } finally {
    }

}

From source file:Tables.Printer.java

public void supCust_DebtIssue(TableView supIssTab, TableColumn name, TableColumn amtOwed, long total,
        String title, String fileName) {

    try {/*ww  w.  j  a  va2  s .  c o  m*/
        //            Image im = Image.getInstance("src/njeiaccount/njei_img/accountcreation-icon.png");
        //            im.scaleAbsolute(150f, 150f);
        //            im.setAbsolutePosition(25,50);
        //            im.setBackgroundColor(BaseColor.PINK);

        dNow = new Date();
        String app = this.datForFile.format(dNow);
        String file = "\\Documents\\NjieAB_receipts\\default" + app + ".pdf";
        if (fileName == "SupplierDebt") {
            file = "\\Documents\\NjieAB_receipts\\supplier\\debt " + app + ".pdf";
        } else if (fileName == "CustumerDebt") {
            file = "\\Documents\\NjieAB_receipts\\custumer\\debt " + app + ".pdf";
        }

        System.out.println("file is " + file);
        fs = new FileOutputStream(System.getProperties().getProperty("user.home") + file); //this is for windows. since am developing on linux, i will use the next line. But for production version, i will enable the first optionand comment the second option as most users will be on the windows system. Or, will detect the OS and decide where to keept the files. Better idea
        //fs = new FileOutputStream(System.getProperties().getProperty("user.home")+"root/Desktop/reciept.pdf");

        Document doc = new Document();
        PdfWriter writer = PdfWriter.getInstance(doc, fs);
        //specify column widths    
        float[] columnWidths = { 4f, 5f };
        PdfPTable table = new PdfPTable(columnWidths);

        //special font sizes    
        Font bfBold12 = new Font(FontFamily.TIMES_ROMAN, 12, Font.BOLD, new BaseColor(0, 0, 0));
        Font bf12 = new Font(FontFamily.TIMES_ROMAN, 10);
        // set table width a percentage of the page width    
        table.setWidthPercentage(90f);

        PdfPCell cell = new PdfPCell(new Phrase("\nRECIEPT FOR "));
        cell.setColspan(6);
        cell.setHorizontalAlignment(2);
        doc.open();
        //doc.add(im);

        header(doc, title);

        doc.add(cell);
        System.out.println(doc.leftMargin());

        //insert column headings    
        if (fileName == "SupplierDebt") {
            insertTableHeading(table, "Supplier Name ", Element.ALIGN_MIDDLE, 1, bfBold12);
            insertTableHeading(table, "Total Amount Owing", Element.ALIGN_MIDDLE, 1, bfBold12);
        } else if (fileName == "CustumerDebt") {
            insertTableHeading(table, "Custumer Name ", Element.ALIGN_MIDDLE, 1, bfBold12);
            insertTableHeading(table, "Total Amount Owing", Element.ALIGN_MIDDLE, 1, bfBold12);
        }
        table.setHeaderRows(1);

        /*Now i have to fill the table  */

        for (int i = 0; i < supIssTab.getItems().size(); i++) {
            insertCell(table, name.getCellData(i).toString(), Element.ALIGN_LEFT, 1, bf12);
            insertCell(table, amtOwed.getCellData(i).toString(), Element.ALIGN_LEFT, 1, bf12);
        }

        insertCell(table, "Total ", Element.ALIGN_RIGHT, 1, bfBold12);
        insertCell(table, String.valueOf(total), Element.ALIGN_LEFT, 2, bfBold12);
        doc.add(table);

        footer(doc); // this is rgw footer of the page

        doc.addCreationDate();
        doc.close();
        System.out.println("finished the printing job");

        try {
            Desktop.getDesktop().open(new File(System.getProperties().getProperty("user.home") + file));
        } catch (IOException iOException) {
            System.out.println("failed opening the file");
        }
    } catch (Exception sd) {
        Dialogs.create().title("Printer Error").masthead("Errro In Printing File").message(
                sd.getMessage() + " : " + sd.getCause() + " Caused By " + sd.getCause() + "--" + sd.toString())
                .showError();
    } finally {
    }

}

From source file:Tables.Printer.java

public void staffBalanceSalary(TableView supIssTab, TableColumn name, TableColumn branch,
        TableColumn amountLeft, long total) {
    String fileName = "StaffBalSalaryt";
    String title = "Staff Balance Salary";

    try {//from w w w . ja v a2s  .  c om
        //            Image im = Image.getInstance("src/njeiaccount/njei_img/accountcreation-icon.png");
        //            im.scaleAbsolute(150f, 150f);
        //            im.setAbsolutePosition(25,50);
        //            im.setBackgroundColor(BaseColor.PINK);

        dNow = new Date();
        String app = this.datForFile.format(dNow);
        String file = "\\Documents\\NjieAB_receipts\\staff\\bal " + app + ".pdf";

        System.out.println("file is " + file);
        fs = new FileOutputStream(System.getProperties().getProperty("user.home") + file); //this is for windows. since am developing on linux, i will use the next line. But for production version, i will enable the first optionand comment the second option as most users will be on the windows system. Or, will detect the OS and decide where to keept the files. Better idea
        //fs = new FileOutputStream(System.getProperties().getProperty("user.home")+"root/Desktop/reciept.pdf");

        Document doc = new Document();
        PdfWriter writer = PdfWriter.getInstance(doc, fs);
        //specify column widths    
        float[] columnWidths = { 4f, 5f, 4f };
        PdfPTable table = new PdfPTable(columnWidths);

        //special font sizes    
        Font bfBold12 = new Font(FontFamily.TIMES_ROMAN, 12, Font.BOLD, new BaseColor(0, 0, 0));
        Font bf12 = new Font(FontFamily.TIMES_ROMAN, 10);
        // set table width a percentage of the page width    
        table.setWidthPercentage(90f);

        PdfPCell cell = new PdfPCell(new Phrase("\nRECIEPT FOR "));
        cell.setColspan(6);
        cell.setHorizontalAlignment(2);
        doc.open();
        //doc.add(im);

        header(doc, title);

        doc.add(cell);
        System.out.println(doc.leftMargin());

        //insert column headings    

        insertTableHeading(table, "Staff Name ", Element.ALIGN_MIDDLE, 1, bfBold12);
        insertTableHeading(table, "Branch ", Element.ALIGN_MIDDLE, 1, bfBold12);
        insertTableHeading(table, "Salary Left", Element.ALIGN_MIDDLE, 1, bfBold12);

        table.setHeaderRows(1);

        /*Now i have to fill the table  */

        for (int i = 0; i < supIssTab.getItems().size(); i++) {
            insertCell(table, name.getCellData(i).toString(), Element.ALIGN_LEFT, 1, bf12);
            insertCell(table, branch.getCellData(i).toString(), Element.ALIGN_LEFT, 1, bf12);
            insertCell(table, amountLeft.getCellData(i).toString(), Element.ALIGN_LEFT, 1, bf12);

        }

        insertCell(table, "", Element.ALIGN_RIGHT, 1, bfBold12);
        insertCell(table, "Total ", Element.ALIGN_RIGHT, 1, bfBold12);
        insertCell(table, String.valueOf(total), Element.ALIGN_LEFT, 1, bfBold12);
        doc.add(table);

        footer(doc); // this is rgw footer of the page

        doc.addCreationDate();
        doc.close();
        System.out.println("finished the printing job");

        try {
            Desktop.getDesktop().open(new File(System.getProperties().getProperty("user.home") + file));
        } catch (IOException iOException) {
            System.out.println("failed opening the file");
        }
    } catch (Exception sd) {
        Dialogs.create().title("Printer Error").masthead("Errro In Printing File").message(
                sd.getMessage() + " : " + sd.getCause() + " Caused By " + sd.getCause() + "--" + sd.toString())
                .showError();
    } finally {
    }

}

From source file:Tables.Printer.java

public void salarySuspension(TableView supIssTab, TableColumn name, TableColumn amount, TableColumn reason,
        TableColumn susDate, TableColumn status, long total) {
    String title = "Salary Suspension";

    try {//  w  ww  .  j  a  v  a 2s . co m
        //            Image im = Image.getInstance("src/njeiaccount/njei_img/accountcreation-icon.png");
        //            im.scaleAbsolute(150f, 150f);
        //            im.setAbsolutePosition(25,50);
        //            im.setBackgroundColor(BaseColor.PINK);

        dNow = new Date();
        String app = this.datForFile.format(dNow);
        String file = "\\Documents\\NjieAB_receipts\\staff\\suspension " + app + ".pdf";

        System.out.println("file is " + file);
        fs = new FileOutputStream(System.getProperties().getProperty("user.home") + file); //this is for windows. since am developing on linux, i will use the next line. But for production version, i will enable the first optionand comment the second option as most users will be on the windows system. Or, will detect the OS and decide where to keept the files. Better idea
        //fs = new FileOutputStream(System.getProperties().getProperty("user.home")+"root/Desktop/reciept.pdf");

        Document doc = new Document(PageSize.A4, 10, 10, 5, 10);
        PdfWriter writer = PdfWriter.getInstance(doc, fs);
        //specify column widths    
        float[] columnWidths = { 6f, 3f, 8f, 3f, 2f };
        PdfPTable table = new PdfPTable(columnWidths);

        //special font sizes    
        Font bfBold12 = new Font(FontFamily.TIMES_ROMAN, 12, Font.BOLD, new BaseColor(0, 0, 0));
        Font bf12 = new Font(FontFamily.TIMES_ROMAN, 10);
        // set table width a percentage of the page width    
        table.setWidthPercentage(90f);

        PdfPCell cell = new PdfPCell(new Phrase("\nRECIEPT FOR "));
        cell.setColspan(6);
        cell.setHorizontalAlignment(2);
        doc.open();
        //doc.add(im);

        header(doc, title);

        doc.add(cell);
        System.out.println(doc.leftMargin());

        //insert column headings    

        insertTableHeading(table, "Staff Name ", Element.ALIGN_MIDDLE, 1, bfBold12);
        insertTableHeading(table, "Amount ", Element.ALIGN_MIDDLE, 1, bfBold12);
        insertTableHeading(table, "Reason", Element.ALIGN_MIDDLE, 1, bfBold12);
        insertTableHeading(table, "Date ", Element.ALIGN_MIDDLE, 1, bfBold12);
        insertTableHeading(table, "Status", Element.ALIGN_MIDDLE, 1, bfBold12);

        table.setHeaderRows(1);

        /*Now i have to fill the table  */

        for (int i = 0; i < supIssTab.getItems().size(); i++) {
            insertCell(table, name.getCellData(i).toString(), Element.ALIGN_LEFT, 1, bf12);
            insertCell(table, amount.getCellData(i).toString(), Element.ALIGN_LEFT, 1, bf12);
            insertCell(table, reason.getCellData(i).toString(), Element.ALIGN_LEFT, 1, bf12);
            insertCell(table, susDate.getCellData(i).toString(), Element.ALIGN_LEFT, 1, bf12);
            insertCell(table, status.getCellData(i).toString(), Element.ALIGN_LEFT, 1, bf12);

        }

        insertCell(table, "", Element.ALIGN_RIGHT, 1, bfBold12);
        insertCell(table, "Total ", Element.ALIGN_RIGHT, 1, bfBold12);
        insertCell(table, String.valueOf(total), Element.ALIGN_LEFT, 1, bfBold12);
        doc.add(table);

        footer(doc); // this is rgw footer of the page

        doc.addCreationDate();
        doc.close();
        System.out.println("finished the printing job");

        try {
            Desktop.getDesktop().open(new File(System.getProperties().getProperty("user.home") + file));
        } catch (IOException iOException) {
            System.out.println("failed opening the file");
        }
    } catch (Exception sd) {
        Dialogs.create().title("Printer Error").masthead("Errro In Printing File").message(
                sd.getMessage() + " : " + sd.getCause() + " Caused By " + sd.getCause() + "--" + sd.toString())
                .showError();
    } finally {
    }

}

From source file:Tables.Printer.java

public void staffSalaryPayments(TableView supIssTab, TableColumn name, TableColumn monthlySalary,
        TableColumn salaryPaid, TableColumn payDate, long total) {
    String fileName = "staffPayment";
    String title = "Staff Payment History";

    try {/*  w  ww. jav  a 2  s  .  c o  m*/
        //            Image im = Image.getInstance("src/njeiaccount/njei_img/accountcreation-icon.png");
        //            im.scaleAbsolute(150f, 150f);
        //            im.setAbsolutePosition(25,50);
        //            im.setBackgroundColor(BaseColor.PINK);

        dNow = new Date();
        String app = this.datForFile.format(dNow);
        String file = "\\Documents\\NjieAB_receipts\\staff\\pay " + app + ".pdf";

        System.out.println("file is " + file);
        fs = new FileOutputStream(System.getProperties().getProperty("user.home") + file); //this is for windows. since am developing on linux, i will use the next line. But for production version, i will enable the first optionand comment the second option as most users will be on the windows system. Or, will detect the OS and decide where to keept the files. Better idea
        //fs = new FileOutputStream(System.getProperties().getProperty("user.home")+"root/Desktop/reciept.pdf");

        Document doc = new Document();
        PdfWriter writer = PdfWriter.getInstance(doc, fs);
        //specify column widths    
        float[] columnWidths = { 6f, 4f, 4f, 4f };
        PdfPTable table = new PdfPTable(columnWidths);

        //special font sizes    
        Font bfBold12 = new Font(FontFamily.TIMES_ROMAN, 12, Font.BOLD, new BaseColor(0, 0, 0));
        Font bf12 = new Font(FontFamily.TIMES_ROMAN, 10);
        // set table width a percentage of the page width    
        table.setWidthPercentage(90f);

        PdfPCell cell = new PdfPCell(new Phrase("\nRECIEPT FOR "));
        cell.setColspan(6);
        cell.setHorizontalAlignment(2);
        doc.open();
        //doc.add(im);

        header(doc, title);

        doc.add(cell);
        System.out.println(doc.leftMargin());

        //insert column headings    

        insertTableHeading(table, "Staff Name ", Element.ALIGN_MIDDLE, 1, bfBold12);
        insertTableHeading(table, "Monthly Salary ", Element.ALIGN_MIDDLE, 1, bfBold12);
        insertTableHeading(table, "Salary Paid", Element.ALIGN_MIDDLE, 1, bfBold12);
        insertTableHeading(table, "Payment Date", Element.ALIGN_MIDDLE, 1, bfBold12);

        table.setHeaderRows(1);

        /*Now i have to fill the table  */

        for (int i = 0; i < supIssTab.getItems().size(); i++) {
            insertCell(table, name.getCellData(i).toString(), Element.ALIGN_LEFT, 1, bf12);
            insertCell(table, monthlySalary.getCellData(i).toString(), Element.ALIGN_LEFT, 1, bf12);
            insertCell(table, salaryPaid.getCellData(i).toString(), Element.ALIGN_LEFT, 1, bf12);
            insertCell(table, payDate.getCellData(i).toString(), Element.ALIGN_LEFT, 1, bf12);

        }

        insertCell(table, "", Element.ALIGN_RIGHT, 1, bfBold12);
        insertCell(table, "Total ", Element.ALIGN_RIGHT, 1, bfBold12);
        insertCell(table, String.valueOf(total), Element.ALIGN_LEFT, 1, bfBold12);
        doc.add(table);

        footer(doc); // this is rgw footer of the page

        doc.addCreationDate();
        doc.close();
        System.out.println("finished the printing job");

        try {
            Desktop.getDesktop().open(new File(System.getProperties().getProperty("user.home") + file));
        } catch (IOException iOException) {
            System.out.println("failed opening the file");
        }
    } catch (Exception sd) {
        Dialogs.create().title("Printer Error").masthead("Errro In Printing File").message(
                sd.getMessage() + " : " + sd.getCause() + " Caused By " + sd.getCause() + "--" + sd.toString())
                .showError();
    } finally {
    }

}

From source file:Tables.Printer.java

public void supCust_PayDebt(TableView supPayTab, TableColumn name, TableColumn debtPayment,
        TableColumn paymtDate, long total, String title, String fileName) {

    try {//from  www .ja v  a2  s  .  c  om
        //            Image im = Image.getInstance("src/njeiaccount/njei_img/accountcreation-icon.png");
        //            im.scaleAbsolute(150f, 150f);
        //            im.setAbsolutePosition(25,50);
        //            im.setBackgroundColor(BaseColor.PINK);

        dNow = new Date();
        String app = this.datForFile.format(dNow);

        String file = "\\Documents\\NjieAB_receipts\\default" + app + ".pdf";
        if (fileName == "SupplierDebtPayment") {
            file = "\\Documents\\NjieAB_receipts\\supplier\\pay " + app + ".pdf";
        } else if (fileName == "CustumerDebtPayment") {
            file = "\\Documents\\NjieAB_receipts\\custumer\\pay " + app + ".pdf";
        } else if (fileName == "StaffBalSalaryt") {
            file = "\\Documents\\NjieAB_receipts\\staff\\balance " + app + ".pdf";
        }

        System.out.println("file is " + file);
        fs = new FileOutputStream(System.getProperties().getProperty("user.home") + file); //this is for windows. since am developing on linux, i will use the next line. But for production version, i will enable the first optionand comment the second option as most users will be on the windows system. Or, will detect the OS and decide where to keept the files. Better idea
        //fs = new FileOutputStream(System.getProperties().getProperty("user.home")+"root/Desktop/reciept.pdf");

        Document doc = new Document();
        PdfWriter writer = PdfWriter.getInstance(doc, fs);
        //specify column widths    
        float[] columnWidths = { 4f, 5f, 3f };
        PdfPTable table = new PdfPTable(columnWidths);

        //special font sizes    
        Font bfBold12 = new Font(FontFamily.TIMES_ROMAN, 12, Font.BOLD, new BaseColor(0, 0, 0));
        Font bf12 = new Font(FontFamily.TIMES_ROMAN, 12);
        // set table width a percentage of the page width    
        table.setWidthPercentage(90f);

        PdfPCell cell = new PdfPCell(new Phrase("\nRECIEPT FOR "));
        cell.setColspan(6);
        cell.setHorizontalAlignment(2);
        doc.open();
        //doc.add(im);

        header(doc, title);

        doc.add(cell);
        System.out.println(doc.leftMargin());

        //insert column headings
        if (fileName == "SupplierDebtPayment") {
            insertTableHeading(table, "Supplier Name ", Element.ALIGN_MIDDLE, 1, bfBold12);
            insertTableHeading(table, "Amount Owing", Element.ALIGN_MIDDLE, 1, bfBold12);
            insertTableHeading(table, "Date Issued", Element.ALIGN_MIDDLE, 1, bfBold12);
        } else if (fileName == "CustumerDebtPayment") {
            insertTableHeading(table, "Custumer Name ", Element.ALIGN_MIDDLE, 1, bfBold12);
            insertTableHeading(table, "Amount Owing", Element.ALIGN_MIDDLE, 1, bfBold12);
            insertTableHeading(table, "Date Issued", Element.ALIGN_MIDDLE, 1, bfBold12);
        } else if (fileName == "StaffBalSalaryt") {
            insertTableHeading(table, "Staff Name ", Element.ALIGN_MIDDLE, 1, bfBold12);
            insertTableHeading(table, "Branch", Element.ALIGN_MIDDLE, 1, bfBold12);
            insertTableHeading(table, "Balance Amount", Element.ALIGN_MIDDLE, 1, bfBold12);
        }
        table.setHeaderRows(1);

        /*Now i have to fill the table  */

        for (int i = 0; i < supPayTab.getItems().size(); i++) {
            insertCell(table, name.getCellData(i).toString(), Element.ALIGN_LEFT, 1, bf12);
            insertCell(table, debtPayment.getCellData(i).toString(), Element.ALIGN_LEFT, 1, bf12);
            insertCell(table, paymtDate.getCellData(i).toString(), Element.ALIGN_LEFT, 1, bf12);
        }

        insertCell(table, "Total ", Element.ALIGN_RIGHT, 1, bfBold12);
        insertCell(table, String.valueOf(total), Element.ALIGN_LEFT, 2, bfBold12);
        insertCell(table, "", Element.ALIGN_RIGHT, 3, bfBold12);
        doc.add(table);

        footer(doc); // this is rgw footer of the page

        doc.addCreationDate();
        doc.close();
        System.out.println("finished the printing job");

        //Desktop.getDesktop().open(new File(System.getProperties().getProperty("user.home")+"root/Desktop/reciept.pdf"));
        try {
            Desktop.getDesktop().open(new File(System.getProperties().getProperty("user.home") + file));
        } catch (IOException iOException) {
            System.out.println("failed opening the file");
        }
    } catch (Exception sd) {
        Dialogs.create().title("Printer Error").masthead("Errro In Printing File").message(
                sd.getMessage() + " : " + sd.getCause() + " Caused By " + sd.getCause() + "--" + sd.toString())
                .showError();
    } finally {
    }

}

From source file:Tables.PrinterClass.java

public PrinterClass() {
    /****default values for the printer */
    System.out.println("instantiating the printer class");

    companyName = "Unity Systems";
    companyLocation = "Malingo, HIAMS building, Buea";
    companyTel = "+237 679574561";
    companyPoBox = "PB 1001, Buea";

    smallFooter = new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.ITALIC, new BaseColor(157, 175, 157));
    this.companyNameFont = new Font(Font.FontFamily.TIMES_ROMAN, 22, Font.BOLD, new BaseColor(0, 0, 128));
    this.companySubInfoFont = new Font(Font.FontFamily.TIMES_ROMAN, 18, Font.BOLD, new BaseColor(51, 102, 13));
    this.tHeadingFont = new Font(Font.FontFamily.TIMES_ROMAN, 16, Font.BOLD, new BaseColor(51, 51, 0));
    this.tBodyFont = new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD, new BaseColor(51, 51, 51));

    this.saveDir = "\\";

    dateOnly = new SimpleDateFormat("yyyy-MM-dd");
    timeOnly = new SimpleDateFormat("hh:mm:ss");
    dateTime = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
    datForFile = new SimpleDateFormat("yyyy-MM-dd __ hh mm ss");
}

From source file:tmarker.PerformanceOverviewPanel.java

License:Open Source License

@Override
protected void paintComponent(Graphics g) {
    super.paintComponent(g);
    Graphics2D g2 = (Graphics2D) g;
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
    g.setFont(g.getFont().deriveFont(Font.BOLD));

    double dx = 1.0 * getWidth() / (length); // distance between two values on x axis.
    double factor = getHeight() / (max + 20); // scale factor for values on y axis (not to be higher than the panel height).

    // draw the free memory
    //g.setColor(Color.GREEN);
    //for (int i=1; i<length; i++) {
    //    g.drawLine((int)((i-1)*dx), getHeight()-(int)(factor*(int)(freeMem.get(i-1))), (int)(i*dx), getHeight()-(int)(factor*(int)(freeMem.get(i))));
    //}//  w  w w.j a  v  a2s. c o  m
    //g.drawString("Free " + freeMem.get(freeMem.size()-1) + " MB", 95, getHeight() -5);

    // draw the total memory used so far
    g.setColor(Color.GREEN);
    for (int i = 1; i < length; i++) {
        g.drawLine((int) ((i - 1) * dx), getHeight() - (int) (factor * (int) (totMem.get(i - 1))),
                (int) (i * dx), getHeight() - (int) (factor * (int) (totMem.get(i))));
    }
    g.drawString("Tot " + totMem.get(totMem.size() - 1) + " MB", 185, getHeight() - 5);

    // draw the used memory
    g.setColor(Color.YELLOW);
    for (int i = 1; i < length; i++) {
        g.drawLine((int) ((i - 1) * dx), getHeight() - (int) (factor * (int) (usedMem.get(i - 1))),
                (int) (i * dx), getHeight() - (int) (factor * (int) (usedMem.get(i))));
    }
    g.drawString("Used " + usedMem.get(usedMem.size() - 1) + " MB", 95, getHeight() - 5);

    // draw the max memory (constant, given by -xmx flag on start of the program)
    g.setColor(Color.RED);
    g.drawString("Max " + maxMem + " MB", 5, getHeight() - 5);

}