Skip to main content
May 23, 2011
Question

Extract bookmarks from pdf file

  • May 23, 2011
  • 1 reply
  • 5000 views

Hey Guys,

How can i extract the bookmarks from a PDF file.

I am creating a table of contents in a coldfusion 8 page and I need the bookmarks to link the chapters to the pdf pages.

Thanks a lot!!

Sid

    This topic has been closed for replies.

    1 reply

    Inspiring
    May 24, 2011

    You could use a bit of iText to extract the bookmark details (essentially an array of structures) or export them to xml.

    <!--- syntax may differ for cf8 --->

    <cfset input = "c:/path/to/yourFile.pdf">
    <cfset reader = createObject("java", "com.lowagie.text.pdf.PdfReader").init(input)>
    <cfset bookmarks = createObject("java", "com.lowagie.text.pdf.SimpleBookmark").getBookmark(reader)>
    <cfif structKeyExists(variables, "bookmarks")>
        <cfdump var="#bookmarks#">
    </cfif>

    May 24, 2011

    Hey Thanks a lot for code!!!

    I am getting an error saying:

    Object instantiation exception.

    An exception occurred while instantiating a Java object. The class must not

    be an interface or an abstract class. Error: ''. The error occurred

    in *C:\www\xxxxxxxxxxxxx\index.cfm:

    line 5*

    3 :

    4 :

    Thanks a lot!!!

    Sid

    Inspiring
    May 24, 2011

    I am getting an error saying:

     

    Object instantiation exception.

    CF8's version of iText is older. So there might be some syntax differences. Can you post the strack trace? That has the real error message.