3 Replies Latest reply on May 11, 2011 11:20 AM by -==cfSearching==-

    Getting PDF annotations in ColdFusion

    The Albino Level 1

      Currently, I am using coldfusion 9 and I am trying to get information about annotations from within a PDF file.  The problem is that there are two types of annotations: text and popup.  I am using iText and I can get an annotation array that has 7 objects.


      <cfset reader = CreateObject("java","com.lowagie.text.pdf.PdfReader").init(expandPath("test.pdf"))>

      <cfset pageDict = reader.getPageN(1)>

      <cfset pdfname = createObject("java","com.lowagie.text.pdf.PdfName")>

      <cfset annots = pageDict.getAsArray(pdfname.ANNOTS)>


      So now I see that I have 7 annotations ( I know one is text, and the other 6 are popup). At this point I want to loop through the annotation array and get the informartion


      <cfset iterator = annots.listIterator()>
      <cfloop condition="iterator.hasNext()">
             <cfset annot = reader.getPdfObject(iterator.next())>
             <cfset content = reader.getPdfObject(annot.get(pdfname.CONTENTS))>
             <cfif not isNull(content)>

                     Text Comment =#content#    <!--- This works for the text comments --->
                     <!--- This happends to be the Popup contents, and where I get lost ---->



      So in the part where I am trying to get the popup contents, I have tried <cfset x  = reader.getPdfObject(annot.getAsDict(pdfname.popup))>  This works, but I can't seem to extract the data.  All I need is to get either the Subject or Name from the popup innotation as they are set to a set number of possibilities in our system.  How do I extract the name or subject info drom the popup object?