Skip to main content
Inspiring
June 13, 2011
Question

Determining if a PDF is signed using CFPDFFORM

  • June 13, 2011
  • 1 reply
  • 928 views

I have a PDF which contains form data, including multiple signature fields.  Is there a means to determine if any of the signatures within the PDF form have been filled programmatically?  When I use the CFPDFFORM ACTION="read" tag, it only returns those fields which are not signature fields.

Much regards

    This topic has been closed for replies.

    1 reply

    jmaitinoAuthor
    Inspiring
    June 13, 2011

    Answered my own question in the form of a function, this accepts a PDF file and returns a list of all signed signature fields names.


    <cffunction name="pdfGetSignedFields" returntype="string" output="false">
    <cfargument name="pgsFile" type="string" required="yes">
    <cfset pgsAns="">
    <cfif FileExists(pgsFile)>
      <cfset pgsReader=CreateObject("java","com.lowagie.text.pdf.PdfReader").init(pgsFile)>
      <cfset pgsAcroFields=pgsReader.getAcroFields()>
      <cfset pgsAns=ArrayToList(pgsAcroFields.getSignatureNames(),",")>   
    </cfif>
    <cfreturn pgsAns>
    </cffunction>

    Participating Frequently
    June 13, 2011

    Don't forget to var scope your function variables.

    jmaitinoAuthor
    Inspiring
    June 13, 2011

    Good point...


    <cffunction name="pdfGetSigned" returntype="string" output="false">
    <cfargument name="pgsFile" type="string" required="yes">
    <cfset var.pgsAns="">
    <cfif FileExists(pgsFile)>
      <cfset var.pgsReader=CreateObject("java","com.lowagie.text.pdf.PdfReader").init(pgsFile)>
      <cfset var.pgsAcroFields=var.pgsReader.getAcroFields()>
      <cfset var.pgsAns=ArrayToList(var.pgsAcroFields.getSignatureNames(),",")>   
    </cfif>
    <cfreturn var.pgsAns>
    </cffunction>