Example usage for com.itextpdf.text Paragraph add

List of usage examples for com.itextpdf.text Paragraph add

Introduction

In this page you can find the example usage for com.itextpdf.text Paragraph add.

Prototype

@Override
public boolean add(Element o) 

Source Link

Document

Adds an Element to the Paragraph.

Usage

From source file:klasy.PdfFiles.java

public static void createTable() {
    try {//from  w  w  w.  j a  v a  2s .  c o m
        Document document = new Document();
        PdfWriter.getInstance(document, new FileOutputStream(FILE2));
        document.open();
        PdfPTable table = new PdfPTable(8);

        PdfPCell c1 = new PdfPCell(new Phrase("Imie pasazera"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);

        c1 = new PdfPCell(new Phrase("Nazwisko pasazera"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);

        c1 = new PdfPCell(new Phrase("Data lotu"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);

        c1 = new PdfPCell(new Phrase("Data wystawienia biletu"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);

        c1 = new PdfPCell(new Phrase("Cel podrozy: "));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);

        c1 = new PdfPCell(new Phrase("Cena: "));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);

        c1 = new PdfPCell(new Phrase("Model samolotu: "));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);

        c1 = new PdfPCell(new Phrase("Nr lotu: "));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);

        Functions f = new Functions();

        for (Bilet b : bilety) {
            Miasto m = f.getMiasto(b);
            Samolot s = f.getSamolot(b);

            table.addCell(b.getImie_pasazera());
            table.addCell(b.getNazwisko_pasazera());
            table.addCell(b.getData_lotu());
            table.addCell(b.getData_wystawienia_biletu());
            table.addCell(m.getNazwa());
            table.addCell(Double.toString(m.getCena()));
            table.addCell(s.getModel());
            table.addCell(s.getNr_samolotu());
            //JOptionPane.showMessageDialog(null, b);

        }
        Paragraph preface = new Paragraph();
        preface.add(table);

        document.add(preface);
        document.close();

        addEmptyLine(preface, 30);
        preface.add(new Paragraph("Wygenerowano: " + new Date(), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                smallBold));

    } catch (Exception e) {
        JOptionPane.showMessageDialog(null, e);
    }

}

From source file:KTCNPM.ExportFile.java

public void exportFile(ArrayList<String> list, ArrayList<String> listTAW, ArrayList<String> listTBF,
        ArrayList<String> listTCF, ArrayList<String> listEF, ArrayList<String> listG) throws IOException {
    Document document = new Document();

    try {/*w  w w.  j  a va  2  s . co m*/
        String fileSRC = "E:\\KTCNPM.pdf";
        File file = new File(fileSRC);
        if (file.exists()) {
            file.delete();
        } else {
            file.createNewFile();
        }

        PdfWriter.getInstance(document, new FileOutputStream(fileSRC));
        document.open();

        Font f1 = new Font(
                BaseFont.createFont("/newpackage/vuArialBold.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED));
        Font f2 = new Font(
                BaseFont.createFont("/newpackage/vuArial.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED));
        f2.setSize(9);
        f1.setSize(13);

        Paragraph paragraph2 = new Paragraph("", f2);
        Paragraph paragraph3 = new Paragraph();

        paragraph2.setIndentationLeft(80);
        paragraph2.setIndentationRight(80);
        paragraph2.setAlignment(Element.ALIGN_LEFT);
        paragraph2.setSpacingAfter(15);

        Phrase phrase2 = new Phrase("Tn phn m?m: Tnh chi ph phn m?m");
        Phrase phrase3 = new Phrase(" ");
        paragraph3.add(phrase3);
        paragraph2.add(phrase2);

        //Phu luc 3
        Phrase phrase5 = new Phrase(
                "Ph lc III: Bng tnh ton im cc tc nhn (actors) tng tc, trao i thng tin");
        Paragraph paragraph5 = new Paragraph("", f1);
        paragraph5.setIndentationLeft(80);
        paragraph5.setIndentationRight(80);
        paragraph5.setAlignment(Element.ALIGN_CENTER);
        paragraph5.setSpacingAfter(10);
        paragraph5.add(phrase5);

        document.add(paragraph5);
        document.add(paragraph2);

        PdfPTable table3 = new PdfPTable(5);

        table3.setWidthPercentage(400 / 5.23f);
        table3.setWidths(new int[] { 1, 5, 3, 2, 3 });
        for (int i = 0; i < listTAW.size(); i++) {
            Paragraph p = new Paragraph(listTAW.get(i), f2);
            PdfPCell data = new PdfPCell(p);
            table3.addCell(data);
        }
        document.add(table3);
        document.add(paragraph3);
        document.add(paragraph3);
        document.add(paragraph3);

        // phu luc 4
        Phrase phrase41 = new Phrase(
                "Ph lc IV: Bng tnh ton im cc tr?ng hp s dung (use case)");
        Paragraph paragraph41 = new Paragraph("", f1);
        paragraph41.setIndentationLeft(80);
        paragraph41.setIndentationRight(80);
        paragraph41.setAlignment(Element.ALIGN_CENTER);
        paragraph41.setSpacingAfter(10);
        paragraph41.add(phrase41);

        document.add(paragraph41);
        document.add(paragraph2);

        PdfPTable table4 = new PdfPTable(4);
        table4.setWidthPercentage(400 / 5.23f);
        table4.setWidths(new int[] { 1, 3, 3, 4 });
        for (int i = 0; i < listTBF.size(); i++) {
            PdfPCell data = new PdfPCell(new Paragraph(listTBF.get(i), f2));
            table4.addCell(data);
        }
        document.add(table4);
        document.add(paragraph3);
        document.add(paragraph3);
        document.add(paragraph3);

        // phu luc 5
        Phrase phrase51 = new Phrase(
                "Ph lc V: Bng tnh ton h s phc tp k thut - cng ngh");
        Paragraph paragraph51 = new Paragraph("", f1);
        paragraph51.setIndentationLeft(80);
        paragraph51.setIndentationRight(80);
        paragraph51.setAlignment(Element.ALIGN_CENTER);
        paragraph51.setSpacingAfter(10);
        paragraph51.add(phrase51);

        document.add(paragraph51);
        document.add(paragraph2);

        PdfPTable table5 = new PdfPTable(5);
        table5.setWidthPercentage(400 / 5.23f);
        table5.setWidths(new int[] { 1, 6, 2, 2, 2 });
        for (int i = 0; i < listTCF.size(); i++) {
            PdfPCell data = new PdfPCell(new Paragraph(listTCF.get(i), f2));
            table5.addCell(data);
        }
        document.add(table5);
        document.add(paragraph3);
        document.add(paragraph3);
        document.add(paragraph3);

        //phu luc 6
        Phrase phrase61 = new Phrase(
                "Ph lc VI: Bng tnh ton h s tc ng mi tr?ng v nhm lm vic, h s phc tp v? mi tr?ng");
        Paragraph paragraph61 = new Paragraph("", f1);
        paragraph61.setIndentationLeft(80);
        paragraph61.setIndentationRight(80);
        paragraph61.setAlignment(Element.ALIGN_CENTER);
        paragraph61.setSpacingAfter(10);
        paragraph61.add(phrase61);

        document.add(paragraph61);
        document.add(paragraph2);

        PdfPTable table6 = new PdfPTable(6);
        table6.setWidthPercentage(400 / 5.23f);
        table6.setWidths(new int[] { 1, 6, 2, 2, 2, 3 });
        for (int i = 0; i < listEF.size(); i++) {
            PdfPCell data = new PdfPCell(new Paragraph(listEF.get(i), f2));
            table6.addCell(data);
        }
        document.add(table6);
        document.add(paragraph3);
        document.add(paragraph3);
        document.add(paragraph3);

        //phu luc 7
        Phrase phrase7 = new Phrase("Ph lc VII: Bng tnh ton gi tr phn m?m");
        Paragraph paragraph7 = new Paragraph("", f1);
        paragraph7.setIndentationLeft(80);
        paragraph7.setIndentationRight(80);
        paragraph7.setAlignment(Element.ALIGN_CENTER);
        paragraph7.setSpacingAfter(10);
        paragraph7.add(phrase7);

        document.add(paragraph7);
        document.add(paragraph2);

        PdfPTable table7 = new PdfPTable(5);
        table7.setWidthPercentage(400 / 5.23f);
        table7.setWidths(new int[] { 1, 5, 5, 4, 2 });
        for (int i = 0; i < listG.size(); i++) {
            PdfPCell data = new PdfPCell(new Paragraph(listG.get(i), f2));
            table7.addCell(data);
        }
        document.add(table7);
        document.add(paragraph3);
        document.add(paragraph3);
        document.add(paragraph3);

        // phu luc 8
        Paragraph paragraph1 = new Paragraph("", f1);
        paragraph1.setIndentationLeft(80);
        paragraph1.setIndentationRight(80);
        paragraph1.setAlignment(Element.ALIGN_CENTER);
        paragraph1.setSpacingAfter(10);
        Phrase phrase1 = new Phrase("Ph lc VIII: Bng tng hp chi ph phn m?m");
        paragraph1.add(phrase1);
        document.add(paragraph1);
        document.add(paragraph2);
        PdfPTable table = new PdfPTable(5);
        table.setWidthPercentage(400 / 5.23f);
        table.setWidths(new int[] { 1, 5, 3, 4, 2 });

        for (int i = 0; i < list.size(); i++) {
            PdfPCell data = new PdfPCell(new Paragraph(list.get(i), f2));
            table.addCell(data);
        }
        document.add(table);
        document.close();

    } catch (DocumentException | FileNotFoundException e) {
    }
}

From source file:lk.score.androphsy.report.ReportPdf.java

License:Open Source License

private void addContent(Document document, String feature) {
    String title = "";

    if (feature == "User Credentials") {
        title = "User Credentials";

    } else if (feature == "SMS") {
        title = "Short Message Service (SMS)";

    } else if (feature == "Phone Book") {
        title = "Contact Numbers/Phone Book";

    } else if (feature == "Gmail") {
        title = "Gmail Information";

    } else if (feature == "Calendar") {
        title = "Calendar Events";

    } else if (feature == "YouTube") {
        title = "YouTube History";

    } else if (feature.equals("FACEBOOK_MESSAGES")) {
        title = "Facebook Messages";

    } else if (feature.equals("FACEBOOK_CONTACTS")) {
        title = "Facebook Contacts";

    } else if (feature.equals("FACEBOOK_NOTIFICATIONS")) {
        title = "Facebook Notifications";

    } else if (feature.equals("LINKEDIN_PROFILE")) {
        title = "LinkedIn Profile";

    } else if (feature.equals("LINKEDIN_CONNECTIONS")) {
        title = "LinkedIn Connections";

    } else if (feature.equals("LINKEDIN_INVITATIONS")) {
        title = "LinkedIn Invitations";

    } else if (feature.equals("LINKEDIN_MESSAGES")) {
        title = "LinkedIn Messages";

    } else if (feature.equals("DEFAULT_WEB_FORM_DATA")) {
        title = "Interacted Web Forms and Supplied Parameter Values";

    } else if (feature.equals("DEFAULT_COOKIES")) {
        title = "Default Browser Cookie Information";

    } else if (feature.equals("DEFAULT_WEB_SEARCH")) {
        title = "Default Browser Web lk.score.androphsy.main.Search Text";

    } else if (feature.equals("DEFAULT_BOOKMARKS")) {
        title = "Bookmarked URL Information";

    } else if (feature.equals("DEFAULT_BROWSER_HISTORY")) {
        title = "Default Browser History";

    } else if (feature.equals("CHROME_BROWSER_HISTORY")) {
        title = "Chrome Browser History";

    } else if (feature.equals("CHROME_COOKIES")) {
        title = "Chrome Browser Cookie Information";

    } else if (feature.equals("CHROME_WEB_SEARCH")) {
        title = "Chrome Web lk.score.androphsy.main.Search Text";

    } else if (feature.equals("CHROME_CREDIT_CARD")) {
        title = "Chrome Credit Card Information";

    } else if (feature.equals("Firefox_COOKIES")) {
        title = "Firefox Browser Cookies";

    } else if (feature.equals("Firefox_WEB_SEARCH")) {
        title = "Firefox WebSearch";

    } else if (feature.equals("Firefox_BOOKMARKS")) {
        title = "Firefox Bookmark";

    } else if (feature.equals("Firefox_BROWSER_HISTORYy")) {
        title = "Firefox Browser History";

    } else if (feature.equals("Call Logs")) {
        title = "Call Logs";

    } else if (feature.equals("SMS Logs")) {
        title = "SMS Logs";

    } else if (feature.equals("MMS Logs")) {
        title = "MMS Logs";

    } else if (feature == "Wi-Fi Access Points") {
        title = "Wi-Fi Access Points";

    } else if (feature.equals("Wi-Fi Access Points")) {
        title = "Wi-Fi Access Points";

    } else if (feature == "Bluetooth Data") {
        title = "Bluetooth Information";

    } else if (feature.equals("Bluetooth Data")) {
        title = "Bluetooth Information";

    } else if (feature == "Skype Account") {
        title = "Skype Account";

    } else if (feature == "Skype Contacts") {
        title = "Skype Contacts";

    } else if (feature == "Skype Calls") {
        title = "Skype Call";

    } else if (feature == "Skype Messages") {
        title = "Skype Message";

    }/*from  w w w  .j a  va  2s .  c om*/

    try {
        document.newPage();

        Paragraph subpara = new Paragraph(title, HeadingFont);
        subpara.setAlignment(Paragraph.ALIGN_CENTER);
        addEmptyLine(subpara, 1);

        if (feature == "User Credentials") {
            Paragraph p1 = new Paragraph("Primary Account Detail", SubHeadingFont);
            addEmptyLine(p1, 1);
            CreateTable(p1, "PRIMARY_ACC");
            addEmptyLine(p1, 1);
            subpara.add(p1);

            Paragraph p2 = new Paragraph("Secondary Account Detail", SubHeadingFont);
            addEmptyLine(p2, 1);
            CreateTable(p2, "OTHER_ACC");
            subpara.add(p2);

        } else if (feature.equals("Call Logs")) {
            Paragraph p1 = new Paragraph("Incomming Calls Log", SubHeadingFont);
            addEmptyLine(p1, 1);
            CreateTable(p1, "INCOMING_CALLS");
            addEmptyLine(p1, 1);
            subpara.add(p1);

            Paragraph p2 = new Paragraph("Missed Calls Log", SubHeadingFont);
            addEmptyLine(p2, 1);
            CreateTable(p2, "MISSED_CALLS");
            subpara.add(p2);

            Paragraph p3 = new Paragraph("Cancelled Calls Log", SubHeadingFont);
            addEmptyLine(p3, 1);
            CreateTable(p3, "CANCELLED_CALLS");
            addEmptyLine(p3, 1);
            subpara.add(p3);

            Paragraph p4 = new Paragraph("Outgoing Calls Log", SubHeadingFont);
            addEmptyLine(p4, 1);
            CreateTable(p4, "OUTGOING_CALLS");
            subpara.add(p4);

        } else if (feature.equals("SMS Logs")) {
            Paragraph p1 = new Paragraph("Incomming SMS Log", SubHeadingFont);
            addEmptyLine(p1, 1);
            CreateTable(p1, "SMS_INBOX");
            addEmptyLine(p1, 1);
            subpara.add(p1);

            Paragraph p2 = new Paragraph("Outgoing SMS Log", SubHeadingFont);
            addEmptyLine(p2, 1);
            CreateTable(p2, "SMS_OUTBOX");
            subpara.add(p2);

        } else if (feature.equals("MMS Logs")) {

            Paragraph p1 = new Paragraph("Incomming MMS Log", SubHeadingFont);
            addEmptyLine(p1, 1);
            CreateTable(p1, "MMS_INBOX");
            addEmptyLine(p1, 1);
            subpara.add(p1);

            Paragraph p2 = new Paragraph("Outgoing MMS Log", SubHeadingFont);
            addEmptyLine(p2, 1);
            CreateTable(p2, "MMS_OUTBOX");
            subpara.add(p2);

        } else if (feature == "Bluetooth Data") {
            Paragraph p1 = new Paragraph("Nearby Bluetooth Device Information", SubHeadingFont);
            addEmptyLine(p1, 1);
            CreateTable(p1, "BT_SEEN");
            addEmptyLine(p1, 1);
            subpara.add(p1);

            Paragraph p2 = new Paragraph("Contacted Bluetooth Device Information", SubHeadingFont);
            addEmptyLine(p2, 1);
            CreateTable(p2, "BT_USED");
            subpara.add(p2);

        } else if (feature.equals("Bluetooth Data")) {
            Paragraph p1 = new Paragraph("Nearby Bluetooth Device Information", SubHeadingFont);
            addEmptyLine(p1, 1);
            CreateTable(p1, "BT_SEEN");
            addEmptyLine(p1, 1);
            subpara.add(p1);

            Paragraph p2 = new Paragraph("Contacted Bluetooth Device Information", SubHeadingFont);
            addEmptyLine(p2, 1);
            CreateTable(p2, "BT_USED");
            subpara.add(p2);
        } else {
            CreateTable(subpara, feature);
        }

        document.add(subpara);
    } catch (DocumentException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:lk.score.androphsy.report.ReportPdf.java

License:Open Source License

private void CreateTable(Paragraph subpara, String feature) {
    System.out.println("Report Create Table: " + feature);
    try {/*from   w w  w  . j  ava 2s. c  o m*/
        String query = "";
        Connection conn = new ConnectDb().getConnection();
        Statement stmt = conn.createStatement();

        if (feature == "PRIMARY_ACC") {
            query = "SELECT host AS 'Account Type', username AS 'User Name',"
                    + " password AS 'Password (HASHED)'" + " FROM Androspy_Account" + " WHERE case_id = "
                    + AndrospyMain.gb_CaseId + " AND device_id = " + AndrospyMain.gb_DeviceId
                    + " AND primary_acc = " + 1;

        } else if (feature == "OTHER_ACC") {
            query = "SELECT host AS 'Account Type', username AS 'User Name'," + " password AS 'Password'"
                    + " FROM Androspy_Account" + " WHERE case_id = " + AndrospyMain.gb_CaseId
                    + " AND device_id = " + AndrospyMain.gb_DeviceId + " AND primary_acc != " + 1;

        } else if (feature == "SMS") {
            query = "SELECT subject AS 'Subject', body AS 'Message Body',"
                    + " type AS 'Message Type', date_received AS 'Received Date', date_sent AS 'Send Date'"
                    + " FROM Sms" + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = "
                    + AndrospyMain.gb_DeviceId;

        } else if (feature == "Phone Book") {
            query = "SELECT contact_no AS 'Contact No', name AS 'Name',"
                    + " times_contacted AS 'Times Contacted', last_time_contacted AS 'Last Contacted Date'"
                    + " FROM Contacts" + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = "
                    + AndrospyMain.gb_DeviceId;

        } else if (feature == "Gmail") {
            query = "SELECT fromaddress AS 'From Address',"
                    + " toaddress AS 'To Address', ccaddress AS 'CC Address', bccaddress AS 'BCC Address',"
                    + " replytoaddress AS 'Reply To Address', subject AS 'Subject', snippet As 'Message Body', "
                    + "datesent AS 'Send Date', datereceive AS 'Received Date'" + " FROM Gmail_Store"
                    + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = "
                    + AndrospyMain.gb_DeviceId;

        } else if (feature == "Calendar") {
            query = "SELECT title AS 'Title', description AS 'Event', location AS 'Location',"
                    + " start_time AS 'Start Time', end_time AS 'End Time', created_by AS 'Creator'"
                    + " FROM Calendar_Event" + " WHERE case_id = " + AndrospyMain.gb_CaseId
                    + " AND device_id = " + AndrospyMain.gb_DeviceId;

        } else if (feature == "YouTube") {
            query = "SELECT query AS 'Search' , search_date AS 'Time Stamp'" + " FROM Youtube_History"
                    + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = "
                    + AndrospyMain.gb_DeviceId;

        } else if (feature.equals("FACEBOOK_MESSAGES")) {
            query = "SELECT IFNULL(sender, '') AS 'Sender'," + " IFNULL(text, '') AS 'Message',"
                    + " IFNULL(conversation_date, '') AS 'Date'," + " IFNULL(logitude, '') AS 'Longitude',"
                    + " IFNULL(latitude, '') AS 'Latitude'" + " FROM Facebook_Message" + " WHERE case_id = "
                    + AndrospyMain.gb_CaseId + " AND device_id = " + AndrospyMain.gb_DeviceId;

        } else if (feature.equals("FACEBOOK_CONTACTS")) {
            query = "SELECT IFNULL(first_name, '') AS 'First Name'," + " IFNULL(last_name, '') AS 'Last Name',"
                    + " IFNULL(display_name, '') AS 'Display Name',"
                    + " IFNULL(added_time, '') AS 'Time Stamp'," + " IFNULL(type, '') AS 'Contact Type'"
                    + " FROM Fb_Contacts" + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = "
                    + AndrospyMain.gb_DeviceId;

        } else if (feature.equals("FACEBOOK_NOTIFICATIONS")) {
            query = "SELECT IFNULL(notification, '') AS 'Notification'," + " IFNULL(update_date, '') AS 'Date'"
                    + " FROM Facebook_Notifications" + " WHERE case_id = " + AndrospyMain.gb_CaseId
                    + " AND device_id = " + AndrospyMain.gb_DeviceId;

        } else if (feature.equals("LINKEDIN_PROFILE")) {
            query = "SELECT first_name AS 'First Name', last_name AS 'Last Name', display_name AS 'Display Name',"
                    + "country AS 'Country', join_date AS 'Join Date', connections AS 'No of Connections'"
                    + " FROM Linkedin_Profile" + " WHERE case_id = " + AndrospyMain.gb_CaseId
                    + " AND device_id = " + AndrospyMain.gb_DeviceId;

        } else if (feature.equals("LINKEDIN_CONNECTIONS")) {
            query = "SELECT IFNULL(first_name, '') AS 'First Name'," + " IFNULL(last_name, '') AS 'Last Name',"
                    + " IFNULL(display_name, '') AS 'Display Name'," + " IFNULL(title, '') AS 'Title'"
                    + " FROM Linkedin_Connections" + " WHERE case_id = " + AndrospyMain.gb_CaseId
                    + " AND device_id = " + AndrospyMain.gb_DeviceId;

        } else if (feature.equals("LINKEDIN_INVITATIONS")) {
            query = "SELECT IFNULL(from_display_name, '') AS 'Sender Name'," + " IFNULL(title, '') AS 'Title',"
                    + " IFNULL(invitation_date, '') AS 'Invitation Date'" + " FROM Linkedin_Invitation"
                    + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = "
                    + AndrospyMain.gb_DeviceId;

        } else if (feature.equals("LINKEDIN_MESSAGES")) {
            query = "SELECT from_display_name AS 'Remote Party', from_title AS 'Remote Party Title',"
                    + " message_date AS 'Message Date', subject AS Subject, message_body AS Message"
                    + " FROM Linkedin_Message" + " WHERE case_id = " + AndrospyMain.gb_CaseId
                    + " AND device_id = " + AndrospyMain.gb_DeviceId;

        } else if (feature.equals("DEFAULT_BROWSER_HISTORY")) {
            query = "SELECT title AS Title, url AS URL, "
                    + "last_visit_date AS 'Last Visit Date', visits AS 'No of Visitis'"
                    + " FROM Browser_History" + " WHERE case_id = " + AndrospyMain.gb_CaseId
                    + " AND device_id = " + AndrospyMain.gb_DeviceId + " AND browser = 'DEFAULTB'";

        } else if (feature.equals("DEFAULT_BOOKMARKS")) {
            query = "SELECT title AS Title, url AS URL, "
                    + "created_date AS 'Creaded Date', modified_date AS 'Modified Date', deleted AS Deleted,"
                    + "account_name AS 'Created By', account_type AS 'Account Type'" + " FROM Androspy_Bookmark"
                    + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = "
                    + AndrospyMain.gb_DeviceId + " AND browser = 'DEFAULTB'";

        } else if (feature.equals("DEFAULT_WEB_FORM_DATA")) {
            query = "SELECT url AS 'URL', name AS 'Parameter Name', value AS 'Parameter Value'"
                    + " FROM WebForm f, WebFormData d"
                    + " WHERE f.case_id = d.case_id AND f.device_id = d.device_id" + " AND d.urlid = f.id"
                    + " AND d.case_id = " + AndrospyMain.gb_CaseId + " AND d.device_id = "
                    + AndrospyMain.gb_DeviceId;

        } else if (feature.equals("DEFAULT_COOKIES")) {
            query = "SELECT host AS 'Host', "
                    + "cookie_name AS 'Cookie Name', cookie_value AS 'Cookie Value', path AS Path, "
                    + "secure AS Secure, httponly AS 'Http Only', created_date AS 'Created Date', "
                    + "expire_date AS 'Expire Date', last_access_date AS 'Last Access Date'"
                    + " FROM Browser_Cookies" + " WHERE case_id = " + AndrospyMain.gb_CaseId
                    + " AND device_id = " + AndrospyMain.gb_DeviceId + " AND browser = 'DEFAULTB'";

        } else if (feature.equals("DEFAULT_WEB_SEARCH")) {
            query = "SELECT search_text AS 'Search Text', " + "search_date AS 'Search Date'" + " FROM WebSearch"
                    + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = "
                    + AndrospyMain.gb_DeviceId + " AND browser = 'DEFAULTB'";

        } else if (feature.equals("CHROME_BROWSER_HISTORY")) {
            query = "SELECT title AS Title, url AS URL, "
                    + "last_visit_date AS 'Last Visit Date', visits AS 'No of Visitis'"
                    + " FROM Browser_History" + " WHERE case_id = " + AndrospyMain.gb_CaseId
                    + " AND device_id = " + AndrospyMain.gb_DeviceId + " AND browser = 'CHROME'";

        } else if (feature.equals("CHROME_COOKIES")) {
            query = "SELECT host AS 'Host', "
                    + "cookie_name AS 'Cookie Name', cookie_value AS 'Cookie Value', path AS Path, "
                    + "secure AS Secure, httponly AS 'Http Only', created_date AS 'Created Date', "
                    + "expire_date AS 'Expire Date', last_access_date AS 'Last Access Date'"
                    + " FROM Browser_Cookies" + " WHERE case_id = " + AndrospyMain.gb_CaseId
                    + " AND device_id = " + AndrospyMain.gb_DeviceId + " AND browser = 'CHROME'";

        } else if (feature.equals("CHROME_WEB_SEARCH")) {
            query = "SELECT search_text AS 'Search Text', " + "search_date AS 'Search Date'" + " FROM WebSearch"
                    + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = "
                    + AndrospyMain.gb_DeviceId + " AND browser = 'CHROME'";

        } else if (feature.equals("CHROME_CREDIT_CARD")) {
            query = "SELECT name AS Name, expire_month AS 'Expire Month', expire_year AS 'Exire Year', "
                    + "modified_date AS 'Modified Date'" + " FROM Browser_Credit_Card" + " WHERE case_id = "
                    + AndrospyMain.gb_CaseId + " AND device_id = " + AndrospyMain.gb_DeviceId
                    + " AND browser = 'CHROME'";

        } else if (feature.equals("Firefox_BROWSER_HISTORY")) {
            query = "SELECT title AS Title, url AS URL, "
                    + "last_visit_date AS 'Last Visit Date', visits AS 'No of Visitis'"
                    + " FROM Browser_History" + " WHERE case_id = " + AndrospyMain.gb_CaseId
                    + " AND device_id = " + AndrospyMain.gb_DeviceId + " AND browser = 'Firefox'";

        } else if (feature.equals("Firefox_BOOKMARKS")) {
            query = "SELECT title AS Title, url AS URL, "
                    + "created_date AS 'Creaded Date', modified_date AS 'Modified Date', deleted AS Deleted,"
                    + "account_name AS 'Created By', account_type AS 'Account Type'" + " FROM Androspy_Bookmark"
                    + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = "
                    + AndrospyMain.gb_DeviceId + " AND browser = 'Firefox'";

        } else if (feature.equals("Firefox_WEB_SEARCH")) {
            query = "SELECT search_text AS 'Search Text', " + "search_date AS 'Search Date'" + " FROM WebSearch"
                    + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = "
                    + AndrospyMain.gb_DeviceId + " AND browser = 'Firefox'";

        } else if (feature.equals("Firefox_COOKIES")) {
            query = "SELECT host AS 'Host', "
                    + "cookie_name AS 'Cookie Name', cookie_value AS 'Cookie Value', path AS Path, "
                    + "secure AS Secure, httponly AS 'Http Only', created_date AS 'Created Date', "
                    + "expire_date AS 'Expire Date', last_access_date AS 'Last Access Date'"
                    + " FROM Browser_Cookies" + " WHERE case_id = " + AndrospyMain.gb_CaseId
                    + " AND device_id = " + AndrospyMain.gb_DeviceId + " AND browser = 'Firefox'";

        } else if (feature == "ALL_CALL_LOG") {
            query = "SELECT contact_no AS 'Contact No', name AS 'Name',"
                    + " date AS 'Contacted Date', duration AS 'Call Duration', "
                    + "countryiso AS 'Country Code', geolocationcode AS 'Geo Location'" + " FROM Event_Log"
                    + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = "
                    + AndrospyMain.gb_DeviceId + " AND logtype = " + 100;

        } else if (feature == "INCOMING_CALLS") {
            query = "SELECT contact_no AS 'Contact No', name AS 'Name',"
                    + " date AS 'Contacted Date', duration AS 'Call Duration', "
                    + "countryiso AS 'Country Code', geolocationcode AS 'Geo Location'" + " FROM Event_Log"
                    + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = "
                    + AndrospyMain.gb_DeviceId + " AND logtype = " + 100 + " AND type = " + 1;

        } else if (feature == "MISSED_CALLS") {
            query = "SELECT contact_no AS 'Contact No', name AS 'Name',"
                    + " date AS 'Contacted Date', duration AS 'Call Duration', "
                    + "countryiso AS 'Country Code', geolocationcode AS 'Geo Location'" + " FROM Event_Log"
                    + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = "
                    + AndrospyMain.gb_DeviceId + " AND logtype = " + 100 + " AND type = " + 3;

        } else if (feature == "CANCELLED_CALLS") {
            query = "SELECT contact_no AS 'Contact No', name AS 'Name',"
                    + " date AS 'Contacted Date', duration AS 'Call Duration', "
                    + "countryiso AS 'Country Code', geolocationcode AS 'Geo Location'" + " FROM Event_Log"
                    + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = "
                    + AndrospyMain.gb_DeviceId + " AND logtype = " + 500;

        } else if (feature == "OUTGOING_CALLS") {
            query = "SELECT contact_no AS 'Contact No', name AS 'Name',"
                    + " date AS 'Contacted Date', duration AS 'Call Duration', "
                    + "countryiso AS 'Country Code', geolocationcode AS 'Geo Location'" + " FROM Event_Log"
                    + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = "
                    + AndrospyMain.gb_DeviceId + " AND logtype = " + 100 + " AND type = " + 2;

        } else if (feature == "ALL_SMS_LOG") {
            query = "SELECT contact_no AS 'Contact No', name AS 'Name'," + " date AS 'Contacted Date', "
                    + "messageid AS 'Message_Id', m_subject AS 'Message Subject', m_content AS 'Message Body', "
                    + "countryiso AS 'Country Code', geolocationcode AS 'Geo Location'" + " FROM Event_Log"
                    + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = "
                    + AndrospyMain.gb_DeviceId + " AND logtype = " + 300;

        } else if (feature == "SMS_INBOX") {
            query = "SELECT contact_no AS 'Contact No', name AS 'Name'," + " date AS 'Contacted Date', "
                    + "messageid AS 'Message_Id', m_subject AS 'Message Subject', m_content AS 'Message Body', "
                    + "countryiso AS 'Country Code', geolocationcode AS 'Geo Location'" + " FROM Event_Log"
                    + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = "
                    + AndrospyMain.gb_DeviceId + " AND logtype = " + 300 + " AND type = " + 1;

        } else if (feature == "SMS_OUTBOX") {
            query = "SELECT contact_no AS 'Contact No', name AS 'Name'," + " date AS 'Contacted Date', "
                    + "messageid AS 'Message_Id', m_subject AS 'Message Subject', m_content AS 'Message Body', "
                    + "countryiso AS 'Country Code', geolocationcode AS 'Geo Location'" + " FROM Event_Log"
                    + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = "
                    + AndrospyMain.gb_DeviceId + " AND logtype = " + 300 + " AND type != " + 1;

        } else if (feature == "ALL_MMS_LOG") {
            query = "SELECT contact_no AS 'Contact No', name AS 'Name'," + " date AS 'Contacted Date', "
                    + "messageid AS 'Message_Id', m_subject AS 'Message Subject', m_content AS 'Message Body', "
                    + "countryiso AS 'Country Code', geolocationcode AS 'Geo Location'" + " FROM Event_Log"
                    + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = "
                    + AndrospyMain.gb_DeviceId + " AND logtype = " + 200;

        } else if (feature == "MMS_INBOX") {
            query = "SELECT contact_no AS 'Contact No', name AS 'Name'," + " date AS 'Contacted Date', "
                    + "messageid AS 'Message_Id', m_subject AS 'Message Subject', m_content AS 'Message Body', "
                    + "countryiso AS 'Country Code', geolocationcode AS 'Geo Location'" + " FROM Event_Log"
                    + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = "
                    + AndrospyMain.gb_DeviceId + " AND logtype = " + 200 + " AND type = " + 1;

        } else if (feature == "MMS_OUTBOX") {
            query = "SELECT contact_no AS 'Contact No', name AS 'Name'," + " date AS 'Contacted Date', "
                    + "messageid AS 'Message_Id', m_subject AS 'Message Subject', m_content AS 'Message Body', "
                    + "countryiso AS 'Country Code', geolocationcode AS 'Geo Location'" + " FROM Event_Log"
                    + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = "
                    + AndrospyMain.gb_DeviceId + " AND logtype = " + 200 + " AND type != " + 1;

        } else if (feature == "Wi-Fi Access Points") {
            query = "SELECT ssid AS 'SSID', password AS 'Password', key_mgmt AS 'Key Management'"
                    + " FROM Wifi_Info" + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = "
                    + AndrospyMain.gb_DeviceId;

        } else if (feature.equals("Wi-Fi Access Points")) {
            query = "SELECT ssid AS 'SSID', password AS 'Password', key_mgmt AS 'Key Management'"
                    + " FROM Wifi_Info" + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = "
                    + AndrospyMain.gb_DeviceId;

        } else if (feature == "BT_USED") {
            query = "SELECT device_address AS 'Target Device BT Address', mimetype AS 'MIME Type', "
                    + " in_file_name AS 'File Name', totalbytes AS 'File Size', location AS Location, direction AS Direction, visibility AS Visibility, confirm AS Confirm,"
                    + " status AS 'Transfer Status', date AS 'Transfer Date', scanned As Scanned"
                    + " FROM Bluetooth_Tranfer" + " WHERE case_id = " + AndrospyMain.gb_CaseId
                    + " AND device_id = " + AndrospyMain.gb_DeviceId;

        } else if (feature == "BT_SEEN") {
            query = "SELECT bmac AS 'Bluetooth Address',"
                    + " device_name AS 'Device Name', seen_date AS 'Last Seen Date', 'used_date' AS 'Last_Paired_Date'"
                    + " FROM Bluetooth_Device" + " WHERE case_id = " + AndrospyMain.gb_CaseId
                    + " AND device_id = " + AndrospyMain.gb_DeviceId;

        } else if (feature == "Skype Account") {
            System.out.println("Skype Account");
            query = "SELECT skypename, fullname, birthday, country, city reg_date, gender"
                    + " FROM Skype_Account" + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = "
                    + AndrospyMain.gb_DeviceId;

        } else if (feature == "Skype Contacts") {
            System.out.println("Skype Contacts");
            query = "SELECT skypename, fullname, birthday, displayname, country, city, gender, phone"
                    + " FROM Skype_Contacts" + " WHERE case_id = " + AndrospyMain.gb_CaseId
                    + " AND device_id = " + AndrospyMain.gb_DeviceId;

        } else if (feature == "Skype Calls") {
            System.out.println("Skype Calls");
            query = "SELECT identity, display_name, call_duration, start_time_stamp" + " FROM Skype_Call"
                    + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = "
                    + AndrospyMain.gb_DeviceId;

        } else if (feature == "Skype Messages") {
            System.out.println("Skype Messages");
            query = "SELECT author, from_display_name, dialog_partner, message, time_stamp"
                    + " FROM Skype_Message" + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = "
                    + AndrospyMain.gb_DeviceId;

        }

        if (query != ("")) {
            if (!bflagall) {
                query += " AND favourite = " + 1;
            }

            System.out.println("query: " + query);

            ResultSet rs = stmt.executeQuery(query);
            ResultSetMetaData rsmeta = rs.getMetaData();
            int colcount = rsmeta.getColumnCount();
            PdfPTable pdftable = new PdfPTable(colcount);
            pdftable.setWidthPercentage(100 / colcount);
            pdftable.setTotalWidth(527);
            pdftable.setLockedWidth(true);

            for (int i = 1; i <= colcount; i++) {
                PdfPCell c1 = new PdfPCell(new Phrase(rsmeta.getColumnLabel(i)));
                c1.setHorizontalAlignment(Element.ALIGN_CENTER);
                pdftable.addCell(c1);
            }
            pdftable.setHeaderRows(1);

            while (rs.next()) {
                for (int i = 1; i <= colcount; i++) {
                    System.out.println("add table cell report " + rs.getString(i));
                    pdftable.addCell(rs.getString(i));
                }
            }

            subpara.add(pdftable);
        }

    } catch (SQLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:lk.score.androphsy.report.ReportPdf.java

License:Open Source License

private void addTitlePage(Document document) {
    String creator_name = "";
    try {//from  w ww.ja  v  a2 s.c  o  m
        Connection con = new ConnectDb().getConnection();
        Statement stmt = con.createStatement();
        ResultSet rs = stmt.executeQuery("SELECT first_name, last_name FROM Androspy_User WHERE user_name = '"
                + AndrospyMain.gb_username + "'");
        while (rs.next()) {
            creator_name = rs.getString("first_name") + " " + rs.getString("last_name");
        }
    } catch (SQLException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }
    Paragraph preface = new Paragraph();
    addEmptyLine(preface, 1);

    Paragraph title = new Paragraph("ANDROSPY SOFTWARE", TitleFont);
    addEmptyLine(title, 1);
    title.add(new Paragraph("Report Genereated By: " + creator_name));
    title.add(new Paragraph("Date: " + gen_date));
    title.setAlignment(Paragraph.ALIGN_CENTER);

    preface.add(title);
    addEmptyLine(preface, 2);

    preface.add(new Paragraph("Case Basic Detail:"));
    addEmptyLine(preface, 1);

    createTableRowFormat(preface, "CaseInfo");

    try {
        document.add(preface);
    } catch (DocumentException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    document.newPage();
}

From source file:lk.score.androphsy.report.ReportPdf.java

License:Open Source License

private void createTableRowFormat(Paragraph preface, String feature) {
    try {/*from  w w w  .java  2  s  . c  o m*/
        String query = "";
        Connection conn = new ConnectDb().getConnection();
        Statement stmt = conn.createStatement();

        if (feature == "CaseInfo") {
            query = "SELECT case_id AS 'Case ID', case_name AS 'Case Name', investigator_id AS 'Investigatort', IFNULL(analyst_id, '') as 'Analyst' "
                    + "FROM Androspy_Case " + "WHERE case_id = " + AndrospyMain.gb_CaseId;
        } else if (feature == "DeviceBasicInfo") {
            query = "SELECT IFNULL(device_name, '') AS 'Device Name', IFNULL(model, '') AS 'Model', IFNULL(manufacturer, '') AS 'Manufacturer', IFNULL(os, '') AS OS, IFNULL(build_number, '') AS 'Build Number', IFNULL(sw_number, '') AS 'Software Number', IFNULL(serial_no,'') As 'Serial No'"
                    + " FROM Androspy_Device" + " WHERE case_id = " + AndrospyMain.gb_CaseId
                    + " AND device_id = " + AndrospyMain.gb_DeviceId;
        }

        System.out.println(query);
        ResultSet rs = stmt.executeQuery(query);
        ResultSetMetaData rsmeta = rs.getMetaData();
        int colcount = rsmeta.getColumnCount();
        PdfPTable pdftable = new PdfPTable(2);

        while (rs.next()) {
            for (int i = 1; i <= colcount; i++) {
                String value = rs.getString(i).equals(null) ? "" : rs.getString(i);
                PdfPCell c1 = new PdfPCell(new Phrase(rsmeta.getColumnLabel(i) + ":"));
                PdfPCell c2 = new PdfPCell(new Phrase(value));
                c1.setBorder(Rectangle.NO_BORDER);
                c2.setBorder(Rectangle.NO_BORDER);
                pdftable.addCell(c1);
                pdftable.addCell(c2);
            }
        }

        preface.add(pdftable);

    } catch (SQLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}

From source file:lk.score.androphsy.report.ReportPdf.java

License:Open Source License

private void addEmptyLine(Paragraph paragraph, int count) {
    for (int i = 0; i < count; i++) {
        paragraph.add(new Paragraph(" "));
    }//from   www. j av a2s  . c  o m

}

From source file:Login.NewJFrame.java

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
    try {//from   w  ww . j  av  a 2s.c om
        int amount = new Integer(jTextField2.getText());
        String Recipient_name = jTextField1.getText();
        System.out.println("amout" + amount + "name" + Recipient_name);
        Class.forName("com.mysql.jdbc.Driver");
        Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/mysql?digitalCoin -peerdb",
                "root", "root");
        Statement stmt = (Statement) con.createStatement();
        String insert = "INSERT INTO digitalCoin.Transaction (Recipient_name, Sender_name,amount) VALUES('"
                + Recipient_name + "','" + this.sender_name + "','" + amount + "')";
        stmt.executeUpdate(insert);
        JOptionPane.showMessageDialog(null, "Transaction Completed Successfully!");

        //PDF generation
        OutputStream file = new FileOutputStream(new File(Recipient_name + "SamplePDF.pdf"));
        Document document = new Document();
        PdfWriter.getInstance(document, file);

        document.open();
        //  document.add(new Paragraph("First iText PDF"));
        //  document.add(new Paragraph(new Date().toString()));

        /* document.addAuthor("Ameya");
         document.addCreationDate();
         document.addCreator("JavaBeat");
         document.addTitle("Transaction");
            */
        Chunk chunk = new Chunk("Recipient's Name: " + Recipient_name);
        // chunk.setUnderline(+1f,-2f);//1st co-ordinate is for line width,2nd is space between
        Chunk chunk1 = new Chunk("Sender's Name: " + this.sender_name);
        Chunk chunk2 = new Chunk("Amount: " + amount);
        // chunk1.setUnderline(+4f,-8f);
        // chunk1.setBackground(new BaseColor (17, 46, 193));  
        document.add(chunk);
        document.add(chunk1);
        document.add(chunk2);
        //Create Paragraph
        //      Paragraph paragraph = new Paragraph("Title 1",new Font(Font.FontFamily.TIMES_ROMAN, 18,
        //          Font.BOLD));
        Paragraph paragraph = new Paragraph();
        //New line
        paragraph.add(new Paragraph(" "));
        //paragraph.add("Test Paragraph");
        paragraph.add(new Paragraph(" "));
        document.add(paragraph);

        document.close();
        file.close();

        String currentDir = System.getProperty("user.dir");
        String current = currentDir + Recipient_name + "/SamplePDF.pdf";
        System.out.println("Current dir using System:" + current);
        File file_read = new File(currentDir);
        if (file_read.exists()) {
            Desktop desktop = Desktop.getDesktop();
            if (desktop.isSupported(Desktop.Action.OPEN)) {
                // if (Desktop.isDesktopSupported()) {
                Desktop.getDesktop().open(file_read);
            } else {
                System.out.println("Awt Desktop is not supported!");
            }
        } else {

            System.out.println("File is not exists");

        }

        System.out.println("Done");
        File directory = new File(currentDir);
        File file_trans = new File(directory, "Transaction");

        if (!file_trans.exists())
            file_trans.createNewFile();
        FileWriter fileWritter = new FileWriter(file_trans, true);
        BufferedWriter bufferWritter = new BufferedWriter(fileWritter);
        bufferWritter.write(Recipient_name + ":" + amount);
        bufferWritter.close();

        byte[] key = this.hash;
        Key aesKey = new SecretKeySpec(key, "AES");
        Cipher cipher = Cipher.getInstance("AES");

        cipher.init(Cipher.DECRYPT_MODE, aesKey);

        File dir = new File(currentDir + "/Keys/");
        File file_private = new File(dir, "privatekey.txt");

        FileInputStream fileo = new FileInputStream(file_private);
        ObjectInputStream objos = new ObjectInputStream(fileo);
        Object obj = objos.readObject();

        byte[] encrypted = (byte[]) obj;
        cipher.init(Cipher.DECRYPT_MODE, aesKey);
        String decrypted = new String(cipher.doFinal(encrypted));

        Signature tosign = Signature.getInstance("DSA");
        byte[] val = decrypted.getBytes();
        KeyFactory keyFactory = KeyFactory.getInstance("DSA");
        //   ByteArrayInputStream os = new ByteArrayInputStream(decrypted);
        // PrivateKey privatekey = (PrivateKey)val;
        SecretKeySpec sks = new SecretKeySpec(val, "DSA");
        PrivateKey privatekey1 = (PrivateKey) sks;
        //PrivateKey privatekey = keyFactory.generatePrivate(new PKCS8EncodedKeySpec(val));
        tosign.initSign(privatekey1);
        //  os.close();

        FileInputStream fileis = new FileInputStream(currentDir + "/SamplePDF.pdf"); // open data file named " message "
        BufferedInputStream buf = new BufferedInputStream(fileis);
        byte[] buffer = new byte[1024];
        int len;
        while ((len = buf.read(buffer)) >= 0) {
            tosign.update(buffer, 0, len);
        }
        buf.close();
        fileis.close();
        byte[] realsig = tosign.sign();
        FileOutputStream fos = new FileOutputStream(Recipient_name + "/signed.pdf"); // storing the signed data in the file named "signed"
        fos.write(realsig);
        fos.close();

    } catch (Exception e) {
        e.printStackTrace();
    }
    // TODO add your handling code here:
}

From source file:Login.ReceiverCertificate.java

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
    try {//from   www . jav  a  2  s.  c om
        String Recipient_name = jTextField3.getText();
        int amount = new Integer(jTextField4.getText());
        OutputStream file = new FileOutputStream(new File(Recipient_name + "Response.pdf"));
        Document document = new Document();
        PdfWriter.getInstance(document, file);

        document.open();
        //  document.add(new Paragraph("First iText PDF"));
        //  document.add(new Paragraph(new Date().toString()));

        /* document.addAuthor("Ameya");
         document.addCreationDate();
         document.addCreator("JavaBeat");
         document.addTitle("Transaction");
            */
        Paragraph paragraph = new Paragraph();
        Chunk chunk = new Chunk("Recipient's Name: " + Recipient_name);
        paragraph.add(new Paragraph(" "));
        // chunk.setUnderline(+1f,-2f);//1st co-ordinate is for line width,2nd is space between
        Chunk chunk1 = new Chunk("Sender's Name: " + this.sender_name);
        paragraph.add(new Paragraph(" "));
        Chunk chunk2 = new Chunk("Amount: " + amount);
        paragraph.add(new Paragraph(" "));
        Chunk chunk3 = new Chunk("I accept the above transaction");
        paragraph.add(new Paragraph(" "));
        // chunk1.setUnderline(+4f,-8f);
        // chunk1.setBackground(new BaseColor (17, 46, 193));  
        document.add(chunk);
        document.add(chunk1);
        document.add(chunk2);
        document.add(chunk3);
        //     Font.BOLD));
        paragraph.add(new Paragraph(" "));
        //paragraph.add("Test Paragraph");
        paragraph.add(new Paragraph(" "));
        document.add(paragraph);

        document.close();
        file.close();

        String currentDir = System.getProperty("user.dir");
        String current = currentDir + Recipient_name + "/SamplePDF.pdf";
        System.out.println("Current dir using System:" + current);
        File file_read = new File(currentDir);
        if (file_read.exists()) {
            Desktop desktop = Desktop.getDesktop();
            if (desktop.isSupported(Desktop.Action.OPEN)) {
                // if (Desktop.isDesktopSupported()) {
                Desktop.getDesktop().open(file_read);
            } else {
                System.out.println("Awt Desktop is not supported!");
            }
        } else {

            System.out.println("File is not exists");

        }

        System.out.println("Done");
        File directory = new File(currentDir);
        File file_trans = new File(directory, "Transaction");

        if (!file_trans.exists())
            file_trans.createNewFile();
        FileWriter fileWritter = new FileWriter(file_trans, true);
        BufferedWriter bufferWritter = new BufferedWriter(fileWritter);
        bufferWritter.write(Recipient_name + ":" + amount);
        bufferWritter.close();

    } catch (NumberFormatException | DocumentException | IOException e) {
    }

}

From source file:Login.ReceiverCertificate.java

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
    // TODO add your handling code here:
    try {/*from  w  w w.j  av a2 s . c o  m*/
        String Recipient_name = jTextField3.getText();

        int amount = new Integer(jTextField4.getText());
        String currentDir = System.getProperty("user.dir");
        String current = currentDir + Recipient_name + "/SamplePDF.pdf";
        System.out.println("Current dir using System:" + current);
        File file_read = new File(currentDir);
        if (file_read.exists()) {
            Desktop desktop = Desktop.getDesktop();
            if (desktop.isSupported(Desktop.Action.OPEN)) {
                // if (Desktop.isDesktopSupported()) {
                Desktop.getDesktop().open(file_read);
            } else {
                System.out.println("Awt Desktop is not supported!");
            }
        } else {

            System.out.println("File is not exists");

        }

        System.out.println("Done");

        OutputStream file = new FileOutputStream(new File(Recipient_name + "Response.pdf"));
        Document document = new Document();
        PdfWriter.getInstance(document, file);

        document.open();
        //  document.add(new Paragraph("First iText PDF"));
        //  document.add(new Paragraph(new Date().toString()));

        /* document.addAuthor("Ameya");
         document.addCreationDate();
         document.addCreator("JavaBeat");
         document.addTitle("Transaction");
            */
        Paragraph paragraph = new Paragraph();
        Chunk chunk = new Chunk("Recipient's Name: " + Recipient_name);
        paragraph.add(new Paragraph(" "));
        // chunk.setUnderline(+1f,-2f);//1st co-ordinate is for line width,2nd is space between
        Chunk chunk1 = new Chunk("Sender's Name: " + this.sender_name);
        paragraph.add(new Paragraph(" "));
        Chunk chunk2 = new Chunk("Amount: " + amount);
        paragraph.add(new Paragraph(" "));
        Chunk chunk3 = new Chunk("Sorry, I dont want to continue this above transaction");
        paragraph.add(new Paragraph(" "));
        // chunk1.setUnderline(+4f,-8f);
        // chunk1.setBackground(new BaseColor (17, 46, 193));  
        document.add(chunk);
        document.add(chunk1);
        document.add(chunk2);
        document.add(chunk3);
        //     Font.BOLD));
        paragraph.add(new Paragraph(" "));
        //paragraph.add("Test Paragraph");
        paragraph.add(new Paragraph(" "));
        document.add(paragraph);

        document.close();
        file.close();
    } //GEN-LAST:event_jButton3ActionPerformed
    catch (Exception e) {
    }
}