Example usage for com.lowagie.text Anchor Anchor

List of usage examples for com.lowagie.text Anchor Anchor

Introduction

In this page you can find the example usage for com.lowagie.text Anchor Anchor.

Prototype

public Anchor(float leading, String string) 

Source Link

Document

Constructs an Anchor with a certain leading and a certain String.

Usage

From source file:FirstPdf.java

private static void addContent(Document document) throws DocumentException {
    Anchor anchor = new Anchor("First Chapter", catFont);
    anchor.setName("First Chapter");
    // Second parameter is the number of the chapter
    Chapter catPart = new Chapter(new Paragraph(anchor), 1);
    Paragraph subPara = new Paragraph("Subcategory 1", subFont);
    Section subCatPart = catPart.addSection(subPara);
    subCatPart.add(new Paragraph("Hello"));
    subPara = new Paragraph("Subcategory 2", subFont);
    subCatPart = catPart.addSection(subPara);
    subCatPart.add(new Paragraph("Paragraph 1"));
    subCatPart.add(new Paragraph("Paragraph 2"));
    subCatPart.add(new Paragraph("Paragraph 3"));
    // Add a  little list
    createList(subCatPart);//w w  w. jav a  2  s.  c  o  m
    // Add a small table
    createTable(subCatPart);
    // Now a small table
    // Now add all this to the document
    document.add(catPart);
    // Next section
    anchor = new Anchor("Second Chapter", catFont);
    anchor.setName("Second Chapter");
    // Second parameter is the number of the chapter
    catPart = new Chapter(new Paragraph(anchor), 1);
    subPara = new Paragraph("Subcategory", subFont);
    subCatPart = catPart.addSection(subPara);
    subCatPart.add(new Paragraph("This is a very important message"));
    // Now add all this to the document
    document.add(catPart);

}

From source file:classroom.filmfestival_a.Movies04.java

@SuppressWarnings("unchecked")
public static void main(String[] args) {
    // step 1//from   www  . ja  v  a 2s  .c om
    Document document = new Document();
    try {
        // step 2
        PdfWriter.getInstance(document, new FileOutputStream(RESULT));
        // step 3
        document.open();
        // step 4
        Session session = (Session) MySessionFactory.currentSession();
        Query q = session.createQuery("from FilmTitle order by title");
        java.util.List<FilmTitle> results = q.list();
        Paragraph p;
        Chunk c;
        Anchor a;
        Font bold = new Font(Font.HELVETICA, 12, Font.BOLD);
        Font italic = new Font(Font.HELVETICA, 12, Font.ITALIC);
        Font underlined = new Font(Font.HELVETICA, 12, Font.UNDERLINE, Color.BLUE);
        for (FilmTitle movie : results) {
            p = new Paragraph(20);
            c = new Chunk(movie.getTitle(), bold);
            c.setAnchor("http://cinema.lowagie.com/titel.php?id=" + movie.getFilmId());
            p.add(c);
            c = new Chunk(" (" + movie.getYear() + ") ", italic);
            p.add(c);
            a = new Anchor("IMDB", underlined);
            a.setReference("http://www.imdb.com/title/tt" + movie.getImdb());
            p.add(a);
            document.add(p);
            Set<DirectorName> directors = movie.getDirectorNames();
            List list = new List();
            for (DirectorName director : directors) {
                list.add(director.getName());
            }
            document.add(list);
        }
        // step 5
        document.close();
    } catch (IOException e) {
        LOGGER.error("IOException: ", e);
    } catch (DocumentException e) {
        LOGGER.error("DocumentException: ", e);
    }
}

From source file:com.bibisco.export.ITextExporter.java

License:GNU General Public License

@Override
public void startChapter(String pStrChapterTitle) {

    Font lFont = new Font();
    lFont.setFamily(mFont.getFamilyname());
    lFont.setSize(mFont.getSize());/*from  w ww .  jav  a  2 s  .co m*/
    lFont.setStyle(Font.BOLD);

    Anchor anchor = new Anchor(pStrChapterTitle, lFont);
    anchor.setName(pStrChapterTitle);

    mChapter = new Chapter(new Paragraph(anchor), ++mIntChapterPosition);
    addEmptyLines(1);
}

From source file:com.bibisco.export.ITextExporter.java

License:GNU General Public License

@Override
public void startSection(String pStrSectionTitle) {

    Font lFont = new Font();
    lFont.setFamily(mFont.getFamilyname());
    lFont.setSize(mFont.getSize());//  w  w  w  .  j  a  va  2 s  .  com
    lFont.setStyle(Font.ITALIC);

    Anchor anchor = new Anchor(pStrSectionTitle, lFont);
    anchor.setName(pStrSectionTitle);

    mSection = mChapter.addSection(new Paragraph(anchor));
}

From source file:com.bibisco.export.ITextExporter.java

License:GNU General Public License

@Override
public void startSubSection(String pStrSubSectionTitle) {
    Font lFont = new Font();
    lFont.setFamily(mFont.getFamilyname());
    lFont.setSize(mFont.getSize());/*from   ww  w.  j a va  2s  .  co m*/

    Anchor anchor = new Anchor(pStrSubSectionTitle, lFont);
    anchor.setName(pStrSubSectionTitle);

    addEmptyLines(1);
    mSubSection = mSection.addSection(new Paragraph(anchor));
    addEmptyLines(1);

}

From source file:com.concursive.connect.web.modules.wiki.utils.WikiPDFUtils.java

License:Open Source License

private static void appendWiki(WikiPDFContext context, Wiki currentWiki, Document document, Connection db,
        ArrayList<Integer> wikiListDone) throws SQLException {

    LOG.debug("appendWiki-> " + currentWiki.getSubject());

    // Context Objects
    Project project = context.getProject();
    WikiExportBean exportBean = context.getExportBean();

    // Track the wikis to get appended to the output
    ArrayList<Integer> wikiListTodo = new ArrayList<Integer>();

    try {//from   w w w  .  jav  a 2 s.  c om
        // Output the name of the Wiki
        boolean hasTitle = StringUtils.hasText(currentWiki.getSubject());
        if (hasTitle) {
            Anchor wikiAnchor = new Anchor(currentWiki.getSubject(), wikiFont);
            wikiAnchor.setName(currentWiki.getSubject().toLowerCase());
            LOG.debug("Add anchor: " + currentWiki.getSubject().toLowerCase());
            document.add(wikiAnchor);
            LOG.debug("document.add(wikiAnchor)");
        }

        // Output the wiki content
        parseContent(context, currentWiki, currentWiki.getContent(), document, null, db, wikiListTodo,
                wikiListDone, 0f);
        wikiListDone.add(currentWiki.getId());

        // See if any linked wikis should be appended
        if (exportBean.getFollowLinks() && wikiListTodo.size() > 0) {
            Iterator i = wikiListTodo.iterator();
            while (i.hasNext()) {
                Integer id = (Integer) i.next();
                if (id > -1 && !wikiListDone.contains(id)) {
                    Wiki subwiki = new Wiki(db, id);
                    document.add(Chunk.NEXTPAGE);
                    appendWiki(context, subwiki, document, db, wikiListDone);
                }
                //i.remove();
            }
        }
    } catch (Exception e) {
        LOG.error("appendWiki", e);
    }
}

From source file:com.concursive.connect.web.modules.wiki.utils.WikiPDFUtils.java

License:Open Source License

private static boolean parseLine(WikiPDFContext context, String line, Paragraph main, Connection db,
        ArrayList<Integer> wikiListTodo, float cellWidth, PdfPCell cell) throws Exception {

    LOG.debug("PARSING LINE: " + line);

    // Context Objects
    Project project = context.getProject();
    WikiExportBean exportBean = context.getExportBean();
    HashMap<String, ImageInfo> imageList = context.getImageList();
    String fileLibrary = context.getFileLibrary();

    boolean needsCRLF = true;
    boolean bold = false;
    boolean italic = false;
    boolean bolditalic = false;
    StringBuffer subject = new StringBuffer();
    StringBuffer data = new StringBuffer();
    int linkL = 0;
    int linkR = 0;
    int attr = 0;
    int underlineAttr = 0;

    // parse characters
    for (int i = 0; i < line.length(); i++) {
        char c1 = line.charAt(i);
        String c = String.valueOf(c1);
        // False attr/links
        if (!"'".equals(c) && attr == 1) {
            data.append("'").append(c);
            attr = 0;/*  w w  w .  ja  v a 2 s .  co m*/
            continue;
        }
        if (!"_".equals(c) && underlineAttr == 1) {
            data.append("_").append(c);
            underlineAttr = 0;
            continue;
        }
        if (!"[".equals(c) && linkL == 1) {
            data.append("[").append(c);
            linkL = 0;
            continue;
        }
        if (!"]".equals(c) && linkR == 1) {
            data.append("]").append(c);
            linkR = 0;
            continue;
        }
        // Links
        if ("[".equals(c)) {
            ++linkL;
            continue;
        }
        if ("]".equals(c)) {
            ++linkR;
            if (linkL == 2 && linkR == 2) {
                LOG.debug("main.add(new Chunk(data.toString()))");
                main.add(new Chunk(data.toString()));
                data.setLength(0);
                // Different type of links...
                String link = subject.toString().trim();
                if (link.startsWith("Image:") || link.startsWith("image:")) {
                    // @note From WikiImageLink.java
                    String image = link.substring(6);
                    String title = null;
                    int frame = -1;
                    int thumbnail = -1;
                    int left = -1;
                    int right = -1;
                    int center = -1;
                    int none = -1;
                    int imageLink = -1;
                    int alt = -1;
                    if (image.indexOf("|") > 0) {
                        // the image is first
                        image = image.substring(0, image.indexOf("|"));
                        // any directives are next
                        frame = link.indexOf("|frame");
                        thumbnail = link.indexOf("|thumb");
                        left = link.indexOf("|left");
                        right = link.indexOf("|right");
                        center = link.indexOf("|center");
                        none = link.indexOf("|none");
                        imageLink = link.indexOf("|link=");
                        alt = link.indexOf("|alt=");
                        // the optional caption is last
                        int last = link.lastIndexOf("|");
                        if (last > frame && last > thumbnail && last > left && last > right && last > center
                                && last > none && last > imageLink && last > alt) {
                            title = link.substring(last + 1);
                        }
                    }

                    //A picture, including alternate text:
                    //[[Image:Wiki.png|The logo for this Wiki]]

                    //You can put the image in a frame with a caption:
                    //[[Image:Wiki.png|frame|The logo for this Wiki]]

                    // Access some image details
                    int width = 0;
                    int height = 0;
                    ImageInfo imageInfo = imageList.get(image + (thumbnail > -1 ? "-TH" : ""));
                    if (imageInfo != null) {
                        width = imageInfo.getWidth();
                        height = imageInfo.getHeight();
                    }

                    // Alt
                    String altText = null;
                    if (alt > -1) {
                        int startIndex = alt + 4;
                        int endIndex = link.indexOf("|", startIndex);
                        if (endIndex == -1) {
                            endIndex = link.length();
                        }
                        altText = link.substring(startIndex, endIndex);
                    }

                    // Looks like the image needs a link (which is always last)
                    String url = null;
                    if (imageLink > -1) {
                        // Get the entered link
                        int startIndex = imageLink + 6;
                        int endIndex = link.length();
                        String href = link.substring(startIndex, endIndex);

                        // Treat as a wikiLink to validate and to create a proper url
                        WikiLink wikiLink = new WikiLink(project.getId(),
                                (altText != null ? href + " " + altText : href));
                        url = wikiLink.getUrl("");
                        if (!url.startsWith("http://") && !url.startsWith("https://")) {
                            // @todo Use a local link
                            // @todo Use an external link
                        }
                    }

                    // Determine if local or external image
                    if ((image.startsWith("http://") || image.startsWith("https://"))) {
                        // retrieve external image
                        String imageUrl = null;
                        try {
                            URL imageURL = new URL(image);
                            imageUrl = image;
                        } catch (Exception e) {

                        }
                    } else {
                        // local image
                        try {
                            // @todo image alignment and links
                            Image thisImage = Image.getInstance(
                                    getImageFilename(db, fileLibrary, project, image, (thumbnail > -1)));

                            LOG.debug("Drawing image for area: " + cellWidth);

                            if (cellWidth > 0f) {
                                LOG.debug(" Image is embedded in cell");
                                // Guess the size of the cell
                                float cellPixels = (500f * (cellWidth / 100f));
                                if (cellPixels > 0f && (float) width > cellPixels) {
                                    // Shrink image to fit the cell
                                    LOG.debug(" Scaling to fit");
                                    thisImage.scaleToFit(cellPixels, 500f);
                                } else {
                                    // Align image to left instead of scaling it to fit
                                    thisImage.setAlignment(Image.LEFT);
                                }
                                LOG.debug("cell.addElement(thisImage)");
                                cell.addElement(thisImage);
                            } else {
                                LOG.debug(" Image is inline");
                                if (width > 500) {
                                    LOG.debug(" Scaling to fit");
                                    thisImage.scaleToFit(500f, 500f);
                                }
                                LOG.debug("main.add(thisImage)");
                                main.add(thisImage);
                            }

                            //                thisImage.setAlignment();
                            //                thisImage.Alignment = Image.TEXTWRAP | Image.ALIGN_RIGHT;

                            //                main.add(thisImage);
                        } catch (FileNotFoundException fnfe) {
                            LOG.warn("WikiPDFUtils-> Image was not found in the FileLibrary ("
                                    + getImageFilename(db, fileLibrary, project, image, (thumbnail > -1))
                                    + ")... will continue.");
                        }
                    }

                    /*
                    if (frame > -1 || thumbnail > -1) {
                      sb.append("</div>");
                      sb.append("<div id=\"caption\" style=\"margin-bottom: 5px; margin-left: 5px; margin-right: 5px; text-align: left;\">");
                    }
                    if (thumbnail > -1) {
                      sb.append("<div style=\"float:right\"><a target=\"_blank\" href=\"ProjectManagementWiki.do?command=Img&pid=" + wiki.getProjectId() + "&subject=" + StringUtils.replace(StringUtils.jsEscape(image), "%20", "+") + "\"><img src=\"images/magnify-clip.png\" width=\"15\" height=\"11\" alt=\"Enlarge\" border=\"0\" /></a></div>");
                    }
                    if (frame > -1 || thumbnail > -1) {
                      if (title != null) {
                        sb.append(StringUtils.toHtml(title));
                      }
                      sb.append(
                          "  </div>\n" +
                              "</div>");
                    }
                    */
                    /*
                    if (none > -1) {
                      sb.append("<br clear=\"all\">");
                    }
                    */
                    if (i + 1 == line.length() && (right > -1 || left > -1) || none > -1) {
                        needsCRLF = false;
                    }
                } else {
                    // This is most likely a Wiki link
                    String title = subject.toString().trim();
                    if (link.indexOf("|") > 0) {
                        link = link.substring(0, link.indexOf("|")).trim();
                        title = title.substring(title.indexOf("|") + 1);
                    }
                    if (link.indexOf("http://") > -1 || link.indexOf("https://") > -1) {
                        String label = link;
                        if (link.indexOf(" ") > 0) {
                            label = link.substring(link.indexOf(" ") + 1);
                            link = link.substring(0, link.indexOf(" "));
                        }
                        Anchor anchor1 = new Anchor(label, FontFactory.getFont(FontFactory.HELVETICA, 12,
                                Font.UNDERLINE, new Color(0, 0, 255)));
                        anchor1.setReference(link);
                        anchor1.setName("top");
                        main.add(anchor1);
                    } else {
                        // Place a wiki link
                        if (exportBean.getFollowLinks()) {
                            // See if target link exists before creating a link to it
                            int linkedWikiId = -1;
                            if (StringUtils.hasText(title) && !title.startsWith("|")) {
                                Wiki subwiki = WikiList.queryBySubject(db, title, project.getId());
                                if (subwiki.getId() > -1) {
                                    linkedWikiId = subwiki.getId();
                                }
                            }
                            // Display the linked item
                            if (linkedWikiId > -1) {
                                // Display as an anchor
                                Anchor linkToWiki = new Anchor(title, FontFactory.getFont(FontFactory.HELVETICA,
                                        12, Font.NORMAL, new Color(0, 0, 255)));
                                linkToWiki.setReference("#" + title.toLowerCase());
                                LOG.debug("Link to: #" + title.toLowerCase());
                                main.add(linkToWiki);
                                LOG.debug(" main.add(linkToWiki)");
                                //                  main.add(new Chunk(title, FontFactory.getFont(FontFactory.HELVETICA, 12, Font.NORMAL, new Color(0, 0, 255))).setLocalGoto(link));
                                // Add this wiki to the to do list...
                                if (!wikiListTodo.contains(linkedWikiId)) {
                                    wikiListTodo.add(linkedWikiId);
                                }
                            } else {
                                // Display without the link
                                main.add(new Chunk(title, FontFactory.getFont(FontFactory.HELVETICA, 12,
                                        Font.NORMAL, new Color(0, 0, 255))));
                            }
                        } else {
                            // Not following links, so display... perhaps as an external link someday
                            main.add(new Chunk(title, FontFactory.getFont(FontFactory.HELVETICA, 12,
                                    Font.NORMAL, new Color(0, 0, 255))));
                        }
                    }
                }
                subject.setLength(0);
                linkL = 0;
                linkR = 0;
            }
            continue;
        }
        if (!"[".equals(c) && linkL == 2 && !"]".equals(c)) {
            subject.append(c);
            continue;
        }
        // Attribute properties
        if ("'".equals(c)) {
            ++attr;
            continue;
        }
        if (!"'".equals(c) && attr > 1) {
            if (attr == 2) {
                if (!italic) {
                    main.add(new Chunk(data.toString()));
                    data.setLength(0);
                    data.append(c);
                    italic = true;
                } else {
                    data.append(c);
                    main.add(new Chunk(data.toString(),
                            FontFactory.getFont(FontFactory.HELVETICA, 12, Font.ITALIC, new Color(0, 0, 0))));
                    data.setLength(0);
                    italic = false;
                }
                attr = 0;
                continue;
            }
            if (attr == 3) {
                if (!bold) {
                    main.add(new Chunk(data.toString()));
                    data.setLength(0);
                    data.append(c);
                    bold = true;
                } else {
                    data.append(c);
                    main.add(new Chunk(data.toString(),
                            FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD, new Color(0, 0, 0))));
                    data.setLength(0);
                    bold = false;
                }
                attr = 0;
                continue;
            }
            if (attr == 5) {
                if (!bolditalic) {
                    main.add(new Chunk(data.toString()));
                    data.setLength(0);
                    data.append(c);
                    bolditalic = true;
                } else {
                    data.append(c);
                    main.add(new Chunk(data.toString(), FontFactory.getFont(FontFactory.HELVETICA, 12,
                            Font.BOLDITALIC, new Color(0, 0, 0))));
                    data.setLength(0);
                    bolditalic = false;
                }
                attr = 0;
                continue;
            }
        }
        data.append(c);
    }
    for (int x = 0; x < linkR; x++) {
        data.append("]");
    }
    for (int x = 0; x < linkL; x++) {
        data.append("[");
    }
    if (attr == 1) {
        data.append("'");
    }
    if (italic) {
        main.add(new Chunk(data.toString(),
                FontFactory.getFont(FontFactory.HELVETICA, 12, Font.ITALIC, new Color(0, 0, 0))));
    } else if (bold) {
        main.add(new Chunk(data.toString(),
                FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD, new Color(0, 0, 0))));
    } else if (bolditalic) {
        main.add(new Chunk(data.toString(),
                FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLDITALIC, new Color(0, 0, 0))));
    } else {
        main.add(new Chunk(data.toString()));
    }
    data.setLength(0);
    return needsCRLF;
}

From source file:com.exam.server.ConvertPDF.java

private static void addContent(Document document, ArrayList<DeviceDTO> input) throws DocumentException {
    Anchor anchor = new Anchor("", catFont);
    anchor.setName("User Report");

    // Second parameter is the number of the chapter
    Chapter catPart = new Chapter(new Paragraph(anchor), 1);

    Paragraph subPara = new Paragraph("", subFont);
    Section subCatPart = catPart.addSection(subPara);
    //                subCatPart.add(new Paragraph("Hello"));

    //                subPara = new Paragraph("Subcategory 2", subFont);
    //                subCatPart = catPart.addSection(subPara);
    //                subCatPart.add(new Paragraph("Paragraph 1"));
    //                subCatPart.add(new Paragraph("Paragraph 2"));
    //                subCatPart.add(new Paragraph("Paragraph 3"));

    // add a list
    //                createList(subCatPart);
    //                Paragraph paragraph = new Paragraph();
    //                addEmptyLine(paragraph, 5);
    //                subCatPart.add(paragraph);

    // add a table
    createTable(subCatPart, input);//from  w w  w .  ja  v  a2 s . c om

    // now add all this to the document
    document.add(catPart);

    // Next section
    //                anchor = new Anchor("Second Chapter", catFont);
    //                anchor.setName("Second Chapter");

    // Second parameter is the number of the chapter
    //                catPart = new Chapter(new Paragraph(anchor), 1);

    //                subPara = new Paragraph("Subcategory", subFont);
    //                subCatPart = catPart.addSection(subPara);
    //                subCatPart.add(new Paragraph("This is a very important message"));

    // now add all this to the document
    //                document.add(catPart);

    document.newPage();

}

From source file:com.parakhcomputer.util.pdf.FirstPdf.java

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

    // Second parameter is the number of the chapter
    Chapter catPart = new Chapter(new Paragraph(anchor), 1);

    Paragraph subPara = new Paragraph("Subcategory 1", subFont);
    Section subCatPart = catPart.addSection(subPara);
    subCatPart.add(new Paragraph("Hello"));

    subPara = new Paragraph("Subcategory 2", subFont);
    subCatPart = catPart.addSection(subPara);
    subCatPart.add(new Paragraph("Paragraph 1"));
    subCatPart.add(new Paragraph("Paragraph 2"));
    subCatPart.add(new Paragraph("Paragraph 3"));

    // Add a list
    createList(subCatPart);// ww w. ja  v a 2s  .c  o  m
    Paragraph paragraph = new Paragraph();
    addEmptyLine(paragraph, 5);
    subCatPart.add(paragraph);

    // Add a table
    createTable(subCatPart);

    // Now add all this to the document
    document.add(catPart);

    // Next section
    anchor = new Anchor("Second Chapter", catFont);
    anchor.setName("Second Chapter");

    // Second parameter is the number of the chapter
    catPart = new Chapter(new Paragraph(anchor), 1);

    subPara = new Paragraph("Subcategory", subFont);
    subCatPart = catPart.addSection(subPara);
    subCatPart.add(new Paragraph("This is a very important message"));

    // Now add all this to the document
    document.add(catPart);

}

From source file:com.slamd.report.PDFReportGenerator.java

License:Open Source License

/**
 * Writes the table of contents to the document.
 *
 * @param  document  The document to which the contents are to be written.
 *
 * @return  {@code true} if the contents information was written to the
 *          PDF document, or {@code false} if not.
 *
 * @throws  DocumentException  If a problem occurs while writing the contents.
 *//*from ww  w. j  a  v a 2s .  com*/
private boolean writeContents(Document document) throws DocumentException {
    // First, make sure that there is actually something to write.  If we're
    // only going to write information for a single job or optimizing job, then
    // there is no reason to have a contents section.
    if (((reportJobs.length == 1) && (reportOptimizingJobs.length == 0))
            || ((reportJobs.length == 0) && (reportOptimizingJobs.length == 1))) {
        return false;
    }

    if (reportJobs.length > 0) {
        // Write the job data header.
        Paragraph p = new Paragraph("Job Data",
                FontFactory.getFont(FontFactory.HELVETICA, 18, Font.BOLD, Color.BLACK));
        document.add(p);

        // Create a table with the list of jobs.
        PdfPTable table = new PdfPTable(3);
        table.setWidthPercentage(100);
        writeTableHeaderCell(table, "Job ID");
        writeTableHeaderCell(table, "Description");
        writeTableHeaderCell(table, "Job Type");

        for (int i = 0; i < reportJobs.length; i++) {
            Job job = reportJobs[i];
            Anchor anchor = new Anchor(job.getJobID(),
                    FontFactory.getFont(FontFactory.HELVETICA, 12, Font.UNDERLINE, Color.BLUE));
            anchor.setReference('#' + job.getJobID());
            table.addCell(new PdfPCell(anchor));

            String descriptionStr = job.getJobDescription();
            if ((descriptionStr == null) || (descriptionStr.length() == 0)) {
                descriptionStr = "(Not Specified)";
            }
            writeTableCell(table, descriptionStr);

            writeTableCell(table, job.getJobClass().getJobName());
        }
        document.add(table);

        // Write a blank line between the job data and optimizing job data.
        document.add(new Paragraph(" "));
    }

    if (reportOptimizingJobs.length > 0) {
        // Write the optimizing job data header.
        Paragraph p = new Paragraph("Optimizing Job Data",
                FontFactory.getFont(FontFactory.HELVETICA, 18, Font.BOLD, Color.BLACK));
        document.add(p);

        // Create a table with the list of jobs.
        PdfPTable table = new PdfPTable(3);
        table.setWidthPercentage(100);
        writeTableHeaderCell(table, "Optimizing Job ID");
        writeTableHeaderCell(table, "Description");
        writeTableHeaderCell(table, "Job Type");

        for (int i = 0; i < reportOptimizingJobs.length; i++) {
            OptimizingJob optimizingJob = reportOptimizingJobs[i];
            Anchor anchor = new Anchor(optimizingJob.getOptimizingJobID(),
                    FontFactory.getFont(FontFactory.HELVETICA, 12, Font.UNDERLINE, Color.BLUE));
            anchor.setReference('#' + optimizingJob.getOptimizingJobID());
            table.addCell(new PdfPCell(anchor));

            String descriptionStr = optimizingJob.getDescription();
            if ((descriptionStr == null) || (descriptionStr.length() == 0)) {
                descriptionStr = "(Not Specified)";
            }
            writeTableCell(table, descriptionStr);

            writeTableCell(table, optimizingJob.getJobClass().getJobName());
        }
        document.add(table);
    }

    return true;
}