Example usage for com.itextpdf.text Chunk Chunk

List of usage examples for com.itextpdf.text Chunk Chunk

Introduction

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

Prototype

public Chunk(final DrawInterface separator) 

Source Link

Document

Creates a separator Chunk.

Usage

From source file:eu.aniketos.wp1.ststool.report.pdfgenerator.AbstractContentFactory.java

License:Open Source License

protected PdfPCell getHeaderCell(String[] header) {

    Phrase p = new Phrase();
    p.setFont(TABLE_HEADER);//w w  w  .  j a va  2  s.  co m
    for (String s : header) {
        p.add(new Chunk(s));
        p.add(Chunk.NEWLINE);
    }
    PdfPCell cell = new PdfPCell(p);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setBorder(Rectangle.BOTTOM | Rectangle.TOP);
    cell.setBorderWidthTop(1.5f);
    cell.setBorderWidthBottom(1.5f);
    cell.setPaddingBottom(7);
    cell.setPaddingTop(2);
    return cell;
}

From source file:file.PDFWriter.java

License:Open Source License

/**
 * Add the page number and line to the PDF
 * @param splitLines the array of line segments to print
 * @param page the page number the line was on
 * @throws DocumentException //from  w ww  .  jav a 2  s.  co m
 */
private void addLineTableToPDF(String[] splitLines, String page) throws DocumentException {
    PdfPTable lineTable = new PdfPTable(2);
    PdfPCell pageCell = new PdfPCell(new Paragraph("Page: " + page, lineFont));
    pageCell.setPadding(20);
    pageCell.setPaddingLeft(0);
    pageCell.setBorder(PdfPCell.NO_BORDER);
    Chunk lineSegment1 = new Chunk(splitLines[0]);
    lineSegment1.setFont(lineFont);
    Chunk error1 = new Chunk(splitLines[1]);
    error1.setFont(lineFontBold);
    Chunk lineSegment2 = new Chunk(splitLines[2]);
    lineSegment2.setFont(lineFont);
    Chunk error2 = new Chunk(splitLines[3]);
    error2.setFont(lineFontBold);
    Chunk lineSegment3 = new Chunk(splitLines[4]);
    lineSegment3.setFont(lineFont);

    Phrase line = new Phrase(lineSegment1);
    line.add(error1);
    line.add(lineSegment2);
    line.add(error2);
    line.add(lineSegment3);

    PdfPCell lineCell = new PdfPCell(line);
    lineCell.setPadding(20);
    lineCell.setBorder(PdfPCell.NO_BORDER);
    lineTable.setWidthPercentage(100);
    lineTable.setWidths(new int[] { 2, 10 });
    lineTable.setSpacingBefore(1f);
    lineTable.setSpacingAfter(1f);

    lineTable.addCell(pageCell);
    lineTable.addCell(lineCell);
    document.add(lineTable);
    document.add(Chunk.NEWLINE);
}

From source file:fll.util.PdfUtils.java

License:Open Source License

/**
 * Create a header cell for a table./* ww w  .ja va  2s.  c o  m*/
 */
public static PdfPCell createHeaderCell(final String text) throws BadElementException {
    final Chunk chunk = new Chunk(text);
    chunk.getFont().setStyle(Font.BOLD);
    final PdfPCell cell = createBasicCell(chunk);

    return cell;
}

From source file:fll.util.PdfUtils.java

License:Open Source License

/**
 * Create a table cell with the specified text.
 *//*from   w  ww.  j  ava2  s .  c  om*/
public static PdfPCell createCell(final String text) throws BadElementException {
    final PdfPCell cell = createBasicCell(new Chunk(text));
    return cell;
}

From source file:fll.web.report.FinalComputedScores.java

License:Open Source License

/**
 * @throws ParseException/*from www  . ja  v a2s  .c o  m*/
 */
private void writeColumnHeaders(final TournamentSchedule schedule, final double[] weights,
        final ScoreCategory[] subjectiveCategories, final float[] relativeWidths,
        final ChallengeDescription challengeDescription, final PdfPTable divTable) throws ParseException {

    // /////////////////////////////////////////////////////////////////////
    // Write the table column headers
    // /////////////////////////////////////////////////////////////////////
    // team information
    final PdfPCell organizationCell = new PdfPCell(new Phrase("Organization", ARIAL_8PT_BOLD));
    organizationCell.setBorder(0);
    organizationCell.setVerticalAlignment(com.itextpdf.text.Element.ALIGN_MIDDLE);
    divTable.addCell(organizationCell);

    // judging group
    if (null != schedule) {
        final Paragraph judgingGroup = new Paragraph("Judging", ARIAL_8PT_BOLD);
        judgingGroup.add(Chunk.NEWLINE);
        judgingGroup.add(new Chunk("Group"));
        final PdfPCell osCell = new PdfPCell(judgingGroup);
        osCell.setBorder(0);
        osCell.setHorizontalAlignment(com.itextpdf.text.Element.ALIGN_CENTER);
        osCell.setVerticalAlignment(com.itextpdf.text.Element.ALIGN_MIDDLE);
        divTable.addCell(osCell);
    }

    divTable.addCell(""); // weight/raw&scaled

    for (int cat = 0; cat < subjectiveCategories.length; cat++) {
        if (weights[cat] > 0.0) {
            final String catTitle = subjectiveCategories[cat].getTitle();

            final Paragraph catPar = new Paragraph(catTitle, ARIAL_8PT_BOLD);
            final PdfPCell catCell = new PdfPCell(catPar);
            catCell.setBorder(0);
            catCell.setHorizontalAlignment(com.itextpdf.text.Element.ALIGN_CENTER);
            catCell.setVerticalAlignment(com.itextpdf.text.Element.ALIGN_MIDDLE);
            divTable.addCell(catCell);
        }
    }

    final Paragraph perfPar = new Paragraph("Performance", ARIAL_8PT_BOLD);
    final PdfPCell perfCell = new PdfPCell(perfPar);
    perfCell.setBorder(0);
    perfCell.setHorizontalAlignment(com.itextpdf.text.Element.ALIGN_CENTER);
    perfCell.setVerticalAlignment(com.itextpdf.text.Element.ALIGN_MIDDLE);
    divTable.addCell(perfCell);

    final Paragraph overallScore = new Paragraph("Overall", ARIAL_8PT_BOLD);
    overallScore.add(Chunk.NEWLINE);
    overallScore.add(new Chunk("Score"));
    final PdfPCell osCell = new PdfPCell(overallScore);
    osCell.setBorder(0);
    osCell.setHorizontalAlignment(com.itextpdf.text.Element.ALIGN_CENTER);
    osCell.setVerticalAlignment(com.itextpdf.text.Element.ALIGN_MIDDLE);
    divTable.addCell(osCell);

    // /////////////////////////////////////////////////////////////////////
    // Write a table row with the relative weights of the subjective scores
    // /////////////////////////////////////////////////////////////////////

    final PdfPCell teamCell = new PdfPCell(new Phrase("Team # / Team Name", ARIAL_8PT_BOLD));
    teamCell.setBorder(0);
    teamCell.setVerticalAlignment(com.itextpdf.text.Element.ALIGN_MIDDLE);
    divTable.addCell(teamCell);

    final Paragraph wPar = new Paragraph("Weight:", ARIAL_8PT_NORMAL);
    final PdfPCell wCell = new PdfPCell(wPar);
    if (null != schedule) {
        wCell.setColspan(2);
    }
    wCell.setBorder(0);
    wCell.setHorizontalAlignment(com.itextpdf.text.Element.ALIGN_RIGHT);
    divTable.addCell(wCell);

    final PdfPCell[] wCells = new PdfPCell[subjectiveCategories.length];
    final Paragraph[] wPars = new Paragraph[subjectiveCategories.length];
    for (int cat = 0; cat < subjectiveCategories.length; cat++) {
        if (weights[cat] > 0.0) {
            wPars[cat] = new Paragraph(Double.toString(weights[cat]), ARIAL_8PT_NORMAL);
            wCells[cat] = new PdfPCell(wPars[cat]);
            wCells[cat].setBorder(0);
            wCells[cat].setHorizontalAlignment(com.itextpdf.text.Element.ALIGN_CENTER);
            divTable.addCell(wCells[cat]);
        }
    }

    final PerformanceScoreCategory performanceElement = challengeDescription.getPerformance();
    final double perfWeight = performanceElement.getWeight();
    final Paragraph perfWeightPar = new Paragraph(Double.toString(perfWeight), ARIAL_8PT_NORMAL);
    final PdfPCell perfWeightCell = new PdfPCell(perfWeightPar);
    perfWeightCell.setHorizontalAlignment(com.itextpdf.text.Element.ALIGN_CENTER);
    perfWeightCell.setBorder(0);
    divTable.addCell(perfWeightCell);

    divTable.addCell("");

    PdfPCell blankCell = new PdfPCell();
    blankCell.setBorder(0);
    blankCell.setBorderWidthBottom(1.0f);
    blankCell.setColspan(relativeWidths.length);
    divTable.addCell(blankCell);

    // Cause the first 4 rows to be repeated on
    // each page - 1 row for box header, 2 rows text headers and 1 for
    // the horizontal line.
    divTable.setHeaderRows(4);
}

From source file:fll.web.report.PerformanceScoreReport.java

License:Open Source License

@Override
protected void processRequest(HttpServletRequest request, HttpServletResponse response,
        ServletContext application, HttpSession session) throws IOException, ServletException {
    Connection connection = null;
    try {/*ww w.  j  a va2 s. c  o m*/
        final DataSource datasource = ApplicationAttributes.getDataSource(application);
        connection = datasource.getConnection();

        final ChallengeDescription challengeDescription = ApplicationAttributes
                .getChallengeDescription(application);

        final int tournamentId = Queries.getCurrentTournament(connection);
        final Tournament tournament = Tournament.findTournamentByID(connection, tournamentId);
        final int numSeedingRounds = TournamentParameters.getNumSeedingRounds(connection,
                tournament.getTournamentID());

        // create simple doc and write to a ByteArrayOutputStream
        final Document document = new Document(PageSize.LETTER, 36, 36, 72, 36);
        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
        final PdfWriter writer = PdfWriter.getInstance(document, baos);
        final PerformanceScoreReportPageEventHandler headerHandler = new PerformanceScoreReportPageEventHandler(
                HEADER_FONT, REPORT_TITLE, challengeDescription.getTitle(), tournament.getName());
        writer.setPageEvent(headerHandler);

        document.open();

        document.addTitle(REPORT_TITLE);

        final Map<Integer, TournamentTeam> teams = Queries.getTournamentTeams(connection);
        if (teams.isEmpty()) {
            final Paragraph para = new Paragraph();
            para.add(Chunk.NEWLINE);
            para.add(new Chunk("No teams in the tournament."));
            document.add(para);
        } else {
            for (Map.Entry<Integer, TournamentTeam> entry : teams.entrySet()) {
                headerHandler.setTeamInfo(entry.getValue());

                outputTeam(connection, document, tournament, challengeDescription, numSeedingRounds,
                        entry.getValue());

                document.add(Chunk.NEXTPAGE);
            }
        }

        document.close();

        // setting some response headers
        response.setHeader("Expires", "0");
        response.setHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0");
        response.setHeader("Pragma", "public");
        // setting the content type
        response.setContentType("application/pdf");
        response.setHeader("Content-Disposition", "filename=performanceScoreReport.pdf");
        // the content length is needed for MSIE!!!
        response.setContentLength(baos.size());
        // write ByteArrayOutputStream to the ServletOutputStream
        final ServletOutputStream out = response.getOutputStream();
        baos.writeTo(out);
        out.flush();

    } catch (final SQLException e) {
        LOG.error(e, e);
        throw new RuntimeException(e);
    } catch (final DocumentException e) {
        LOG.error(e, e);
        throw new RuntimeException(e);
    } finally {
        SQLFunctions.close(connection);
    }
}

From source file:fll.web.report.PerformanceScoreReport.java

License:Open Source License

private void outputTeam(final Connection connection, final Document document, final Tournament tournament,
        final ChallengeDescription challenge, final int numSeedingRounds, final TournamentTeam team)
        throws DocumentException, SQLException {
    // output first row for header
    final PdfPTable table = new PdfPTable(numSeedingRounds + 1);
    table.addCell("");
    for (int runNumber = 1; runNumber <= numSeedingRounds; ++runNumber) {

        table.addCell(new Phrase("Run " + runNumber, HEADER_FONT));
    }//from  w ww  .ja v  a2s  . c  o  m

    final PerformanceScoreCategory performance = challenge.getPerformance();

    final TeamScore[] scores = getScores(connection, tournament, team, numSeedingRounds);
    for (final AbstractGoal goal : performance.getGoals()) {
        final double bestScore = bestScoreForGoal(scores, goal);

        final StringBuilder goalTitle = new StringBuilder();
        goalTitle.append(goal.getTitle());
        if (goal.isComputed()) {
            goalTitle.append(" (computed)");
        }
        table.addCell(new Phrase(goalTitle.toString(), HEADER_FONT));

        for (final TeamScore score : scores) {
            if (!score.scoreExists() || score.isBye() || score.isNoShow()) {
                table.addCell("");
            } else {
                final double computedValue = goal.getComputedScore(score);

                final StringBuilder cellStr = new StringBuilder();
                if (!goal.isComputed()) {
                    if (goal.isEnumerated()) {
                        final String enumValue = score.getEnumRawScore(goal.getName());
                        boolean found = false;
                        for (final EnumeratedValue ev : goal.getValues()) {
                            if (ev.getValue().equals(enumValue)) {
                                cellStr.append(ev.getTitle() + " -> ");
                                found = true;
                                break;
                            }
                        }
                        if (!found) {
                            LOG.warn("Could not find enumerated title for " + enumValue);
                            cellStr.append(enumValue + " -> ");
                        }
                    } else {
                        if (goal.isYesNo()) {
                            if (FP.greaterThan(score.getRawScore(goal.getName()), 0,
                                    ChallengeParser.INITIAL_VALUE_TOLERANCE)) {
                                cellStr.append("Yes -> ");
                            } else {
                                cellStr.append("No -> ");
                            }
                        } else {
                            final double rawValue = goal.getRawScore(score);
                            cellStr.append(Utilities.NUMBER_FORMAT_INSTANCE.format(rawValue) + " -> ");
                        }
                    } // not enumerated
                } // not computed

                cellStr.append(Utilities.NUMBER_FORMAT_INSTANCE.format(computedValue));
                if (FP.equals(bestScore, computedValue, ChallengeParser.INITIAL_VALUE_TOLERANCE)) {
                    table.addCell(new Phrase(cellStr.toString(), BEST_SCORE_FONT));
                } else {
                    table.addCell(new Phrase(cellStr.toString(), SCORE_FONT));
                }
            } // exists, non-bye, non-no show

        } // foreach score
    } // foreach goal

    // totals
    table.addCell(new Phrase("Total", HEADER_FONT));
    final double bestTotalScore = bestTotalScore(performance, scores);
    for (final TeamScore score : scores) {
        if (!score.scoreExists()) {
            table.addCell("");
        } else if (score.isBye()) {
            table.addCell(new Phrase("Bye", SCORE_FONT));
        } else if (score.isNoShow()) {
            table.addCell(new Phrase("No Show", SCORE_FONT));
        } else {
            final double totalScore = performance.evaluate(score);

            if (FP.equals(bestTotalScore, totalScore, ChallengeParser.INITIAL_VALUE_TOLERANCE)) {
                table.addCell(new Phrase(Utilities.NUMBER_FORMAT_INSTANCE.format(totalScore), BEST_SCORE_FONT));
            } else {
                table.addCell(new Phrase(Utilities.NUMBER_FORMAT_INSTANCE.format(totalScore), SCORE_FONT));
            }
        }

    }

    document.add(table);

    final Paragraph definitionPara = new Paragraph();
    definitionPara.add(Chunk.NEWLINE);
    definitionPara.add(new Chunk("The team's top score for each goal and overall are in bold."));
    document.add(definitionPara);
}

From source file:Login.NewJFrame.java

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
    try {/*from  w  w w . ja  v a2 s .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 {/*  www  .  ja  va  2s . 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  ww . j a v a  2 s  . c om
        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) {
    }
}