Example usage for com.itextpdf.text Chapter setNumberDepth

List of usage examples for com.itextpdf.text Chapter setNumberDepth

Introduction

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

Prototype

public void setNumberDepth(final int numberDepth) 

Source Link

Document

Sets the depth of the sectionnumbers that will be shown preceding the title.

Usage

From source file:nl.ctmm.trait.proteomics.qcviewer.utils.ReportPDFExporter.java

License:Apache License

/**
 * Export a report to a pdf file./*from w w  w  .  j a  va  2  s  .  com*/
 *
 * @param allMetricsMap         map of all QC metrics - keys and description.
 * @param selectedReports       the report units to be exported in PDF format.
 * @param preferredPDFDirectory the directory the pdf document should be exported to.
 * @return Path of the created PDF document if it is successfully created - otherwise return empty string.
 */
public static String exportReportUnitInPDFFormat(final Map<String, String> allMetricsMap,
        final ArrayList<ReportUnit> selectedReports, final String preferredPDFDirectory) {
    //Obtain current timestamp. 
    final java.util.Date date = new java.util.Date();
    final String timestampString = CREATION_DATE_TIME_FORMAT.format(date);
    //Replace all occurrences of special character ':' from time stamp since ':' is not allowed in filename. 
    final String filenameTimestamp = timestampString.replace(':', '-');
    //Instantiation of document object - landscape format using the rotate() method
    final Document document = new Document(PageSize.A4.rotate(), PDF_PAGE_MARGIN, PDF_PAGE_MARGIN,
            PDF_PAGE_MARGIN, PDF_PAGE_MARGIN);
    final String pdfFileName = preferredPDFDirectory + "\\QCReports-" + filenameTimestamp + FILE_TYPE_EXTENSION;
    try {
        //Creation of PdfWriter object
        //            PdfWriter writer;
        //            writer = PdfWriter.getInstance(document, new FileOutputStream(pdfFileName));
        document.open();
        for (ReportUnit reportUnit : selectedReports) {
            //New page for each report. 
            document.newPage();
            //Creation of chapter object
            final Paragraph pageTitle = new Paragraph(
                    String.format(PDF_PAGE_TITLE, reportUnit.getMsrunName(), timestampString),
                    Constants.PDF_TITLE_FONT);
            pageTitle.setAlignment(Element.ALIGN_CENTER);
            final Chapter chapter1 = new Chapter(pageTitle, 1);
            chapter1.setNumberDepth(0);
            //Creation of TIC graph section object
            final String graphTitle = String.format(TIC_GRAPH_SECTION_TITLE, reportUnit.getMsrunName());
            final Paragraph ticGraphSection = new Paragraph(graphTitle, Constants.PDF_SECTION_FONT);
            ticGraphSection.setSpacingBefore(PDF_PARAGRAPH_SPACING);
            ticGraphSection.add(Chunk.NEWLINE);
            //Insert TIC Graph in ticGraphSection.
            ticGraphSection.add(createTICChartImage(reportUnit));
            chapter1.addSection(ticGraphSection);
            final String metricsTitle = String.format(METRICS_VALUES_SECTION_TITLE, reportUnit.getMsrunName());
            final Paragraph metricsValuesSection = new Paragraph(metricsTitle, Constants.PDF_SECTION_FONT);
            metricsValuesSection.setSpacingBefore(PDF_PARAGRAPH_SPACING);
            //Reference: http://www.java-connect.com/itext/add-table-in-PDF-document-using-java-iText-library.html
            //TODO: Insert metrics values table in metricsValuesSection
            metricsValuesSection.add(createMetricsValuesTable(allMetricsMap, reportUnit));
            chapter1.addSection(metricsValuesSection);
            //Addition of a chapter to the main document
            document.add(chapter1);
        }
        document.close();
        return pdfFileName;
    } catch (final DocumentException e) {
        // TODO Explain when these exception can occur.
        /* FileNotFoundException will be thrown by the FileInputStream, FileOutputStream, and 
         * RandomAccessFile constructors when a file with the specified path name does not exist.
         * It will also be thrown by these constructors if the file does exist but for some reason 
         * is inaccessible, for example when an attempt is made to open a read-only file for writing.
         * DocumentException Signals that an error has occurred in a Document.
         */
        logger.log(Level.SEVERE, PDF_EXPORT_EXCEPTION_MESSAGE, e);
        return "";
    }
}

From source file:org.flowable.app.rest.runtime.RelatedContentResource.java

License:Apache License

void createPdf(String dest, ArrayList<String> info) throws IOException, DocumentException {
    Document document = new Document();
    PdfWriter.getInstance(document, new FileOutputStream(dest));
    document.open();/*from  w ww.ja  va  2s. c  o m*/
    Font chapterFont = FontFactory.getFont(FontFactory.HELVETICA, 16, Font.BOLDITALIC);
    Font paragraphFont = FontFactory.getFont(FontFactory.HELVETICA, 12, Font.NORMAL);
    Chunk chunk = new Chunk("Relatrio", chapterFont);
    Chapter chapter = new Chapter(new Paragraph(chunk), 1);
    chapter.setNumberDepth(0);

    int i = 0;
    for (; i < info.size(); i++) {
        chapter.add(new Paragraph(info.get(i), paragraphFont));
    }
    document.add(chapter);
    document.close();
}

From source file:org.fossa.rolp.util.PdfStreamSource.java

License:Open Source License

private void addContent(PdfWriter writer) throws DocumentException, PdfFormatierungsException {
    Anchor anchor = new Anchor("Lernentwicklungsbericht", lernentwicklungsberichtUeberschriftFont);
    Chapter chapterLEB = new Chapter(new Paragraph(anchor), 1);
    chapterLEB.setNumberDepth(0);
    Paragraph paragraphHeader = new Paragraph();
    paragraphHeader.setLeading(FIXED_LEADING_TEXT, 1);
    sectionCount += 1;/*w ww . j a v  a  2  s  .c o m*/
    Section headerSection = chapterLEB.addSection(paragraphHeader);
    headerSection.setNumberDepth(0);

    paragraphHeader.add(Chunk.NEWLINE);
    paragraphHeader.add(PdfFormatHelper.buildHeaderNameLine(lebData.getSchuelername(), headerFont));
    paragraphHeader.add(Chunk.NEWLINE);
    paragraphHeader.add(PdfFormatHelper.buildHeaderKlassendatenLine(lebData, headerFont));
    headerSection.add(Chunk.NEWLINE);
    headerSection.add(Chunk.NEWLINE);
    document.add(chapterLEB);
    insertDummyLineIfNecessary(writer);

    addKlassenbrief(chapterLEB, writer);
    addIndividuelleEinschaetzung(chapterLEB, writer);
    addFacheinschaetzungen(chapterLEB, writer);
}

From source file:org.jaqpot.core.service.data.ReportService.java

public void report2PDF(Report report, OutputStream os) {

    Document document = new Document();
    document.setPageSize(PageSize.A4);/* w  w  w  .  j a v  a2 s  .  com*/
    document.setMargins(50, 45, 80, 40);
    document.setMarginMirroring(false);

    try {
        PdfWriter writer = PdfWriter.getInstance(document, os);
        TableHeader event = new TableHeader();
        writer.setPageEvent(event);

    } catch (DocumentException ex) {
        throw new InternalServerErrorException(ex);
    }

    document.open();

    /** setup fonts for pdf */
    Font ffont = new Font(Font.FontFamily.UNDEFINED, 9, Font.ITALIC);
    Font chapterFont = FontFactory.getFont(FontFactory.HELVETICA, 16, Font.BOLDITALIC);
    Font paragraphFontBold = FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD);
    Font paragraphFont = FontFactory.getFont(FontFactory.HELVETICA, 12, Font.NORMAL);
    Font tableFont = FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD);

    /** print link to jaqpot*/
    Chunk chunk = new Chunk(
            "This report has been automatically created by the JaqpotQuatro report service. Click here to navigate to our official webpage",
            ffont);
    chunk.setAnchor("http://www.jaqpot.org");

    Paragraph paragraph = new Paragraph(chunk);
    paragraph.add(Chunk.NEWLINE);

    Chapter chapter = new Chapter(paragraph, 1);
    chapter.setNumberDepth(0);

    /** get title */
    String title = null;
    if (report.getMeta() != null && report.getMeta().getTitles() != null
            && !report.getMeta().getTitles().isEmpty())
        title = report.getMeta().getTitles().iterator().next();

    /** print title aligned centered in page */
    if (title == null)
        title = "Report";
    chunk = new Chunk(title, chapterFont);
    paragraph = new Paragraph(chunk);
    paragraph.setAlignment(Element.ALIGN_CENTER);
    paragraph.add(Chunk.NEWLINE);
    paragraph.add(Chunk.NEWLINE);

    chapter.add(paragraph);

    /** report Description */
    if (report.getMeta() != null && report.getMeta().getDescriptions() != null
            && !report.getMeta().getDescriptions().isEmpty()
            && !report.getMeta().getDescriptions().toString().equalsIgnoreCase("null")) {
        paragraph = new Paragraph();
        paragraph.add(new Chunk("Description: ", paragraphFontBold));
        paragraph.add(new Chunk(report.getMeta().getDescriptions().toString().replaceAll(":http", ": http"),
                paragraphFont));
        chapter.add(paragraph);
        chapter.add(Chunk.NEWLINE);
    }

    /** report model, algorithm and/or dataset id */
    if (report.getMeta() != null && report.getMeta().getHasSources() != null
            && !report.getMeta().getHasSources().isEmpty() && !report.getMeta().getDescriptions().isEmpty()
            && !report.getMeta().getDescriptions().toString().equalsIgnoreCase("null")) {
        Iterator<String> sources = report.getMeta().getHasSources().iterator();
        sources.forEachRemaining(o -> {
            if (o != null) {
                String[] source = o.split("/");
                if (source[source.length - 2].trim().equals("model")
                        || source[source.length - 2].trim().equals("algorithm")
                        || source[source.length - 2].trim().equals("dataset")) {
                    Paragraph paragraph1 = new Paragraph();
                    paragraph1.add(new Chunk(source[source.length - 2].substring(0, 1).toUpperCase()
                            + source[source.length - 2].substring(1) + ": ", paragraphFontBold));
                    paragraph1.add(new Chunk(source[source.length - 1], paragraphFont));
                    chapter.add(paragraph1);
                    chapter.add(Chunk.NEWLINE);
                }
            }
        });
    }

    /** report single calculations */
    report.getSingleCalculations().forEach((key, value) -> {
        Paragraph paragraph1 = new Paragraph();
        paragraph1 = new Paragraph();
        paragraph1.add(new Chunk(key + ": ", paragraphFontBold));
        paragraph1.add(new Chunk(value.toString().trim().replaceAll(" +", " "), paragraphFont));
        chapter.add(paragraph1);
        chapter.add(Chunk.NEWLINE);
    });

    /** report date of completion */
    if (report.getMeta() != null && report.getMeta().getDate() != null) {
        Paragraph paragraph1 = new Paragraph();
        paragraph1.add(new Chunk("Procedure completed on: ", paragraphFontBold));
        paragraph1.add(new Chunk(report.getMeta().getDate().toString(), paragraphFont));
        chapter.add(paragraph1);
        chapter.add(Chunk.NEWLINE);
    }

    try {
        document.add(chapter);
    } catch (DocumentException ex) {
        throw new InternalServerErrorException(ex);
    }

    Integer chapterNumber = 0;

    /** report all_data */
    for (Entry<String, ArrayCalculation> entry : report.getArrayCalculations().entrySet()) {
        String label = entry.getKey();
        ArrayCalculation ac = entry.getValue();
        PdfPTable table = new PdfPTable(ac.getColNames().size() + 1);
        for (Entry<String, List<Object>> row : ac.getValues().entrySet()) {

            try {
                XMLWorkerHelper.getInstance().parseXHtml(w -> {
                    if (w instanceof WritableElement) {
                        List<Element> elements = ((WritableElement) w).elements();
                        for (Element element : elements) {
                            PdfPCell pdfCell = new PdfPCell();
                            pdfCell.addElement(element);
                            table.addCell(pdfCell);
                        }
                    }
                }, new StringReader(row.getKey()));
            } catch (IOException e) {
                e.printStackTrace();
            }

            for (Object o : row.getValue()) {
                table.addCell(o.toString());
            }
            table.completeRow();
        }
        try {
            Chunk tableChunk = new Chunk(label, tableFont);
            Chapter tableChapter = new Chapter(new Paragraph(tableChunk), ++chapterNumber);
            tableChapter.add(Chunk.NEWLINE);
            tableChapter.add(table);
            document.newPage();
            document.add(tableChapter);
        } catch (DocumentException ex) {
            throw new InternalServerErrorException(ex);
        }
    }

    /** report plots */
    for (Entry<String, String> entry : report.getFigures().entrySet()) {
        try {
            byte[] valueDecoded = Base64.decodeBase64(entry.getValue());
            Image l = Image.getInstance(valueDecoded);
            document.newPage();
            //image starts at the half's half of pdf page
            l.setAbsolutePosition(0, (document.getPageSize().getHeight() / 2 / 2));
            l.scaleToFit(document.getPageSize());

            Chunk tableChunk = new Chunk(entry.getKey(), tableFont);
            Chapter tableChapter = new Chapter(new Paragraph(tableChunk), ++chapterNumber);
            tableChapter.add(l);
            document.add(tableChapter);
        } catch (IOException | DocumentException e) {
            e.printStackTrace();
        }
    }
    document.close();
}

From source file:org.sharegov.cirm.utils.PDFExportUtil.java

License:Apache License

private static void addContent(Document doc, Json data) throws DocumentException {
    Anchor anchor = new Anchor(); //new Anchor("First Chapter", catFont);
    //anchor.setName("First Chapter Anchor");

    Chapter catPart = new Chapter(new Paragraph(anchor), 1);
    catPart.setNumberDepth(0);
    Paragraph subPara = new Paragraph(); //new Paragraph("SubCategory 1", subFont);
    Section subCatPart = catPart.addSection(subPara);
    subCatPart.setNumberDepth(0);//www  .j  a va2s . c  o  m

    createTable(subCatPart, data);

    //Add everything to the document
    doc.add(catPart);
}

From source file:org.sharegov.cirm.utils.PDFViewReport.java

License:Apache License

private void addContent(Document d, Json data) {
    Anchor anchor = new Anchor();
    Chapter catPart = new Chapter(new Paragraph(anchor), 1);
    catPart.setNumberDepth(0);
    Paragraph subPara = new Paragraph(); //new Paragraph("SubCategory 1", subFont);
    Section subCatPart = catPart.addSection(subPara);
    subCatPart.setNumberDepth(0);//w ww. jav a  2  s .  com

    try {
        addTopTable(subCatPart, data);
        addDescription(subCatPart, data);
        addQuestions(subCatPart, data);
        addActors(subCatPart, data);
        addActivities(subCatPart, data);
        d.add(catPart);
    } catch (Exception e) {
        e.printStackTrace();
        throw new RuntimeException("Problem during addContend for BO: " + data.toString(), e);
    }
}

From source file:org.sharegov.cirm.utils.PDFViewReport.java

License:Apache License

private void addWASDContent(Document d, Json applicant, String hasCaseNumber, boolean isEnglish) {
    //Anchor anchor = new Anchor();
    try {/*from w  ww . ja  v a  2  s .co  m*/
        Chapter chapter = new Chapter(new Paragraph(), 1);
        chapter.setNumberDepth(0);
        //addWASDHeader(chapter);
        addWASDBody(chapter, applicant, hasCaseNumber, isEnglish);
        d.add(chapter);
    } catch (Exception e) {
        e.printStackTrace();
        throw new RuntimeException(e);
    }
}

From source file:org.sharegov.cirm.utils.PDFViewReport.java

License:Apache License

public void errorReport(OutputStream out) {
    if (DBG)/*www  .j  a  v  a  2s. c  o  m*/
        System.out.println("Start: PDF errorReport");
    try {
        Date date = new Date();
        setTime(formatDate(date, true, false));
        Document doc = new Document(PageSize.A4);
        doc.setMargins(9, 9, doc.topMargin(), doc.bottomMargin());
        PdfWriter writer = PdfWriter.getInstance(doc, out);
        TableHeader th = new TableHeader();
        writer.setPageEvent(th);
        doc.open();

        Chapter chapter = new Chapter(new Paragraph(), 1);
        chapter.setNumberDepth(0);
        addSection(chapter).add(new Phrase(" "));
        addSection(chapter).add(new Phrase(" "));
        addSection(chapter).add(new Phrase(genericErrorMsg));
        doc.add(chapter);
        doc.close();
    } catch (DocumentException e) {
        e.printStackTrace();
        throw new RuntimeException(e);
    }
    if (DBG)
        System.out.println("Done: PDF errorReport");
}

From source file:pdf.PdfUtility.java

private void addData(Document document) {
    List<? extends Achievement> allData = ServiceLocator.findLifetimeService().getAchievements(userId,
            language);//from www.  j  av  a2 s .  c  o m
    Collections.sort(allData, comparator);

    Chapter info = new Chapter(getSectionTitle(getTranslation("Achievements", language)), 0);
    info.setNumberDepth(0);
    info.setTriggerNewPage(false);

    boolean first = true;
    for (Achievement a : allData) {
        if (isInRange(a)) {
            achievements.add(a);
            Paragraph current = addTableEntry(a);
            if (first) {
                current.setSpacingBefore(5f);
            }
            info.addSection(current, 0);
        }
    }
    //info.add(Chunk.NEWLINE);
    try {
        document.add(info);
    } catch (DocumentException ex) {
        Logger.getLogger(PdfUtility.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:project1.GENERALCV.java

private void createcvActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_createcvActionPerformed
    String firstname, lastname, contactno, email, phonenumber, address;
    String dob, martialStatus, cast, careerObjectives;
    String university, city, startdatee, enddatee, coursesAndQualification;
    String acedemicQualification, certificates, experience, techskills, addSkills;
    String achivements, additionalCertificates, references, hobbies;
    firstname = txtname.getText();/*www  . ja  v  a2 s. c  o  m*/
    lastname = txtlastname.getText();

    email = txtemail.getText();
    phonenumber = txtMobileNo.getText();

    address = txtAddress.getText();

    SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy");

    String link = txtLink.getText();

    // dob= dateFormat.format(dateOfBirth.getDate());
    martialStatus = cmbMartialStatus.getSelectedItem().toString();
    // cast=txtcast.getText();
    //  careerObjectives=txtcareer.getText();

    university = txtCollegeName.getText();
    city = txtCity.getText();
    // startdatee=dateFormat.format(startdate.getDate());
    // enddatee=dateFormat.format(enddate.getDate());
    coursesAndQualification = txtExtraCourses.getText();

    //  certificates=txtcertificats.getText();
    // experience=txtexperience.getText();
    techskills = txttechnical.getText();
    // addSkills=txtadditional.getText();

    references = txtreference.getText();

    try {
        Class.forName("com.mysql.jdbc.Driver");
        con = DriverManager.getConnection("jdbc:mysql://localhost:3306/cvmaker", "root", "12345");

        pInsertPerson = con
                .prepareStatement("INSERT INTO PERSONS(NAMEE,CONTACTNO,EMAILID,ADDRESS) VALUES(?,?,?,?)");

        pInsertPerson.setString(1, firstname + lastname);
        pInsertPerson.setString(2, phonenumber);
        pInsertPerson.setString(3, email);
        pInsertPerson.setString(4, address);
        pInsertPerson.executeUpdate();

        JOptionPane.showMessageDialog(null, "Data Is Alo Saved In Database....");

        showRecords();

    } catch (Exception e) {

        System.out.println(e.toString());

    }

    Statement statement;

    String selectTableSQL = "SELECT ID FROM PERSONS";
    int ss = 0;
    try {
        Class.forName("com.mysql.jdbc.Driver");
        con = DriverManager.getConnection("jdbc:mysql://localhost:3306/cvmaker", "root", "12345");

        statement = con.createStatement();

        //System.out.println(selectTableSQL);
        // execute select SQL stetementS
        ResultSet rs = statement.executeQuery(selectTableSQL);

        while (rs.next()) {

            ss = rs.getInt("ID");
        }
    } catch (SQLException e) {
        System.out.println(e.toString());

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

    int newcvid = ss;

    try {

        OutputStream file = new FileOutputStream(new File("D:\\PDFFILES\\" + firstname + lastname + ".pdf"));

        Document document = new Document();
        PdfWriter.getInstance(document, file);

        document.open();
        //     Image im=Image.getInstance("E:\\PDFFILES\\FUUAST.png");
        //   document.add(new Paragraph(""));
        // document.add(im);

        Paragraph title1 = new Paragraph(firstname + " " + lastname + " Cv", FontFactory
                .getFont(FontFactory.HELVETICA, 36, Font.BOLDITALIC, new CMYKColor(0, 255, 255, 17)));

        Chapter chapter1 = new Chapter(title1, 1);

        chapter1.setNumberDepth(0);
        document.add(chapter1);

        document.add(new Paragraph("\n\n"));

        List unorderedList = new List(List.UNORDERED);
        unorderedList.add(new ListItem("Mobile No:" + phonenumber));
        unorderedList.add(new ListItem("Email:" + city));
        unorderedList.add(new ListItem("Address:" + address));
        //    unorderedList.add(new ListItem("End Date:" + enddatee));
        document.add(unorderedList);

        //  document.add(new Paragraph("Address:"+address));
        Paragraph title2 = new Paragraph("Personal Information", FontFactory.getFont(FontFactory.HELVETICA, 24,
                Font.BOLDITALIC, new CMYKColor(0, 255, 255, 17)));
        title2.setAlignment(Element.ALIGN_CENTER);

        document.add(title2);
        //   document.add(new Paragraph("Date Of Birth:" + dob));

        document.add(new Paragraph("Martial Status:" + martialStatus));
        //   document.add(new Paragraph("Cast:"+cast));
        //   document.add(new Paragraph("Career Objectives:"+careerObjectives));

        Paragraph title3 = new Paragraph("Qualification", FontFactory.getFont(FontFactory.HELVETICA, 24,
                Font.BOLDITALIC, new CMYKColor(0, 255, 255, 17)));
        title3.setAlignment(Element.ALIGN_CENTER);
        document.add(title3);
        PdfPTable table = new PdfPTable(2); // 3 columns.
        document.add(new Paragraph("\n\n"));
        PdfPCell cell1 = new PdfPCell(new Paragraph("Insituite Name:"));
        PdfPCell cell2 = new PdfPCell(new Paragraph(university));

        PdfPCell cell3 = new PdfPCell(new Paragraph("City:"));
        PdfPCell cell4 = new PdfPCell(new Paragraph(city));

        PdfPCell cell5 = new PdfPCell(new Paragraph("Start Date:"));
        // PdfPCell cell6 = new PdfPCell(new Paragraph(startdatee));

        PdfPCell cell7 = new PdfPCell(new Paragraph("End Date:"));
        //PdfPCell cell8 = new PdfPCell(new Paragraph(enddatee));

        PdfPCell cell71 = new PdfPCell(new Paragraph("Extra Courses:"));
        PdfPCell cell81 = new PdfPCell(new Paragraph(coursesAndQualification));
        table.addCell(cell1);
        table.addCell(cell2);
        table.addCell(cell3);
        table.addCell(cell4);
        table.addCell(cell5);
        //   table.addCell(cell6);
        table.addCell(cell7);
        //   table.addCell(cell8);
        table.addCell(cell71);
        table.addCell(cell81);

        document.add(table);

        //  document.add(new Paragraph("Extra Courses:"+coursesAndQualification));
        //   document.add(new Paragraph("Certificates:"+certificates));
        //
        Paragraph title4 = new Paragraph("Experience", FontFactory.getFont(FontFactory.HELVETICA, 24,
                Font.BOLDITALIC, new CMYKColor(0, 255, 255, 17)));
        title4.setAlignment(Element.ALIGN_CENTER);
        document.add(title4);
        //      document.add(new Paragraph(""+experience));

        Paragraph title5 = new Paragraph("Skills", FontFactory.getFont(FontFactory.HELVETICA, 24,
                Font.BOLDITALIC, new CMYKColor(0, 255, 255, 17)));
        title5.setAlignment(Element.ALIGN_CENTER);
        document.add(title5);

        document.add(new Paragraph("Technical Skills:" + techskills));
        //    document.add(new Paragraph("Additional Skills:"+addSkills));
        Paragraph title6 = new Paragraph("References", FontFactory.getFont(FontFactory.HELVETICA, 24,
                Font.BOLDITALIC, new CMYKColor(0, 255, 255, 17)));
        title6.setAlignment(Element.ALIGN_CENTER);
        document.add(title6);
        document.add(new Paragraph("References:" + references));

        //     Anchor anchor;
        //     anchor = new Anchor(link, FontFactory.getFont(FontFactory.HELVETICA,12, Font.UNDERLINE, new CMYKColor(0, 0,0,255)));
        //    anchor.setReference( link);
        Paragraph paragraph = new Paragraph("Profile Link:");
        //     paragraph.add(anchor);
        document.add(paragraph);
        Paragraph title11 = new Paragraph(
                "                                                 Cv Number:" + newcvid, FontFactory
                        .getFont(FontFactory.HELVETICA, 15, Font.BOLDITALIC, new CMYKColor(0, 255, 255, 17)));

        document.add(new Paragraph("\n\n"));
        document.add(title11);
        try {
            Desktop desktop = Desktop.getDesktop();
            if (desktop.isSupported(Desktop.Action.OPEN)) {
                desktop.open(new File("D:\\PDFFILES\\" + firstname + lastname + ".pdf"));
            } else {
                System.out.println("Open is not supported");
            }
        } catch (IOException exp) {
            exp.printStackTrace();
        }
        document.close();
        file.close();

    } catch (Exception e) {

        e.printStackTrace();
    }
}