Example usage for com.lowagie.text.pdf PdfName OUTLINES

List of usage examples for com.lowagie.text.pdf PdfName OUTLINES

Introduction

In this page you can find the example usage for com.lowagie.text.pdf PdfName OUTLINES.

Prototype

PdfName OUTLINES

To view the source code for com.lowagie.text.pdf PdfName OUTLINES.

Click Source Link

Document

A name

Usage

From source file:de.offis.health.icardea.cied.pdf.extractor.PDFiText2Extractor.java

License:LGPL

@SuppressWarnings("unchecked")
public java.util.List getBookmarkTitlesAsText() {
    java.util.List bookmarkContent = null;
    if (pdfReader != null) {
        //bookmarkContent = SimpleBookmark.getBookmark(pdfReader);

        PdfDictionary catalog = pdfReader.getCatalog();
        if (catalog != null) {
            PdfObject rootPdfObject = PdfReader.getPdfObjectRelease(catalog.get(PdfName.OUTLINES));
            if (rootPdfObject != null && rootPdfObject.isDictionary()) {
                PdfDictionary rootOutlinesPdfDictionary = (PdfDictionary) rootPdfObject;
                /*/*w  ww .j  a  v a 2 s . co m*/
                 * If it doesn't exist create the List and populate it,
                 * otherwise just return the already existing List.
                 */
                if (bookmarkTextList == null) {
                    bookmarkTextList = new ArrayList<String>();

                    // Populate the List
                    populateBookmarkTextList(rootOutlinesPdfDictionary, "");
                } // end if

            }
        } // end if
    }
    return bookmarkContent;
}

From source file:it.flavianopetrocchi.jpdfbookmarks.itextbookmarksconverter.iTextBookmarksConverter.java

License:Open Source License

private Bookmark getBookmark() {
    PdfDictionary catalog = reader.getCatalog();
    PdfObject obj = PdfReader.getPdfObjectRelease(catalog.get(PdfName.OUTLINES));
    if (obj == null || !obj.isDictionary()) {
        return null;
    }//from   w  ww  .  ja  v a 2  s . c  om
    PdfDictionary outlines = (PdfDictionary) obj;
    //        pages = new IntHashtable();
    //        int numPages = reader.getNumberOfPages();
    //        for (int k = 1; k <= numPages; ++k) {
    //            pages.put(reader.getPageOrigRef(k).getNumber(), k);
    //            reader.releasePage(k);
    //        }
    initPages();

    Bookmark root = new Bookmark();
    root.setTitle("Root Bookmark");
    bookmarkDepth(root, (PdfDictionary) PdfReader.getPdfObjectRelease(outlines.get(PdfName.FIRST)));
    //        bookmarkDepthIterative(root, outlines);
    return root;
}