- CFML Reference User Guide
- ColdFusion functions
- ColdFusion functions by category
- Functions a-b
- Abs
- ACos
- AddSOAPRequestHeader
- AddSOAPResponseHeader
- AjaxLink
- AjaxOnLoad
- ApplicationStop
- ArrayAppend
- ArrayAvg
- ArrayClear
- ArrayContains
- ArrayContainsNoCase
- ArrayDelete
- ArrayDeleteAt
- ArrayDeleteNoCase
- ArrayEach
- ArrayFilter
- ArrayFind
- ArrayFindAll
- ArrayFindAllNoCase
- ArrayFindNoCase
- ArrayInsertAt
- ArrayIsDefined
- ArrayIsEmpty
- ArrayLen
- ArrayMap
- ArrayMax
- ArrayMin
- ArrayNew
- ArrayPrepend
- ArrayReduce
- ArrayResize
- ArraySet
- ArraySetMetadata
- ArraySlice
- ArraySort
- ArraySum
- ArraySwap
- ArrayToList
- Asc
- ASin
- Atn
- AuthenticatedContext
- AuthenticatedUser
- BinaryDecode
- BinaryEncode
- BitAnd
- BitMaskClear
- BitMaskRead
- BitMaskSet
- BitNot
- BitOr
- BitSHLN
- BitSHRN
- BitXor
- BooleanFormat
- Abs
- Functions-c-d
- CacheGet
- CacheGetAllIds
- CacheGetMetadata
- CacheGetProperties
- CacheGetSession
- CacheIdExists
- CachePut
- CacheRegionExists
- CacheRegionNew
- CacheRegionRemove
- CacheRemove
- CacheRemoveAll
- CacheSetProperties
- CallStackDump
- CallStackGet
- CanDeSerialize
- Canonicalize
- CanSerialize
- Ceiling
- CharsetDecode
- CharsetEncode
- Chr
- CJustify
- Compare
- CompareNoCase
- Cos
- CreateDate
- CreateDateTime
- CreateObject
- CreateObject: .NET object
- CreateObject: COM object
- CreateObject: component object
- CreateObject: CORBA object
- CreateObject: Java or EJB object
- CreateObject: web service object
- CreateODBCDate
- CreateODBCDateTime
- CreateODBCTime
- CreateSignedJWT
- CreateEncryptedJWT
- CreateTime
- CreateTimeSpan
- CreateUUID
- CSRFGenerateToken
- CSRFVerifyToken
- DateAdd
- DateCompare
- DateConvert
- DateDiff
- DateFormat
- DatePart
- DateTimeFormat
- Day
- DayOfWeek
- DayOfWeekAsString
- DayOfYear
- DaysInMonth
- DaysInYear
- DE
- DecimalFormat
- DecodeForHTML
- DecodeFromURL
- DecrementValue
- Decrypt
- DecryptBinary
- DeleteClientVariable
- Deserialize
- DeserializeJSON
- DeserializeXML
- DirectoryCopy
- DirectoryCreate
- DirectoryDelete
- DirectoryExists
- DirectoryList
- DirectoryRename
- DollarFormat
- DotNetToCFType
- Duplicate
- Functions-e-g
- EncodeForCSS
- EncodeForDN
- EncodeForHTML
- EncodeForHTMLAttribute
- EncodeForJavaScript
- EncodeForLDAP
- EncodeForURL
- EncodeForXML
- EncodeForXMLAttribute
- EncodeForXpath
- Encrypt
- EncryptBinary
- EntityDelete
- EntityLoad
- EntityLoadByExample
- EntityLoadByPK
- EntityMerge
- EntityNew
- EntityReload
- EntitySave
- EntityToQuery
- Evaluate
- Exp
- ExpandPath
- FileClose
- FileCopy
- FileDelete
- FileExists
- FileGetMimeType
- FileIsEOF
- FileMove
- FileOpen
- FileRead
- FileReadBinary
- FileReadLine
- FileSeek
- FileSetAccessMode
- FileSetAttribute
- FileSetLastModified
- FileSkipBytes
- FileUpload
- FileUploadAll
- FileWrite
- FileWriteLine
- Find
- FindNoCase
- FindOneOf
- FirstDayOfMonth
- Fix
- Floor
- FormatBaseN
- GeneratePBKDFKey
- GenerateSecretKey
- GetApplicationMetadata
- GetAuthUser
- GetBaseTagData
- GetBaseTagList
- GetBaseTemplatePath
- GetClientVariablesList
- GetComponentMetaData
- GetContextRoot
- GetCPUUsage
- GetCurrentTemplatePath
- GetDirectoryFromPath
- GetEncoding
- GetException
- GetFileFromPath
- GetFileInfo
- GetFreeSpace
- GetFunctionCalledName
- GetFunctionList
- GetGatewayHelper
- GetHttpRequestData
- GetHttpTimeString
- GetK2ServerDocCount
- GetK2ServerDocCountLimit
- GetLocale
- GetLocaleDisplayName
- GetLocalHostIP
- GetMetaData
- GetMetricData
- GetPageContext
- GetPrinterInfo
- GetPrinterList
- GetProfileSections
- GetProfileString
- GetReadableImageFormats
- GetSafeHTML
- GetSAMLAuthRequest
- GetSAMLLogoutRequest
- GenerateSAMLSPMetadata
- GetSOAPRequest
- GetSOAPRequestHeader
- GetSOAPResponse
- GetSOAPResponseHeader
- GetSystemFreeMemory
- GetSystemTotalMemory
- GetTempDirectory
- GetTempFile
- GetTemplatePath
- GetTickCount
- GetTimeZoneInfo
- GetToken
- GetTotalSpace
- GetUserRoles
- GetVFSMetaData
- GetWriteableImageFormats
- Functions-h-im
- Hash
- HMac
- Hour
- HQLMethods
- HTMLCodeFormat
- HTMLEditFormat
- IIf
- ImageAddBorder
- ImageBlur
- ImageClearRect
- ImageCopy
- ImageCreateCaptcha
- ImageCrop
- ImageDrawArc
- ImageDrawBeveledRect
- ImageDrawCubicCurve
- ImageDrawLine
- ImageDrawLines
- ImageDrawOval
- ImageDrawPoint
- ImageDrawQuadraticCurve
- ImageDrawRect
- ImageDrawRoundRect
- ImageDrawText
- ImageFlip
- ImageGetBlob
- ImageGetBufferedImage
- ImageGetEXIFMetadata
- ImageGetEXIFTag
- ImageGetHeight
- ImageGetIPTCMetadata
- ImageGetIPTCTag
- ImageGetMetadata
- ImageGetWidth
- ImageGrayscale
- ImageInfo
- ImageMakeColorTransparent
- ImageMakeTranslucent
- ImageNegative
- ImageNew
- ImageOverlay
- ImagePaste
- ImageRead
- ImageReadBase64
- ImageResize
- ImageRotate
- ImageRotateDrawingAxis
- ImageScaleToFit
- ImageSetAntialiasing
- ImageSetBackgroundColor
- ImageSetDrawingColor
- ImageSetDrawingStroke
- ImageSetDrawingTransparency
- ImageSharpen
- ImageShear
- ImageShearDrawingAxis
- ImageTranslate
- ImageTranslateDrawingAxis
- ImageWrite
- ImageWriteBase64
- ImageXORDrawingMode
- Functions-in-k
- IncrementValue
- InputBaseN
- Insert
- Int
- InvalidateOauthAccesstoken
- Invoke
- InitSAMLAuthRequest
- InitSAMLLogoutRequest
- InvokeCFClientFunction
- IsArray
- IsAuthenticated
- IsAuthorized
- IsBinary
- IsBoolean
- IsClosure
- IsCustomFunction
- IsDate
- IsDateObject
- IsDDX
- IsDebugMode
- IsDefined
- IsImage
- IsImageFile
- IsInstanceOf
- IsIPv6
- IsJSON
- IsK2ServerABroker
- IsK2ServerDocCountExceeded
- IsK2ServerOnline
- IsLeapYear
- IsLocalHost
- IsNull
- IsNumeric
- IsNumericDate
- IsObject
- isOnline
- IsPDFArchive
- IsPDFFile
- IsPDFObject
- IsProtected
- IsQuery
- isSamlLogoutResponse
- isSafeHTML
- IsSimpleValue
- IsSOAPRequest
- IsSpreadsheetFile
- IsSpreadsheetObject
- IsStruct
- IsUserInAnyRole
- IsUserInRole
- IsUserLoggedIn
- IsValid
- IsValidOauthAccesstoken
- IsWDDX
- IsXML
- IsXmlAttribute
- IsXmlDoc
- IsXmlElem
- IsXmlNode
- IsXmlRoot
- JavaCast
- JSStringFormat
- Functions-l
- LCase
- Left
- Len
- ListAppend
- ListChangeDelims
- ListContains
- ListContainsNoCase
- ListDeleteAt
- ListEach
- ListFilter
- ListFind
- ListFindNoCase
- ListFirst
- ListGetAt
- ListInsertAt
- ListLast
- ListLen
- ListMap
- ListPrepend
- ListQualify
- ListReduce
- ListRemoveDuplicates
- ListRest
- ListSetAt
- ListSort
- ListToArray
- ListValueCount
- ListValueCountNoCase
- LJustify
- Location
- Log
- Log10
- LSCurrencyFormat
- LSDateFormat
- LSDateTimeFormat
- LSEuroCurrencyFormat
- LSIsCurrency
- LSIsDate
- LSIsNumeric
- LSNumberFormat
- LSParseCurrency
- LSParseDateTime
- LSParseEuroCurrency
- LSParseNumber
- LSTimeFormat
- LTrim
- Functions-m-r
- Max
- Mid
- Min
- Minute
- Month
- MonthAsString
- Now
- NumberFormat
- ObjectEquals
- ObjectLoad
- ObjectSave
- OnWSAuthenticate
- ORMClearSession
- ORMCloseAllSessions
- ORMCloseSession
- ORMEvictCollection
- ORMEvictEntity
- ORMEvictQueries
- ORMExecuteQuery
- ORMFlush
- ORMFlushall
- ORMGetSession
- ORMGetSessionFactory
- ORMIndex
- ORMIndexPurge
- ORMReload
- ORMSearch
- ORMSearchOffline
- ParagraphFormat
- ParameterExists
- ParseDateTime
- Pi
- PrecisionEvaluate
- ProcessSAMLResponse
- ProcessSAMLLogoutRequest
- Quarter
- PreserveSingleQuotes
- QueryAddColumn
- QueryAddRow
- QueryConvertForGrid
- QueryExecute
- QueryFilter
- QueryGetResult
- QueryGetRow
- QueryKeyExists
- QueryMap
- QueryNew
- QueryReduce
- QuerySetCell
- QuotedValueList
- QueryEach
- Rand
- Randomize
- RandRange
- ReEscape
- REFind
- REFindNoCase
- ReleaseComObject
- REMatch
- REMatchNoCase
- RemoveCachedQuery
- RemoveChars
- RepeatString
- Replace
- ReplaceList
- ReplaceNoCase
- REReplace
- REReplaceNoCase
- RestDeleteApplication
- RestSetResponse
- RestInitApplication
- Reverse
- Right
- RJustify
- Round
- RTrim
- Functions-s
- Second
- SendGatewayMessage
- SendSAMLLogoutResponse
- Serialize
- SerializeJSON
- SerializeXML
- SessionInvalidate
- SessionRotate
- SessionGetMetaData
- SessionInvalidate
- SessionRotate
- SetDay
- SetEncoding
- SetHour
- SetLocale
- SetMonth
- SetProfileString
- SetVariable
- SetYear
- Sgn
- Sin
- Sleep
- SpanExcluding
- SpanIncluding
- SpreadsheetAddAutoFilter
- SpreadsheetAddColumn
- SpreadsheetAddFreezePane
- SpreadsheetAddImage
- SpreadsheetAddInfo
- SpreadsheetAddPageBreaks
- SpreadsheetAddRow
- SpreadsheetAddRows
- SpreadsheetAddSplitPane
- SpreadsheetCreateSheet
- SpreadsheetDeleteColumn
- SpreadsheetDeleteColumns
- SpreadsheetDeleteRow
- SpreadsheetDeleteRows
- SpreadsheetFormatCell
- SpreadsheetFormatColumn
- SpreadsheetFormatCellRange
- SpreadsheetFormatColumn
- SpreadsheetFormatColumns
- SpreadsheetFormatRow
- SpreadsheetFormatRows
- SpreadsheetGetCellComment
- SpreadsheetGetCellFormula
- SpreadsheetGetCellValue
- SpreadsheetGetColumnCount
- SpreadsheetInfo
- SpreadsheetMergeCells
- SpreadsheetNew
- SpreadsheetRead
- SpreadsheetReadBinary
- SpreadsheetRemoveSheet
- SpreadsheetSetActiveSheet
- SpreadsheetSetActiveSheetNumber
- SpreadsheetSetCellComment
- SpreadsheetSetCellFormula
- SpreadsheetSetCellValue
- SpreadsheetSetColumnWidth
- SpreadsheetSetFooter
- SpreadsheetSetHeader
- SpreadsheetSetRowHeight
- SpreadsheetShiftColumns
- SpreadsheetShiftRows
- SpreadsheetWrite
- Sqr
- StripCR
- StructAppend
- StructClear
- StructCopy
- StructCount
- StructDelete
- StructEach
- StructFilter
- StructFind
- StructFindKey
- StructFindValue
- StructGet
- StructGetMetadata
- StructInsert
- StructIsEmpty
- StructKeyArray
- StructKeyExists
- StructKeyList
- StructMap
- StructNew
- StructReduce
- StructSetMetadata
- StructSort
- StructToSorted
- StructUpdate
- StoreSetMetadata
- StoreGetACL
- StoreGetMetadata
- StoreAddACL
- StoreSetACL
- Functions-t-z
- Tan
- ThreadJoin
- ThreadTerminate
- Throw
- TimeFormat
- ToBase64
- ToBinary
- ToScript
- ToString
- Trace
- Transactionandconcurrency
- TransactionCommit
- TransactionRollback
- TransactionSetSavePoint
- Trim
- UCase
- URLDecode
- URLEncodedFormat
- URLSessionFormat
- Val
- ValueList
- VerifyClient
- Week
- Wrap
- WriteDump
- WriteLog
- WriteOutput
- WSGetAllChannels
- WSGetSubscribers
- WSPublish
- WSSendMessage
- XmlChildPos
- XmlElemNew
- XmlFormat
- XmlGetNodeType
- XmlNew
- XmlParse
- XmlSearch
- XmlTransform
- XmlValidate
- Year
- YesNoFormat
- ColdFusion Tags
- ColdFusion tag summary
- ColdFusion tags by category
- Application framework tags
- Communications tags
- Database manipulation tags
- Data output tags
- Debugging tags
- Exception handling tags
- Extensibility tags
- File management tags
- Flow-control tags
- Forms tags
- Internet Protocol tags
- Page processing tags
- Security tags
- Variable manipulation tags
- Other tags
- Tags a-b
- Tags c
- Tags f
- cffeed
- cffile
- cffile action = "append"
- cffile action = "copy"
- cffile action = "delete"
- cffile action = "move"
- cffile action = "read"
- cffile action = "readBinary"
- cffile action = "rename"
- cffile action = "upload"
- cffile action = "uploadAll"
- cffile action = "write"
- cffileupload
- cffinally
- cfflush
- cfform
- cfformgroup
- cfformitem
- cfftp
- cfftp: Connection: file and directory operations
- cfftp: Opening and closing FTP server connections
- cfftp : Opening and closing secure FTP server connections
- cfftp action = "listDir"
- cffunction
- Tags g-h
- Tags i
- Tags j-l
- cfjava
- cflayout
- cflayoutarea
- cfldap
- cflocation
- cflock
- cflog
- cflogin
- cfloginuser
- cflogout
- cfloop
- cfloop : conditional loop
- cfloop : index loop
- cfloop : looping over a COM collection or structure
- cfloop : looping over a date or time range
- cfloop : looping over a list, a file, or an array
- cfloop : looping over a query
- Tags m-o
- cfmail
- cfmailparam
- cfmailpart
- cfmap
- cfmapitem
- cfmediaplayer
- cfmenu
- cfmenuitem
- cfmessagebox
- cfmodule
- cfNTauthenticate
- cfoauth
- cfobject
- cfobject: .NET object
- cfobject: COM object
- cfobject: component object
- cfobject: CORBA object
- cfobject: Java or EJB object
- cfobject: web service object
- cfobjectcache
- cfoutput
- Tags p-q
- Tags r-s
- Tags t
- Tags u-z
- CFML Reference
- Reserved words and variables
- Ajax JavaScript functions
- Ajax JavaScript functions
- Function summary Ajax
- ColdFusion.Ajax.submitForm
- ColdFusion.Autosuggest.getAutosuggestObject
- ColdFusion.Layout.enableSourceBind
- ColdFusion.MessageBox.getMessageBoxObject
- ColdFusion.ProgressBar.getProgressBarObject
- ColdFusion.MessageBox.isMessageBoxDefined
- JavaScriptFunctionsinColdFusion9Update1
- ColdFusion ActionScript functions
- ColdFusion mobile functions
- Application.cfc reference
- Script functions implemented as CFCs
- ColdFusion Flash Form style reference
- Styles valid for all controls
- Styles for cfform
- Styles for cfformgroup with horizontal or vertical type attributes
- Styles for box-style cfformgroup elements
- Styles for cfformgroup with accordion type attribute
- Styles for cfformgroup with tabnavigator type attribute
- Styles for cfformitem with hrule or vrule type attributes
- Styles for cfinput with radio, checkbox, button, image, or submit type attributes
- Styles for cftextarea tag and cfinput with text, password, or hidden type attributes
- Styles for cfselect with size attribute value of 1
- Styles for cfselect with size attribute value greater than 1
- Styles for cfcalendar tag and cfinput with dateField type attribute
- Styles for the cfgrid tag
- Styles for the cftree tag
- ColdFusion Flash Form Style Reference
- ColdFusion event gateway reference
- ColdFusion Event Gateway reference
- addEvent
- CFEvent
- CFEventclass
- Constructor
- Gateway development interfaces and classes
- getStatus
- setCFCPath
- setCFCMethod
- getOriginatorID
- getLogger
- getBuddyList
- getBuddyInfo
- IM gateway message sending commands
- IM Gateway GatewayHelper class methods
- onIncomingMessage
- onIMServerMessage
- onBuddyStatus
- onAddBuddyResponse
- onAddBuddyRequest
- IM Gateway CFC incoming message methods
- IM gateway methods and commands
- CFML CFEvent structure
- warn
- info
- setOriginatorID
- data command
- submit Multi command
- submit command
- setGatewayType
- setGatewayID
- setData
- setCFCListeners
- outgoingMessage
- getStatusTimeStamp
- numberOfMessagesReceived
- numberOfMessagesSent
- removeBuddy
- removeDeny
- removePermit
- setNickName
- setPermitMode
- setStatus
- SMS Gateway CFEvent structure and commands
- SMS Gateway incoming message CFEvent structure
- getStatusAsString
- getProtocolName
- getPermitMode
- getPermitList
- getNickName
- getName
- getDenyList
- getCustomAwayMessage
- getQueueSize
- getMaxQueueSize
- getHelper
- getGatewayType
- getGatewayServices
- getGatewayID_1
- getGatewayID
- getData
- getCFCTimeout
- setCFCTimeout
- getCFCPath
- getCFCMethod
- GatewayServices class
- Gateway interface
- GatewayHelper interface
- addPermit
- addDeny
- addBuddy
- error
- debug
- Logger class
- stop
- start
- CFML event gateway SendGatewayMessage data parameter
- restart
- fatal
- SMS gateway message sending commands
- ColdFusion C++ CFX Reference
- ColdFusion Java CFX reference
- WDDX JavaScript Objects
- Cloud services
- ColdFusion and GCP Storage
- ColdFusion and GCP Firestore
- ColdFusion and GCP PubSub
- ColdFusion and Amazon S3
- ColdFusion and DynamoDB
- ColdFusion and Amazon SQS
- ColdFusion and Amazon SNS
- ColdFusion and MongoDB
- ColdFusion and Azure Blob
- ColdFusion and Azure Service Bus
- Multi-cloud storage services
- Multi-cloud RDS databases
- ColdFusion and Azure Cosmos DB
Description
Manipulates existing forms created in Adobe Acrobat and Adobe LiveCycle Designer. The following list describes some of the tasks you can perform with the cfpdfform tag:
- Embed an interactive form created in Acrobat LiveCycle in a PDF document. You use the cfpdfform tag to embed the PDF form in a cfdocument tag.
- Render an existing form created in Acrobat or LiveCycle. This includes prefilling fields from a database or an XML data file and processing form data from an HTTP post or PDF submission.
- Extract or prefill values in stored PDF forms and save the output to a file or use it to update a data source.
History
ColdFusion 8: Added this tag.
Category
Syntax
populate <cfpdfform required name=" PDF document variable name" action = "populate" source = "PDF file pathname|byte array" optional XMLdata = "XML object|XML string|XML data filename| URL that returns XML data" destination = "output file pathname" overwrite = "yes|no"/ fdf = "true|false> <!---New attribute that populates data in FDF format instead of XML with subforms and params---> fdfdata = "file name to be imported" <!--- New attribute populates data in FDF format from the AcroForm---> read <cfpdfform required action = "read" source = "pathname|byte array" at least one of the following: XMLdata = "variable name for XML data" result = "structure containing form field values" optional overwrite = "yes|no"/> fdfdata = "filename to be exported to"
You can specify this tag's attributes in an attributeCollection attribute whose value is a structure. Specify the structure name in the attributeCollection attribute and use the tag's attribute names as structure keys.
See also
cfdocument, cfdocumentsection, cfform, cfinput, cfpdf, cfpdfformparam, cfpdfparam, cfpdfsubform,
cfrint, IsPDFFile, IsPDFObject, Manipulating PDF Forms in ColdFusion
in the Developing ColdFusion Applications
Attributes
Attribute |
Action |
Req/Opt |
Default |
Description |
---|---|---|---|---|
name | NA | Optional | Specify the PDF document variable name, for example, myPDF. If the source is a PDF document variable, you cannot specify the name attribute again. | |
action |
NA |
Required |
|
Action to perform on the source:
|
destination |
populate |
Optional |
Write to browser |
Pathname for the output file. You can specify an absolute pathname or a pathname relative to the context root. |
overwrite |
populate read |
Optional |
no |
Specifies whether to overwrite the destination file (if action="populate") or the data file (if action="read"):
|
overwriteData |
populate |
Optional |
no |
Specifies whether to overwrite existing data in PDF form fields with data from the data source:
Note: The flag, overwriteData="false" does not work as expected if you are reading the file using xmlData or fdfData. This behavior is seen in ColdFusion (2018 release), ColdFusion (2016 release), and ColdFusion 11. |
result |
read |
Optional(see Description) |
|
ColdFusion structure that contains the form field values.Specify the XMLdata attribute or the result attribute; you can specify both. |
source |
populate read |
Required |
|
Pathname of the source PDF (absolute on-disk or in-memory path, or path relative to the context root) or byte array representing a PDF. |
XMLdata |
populate read |
Optional(see Description) |
|
Pathname for the XML data file.
|
fdf |
populate |
Optional |
false |
If set to true, the system creates FDF with subforms and params instead of an XML |
fdfdata |
populateread |
Optional |
|
For populate, you specify the file name from where the FDF data is imported. |
Usage
ColdFusion supports two types of interactive forms: forms created in Adobe Acrobat 6.0 or earlier, and forms created in Adobe LiveCycle. In Adobe Acrobat Professional and Standard 7.0, Adobe introduced Adobe LiveCycle Designer for creating PDF forms. ColdFusion supports forms created in LiveCycle Designer 7.0 and later.
Forms created in Acrobat have a flat structure: a list of fields at the same level. Forms created in LiveCycle Designer are hierarchical, often composed of nested subforms. To map the data to the form field, you use cfpdfsubform tags to recreate the structure of the form in ColdFusion. For examples, see the Usage section of the cfpdfsubform tag, and " Manipulating PDF Forms in ColdFusion in the Developing ColdFusion Applications.
populate action Use the populate action to populate PDF form fields from the specified data file. You can specify a destination to write the output to a file or write the populated form directly to the browser. To display the interactive PDF form in the browser, do not specify a destination.
The following example shows how to populate a PDF form with an XML data file and display the completed form in a browser:
<cfpdfform source="c:\payslipTemplate.pdf" action="populate" XMLdata="c:\formdata.xml"/>
This example shows how to populate a PDF form with an XML data file and write the completed form to a new PDF file:
<!--- Specify an XML file to populate a PDF form. ---> <cfpdfform source="c:\payslipTemplate.pdf" destination="c:\employeeid123.pdf" action="populate" XMLdata="c:\formdata.xml"/>
Also, you can specify a URL that returns XML data. In the following example, "http://test1.com/xyz"returns XML content:
<cfpdfform source= "#sourcefile#" action="populate" XMLdata= "http://test1.com/xyz" destination="#resultfile#" overwrite="true"/>
For forms created in Acrobat, you can write the output to a PDF file only. For forms created in LiveCycle, you have the option to write the output to an XML Data Package (XDP) file. An XDP file is an XML representation of a PDF file.
Supplied values in form fields created in Acrobat or LiveCycle Designer are case sensitive. For example, if a check box in a form requires a "Yes" value, the value "yes" does not populate that field.
The file extension determines the file format: to save the output in XDP format, use an XDP extension in the destination filename:
<!--- Specify a an XML file to populate a PDF form. ---> <cfpdfform source="c:\payslipTemplate.pdf" destination="c:\employeeid123.xdp" action="populate" XMLdata="c:\formdata.xml"/>
You can use one or more cfpdfformparam tags within a cfpdfform tag to populate individual fields in a PDF form.
The following example shows how to populate an existing form created in Acrobat (payslipTemplate.pdf) and create a PDF form (employeeid123.pdf) with the employeeID and salary fields filled in:
<!--- This example shows how to populate two fields in a form created in Acrobat. ---> <cfpdfform source="c:\payslipTemplate.pdf" destination="c:\employeeid123.pdf" action="populate"> <cfpdfformparam name="employeeId" value="123"> <cfpdfformparam name="salary" value="$85,000"> </cfpdfform>
ColdFusion requires that you reproduce the exact structure of the source PDF form to populate fields. To verify the structure of a PDF form in ColdFusion, use the read action of cfpdfform tag, and then use the cfdump tag to display the result structure. Use a cfpdfsubform tag for each level within the structure. For more information, see Manipulating PDF Forms in ColdFusion in the Developing ColdFusion Applications.
The following example shows how to populate a form created in LiveCycle. Many forms created from templates in LiveCycle contain a subform called form1. Use the cfpdfsubformtag to create a subform in ColdFusion.
<!--- This example shows how to populate two fields in a LiveCycle form. ---> <cfpdfform source="c:\payslipTemplate.pdf" destination="c:\employeeid123.pdf" action="populate"> <cfpdfsubform name="form1"> <cfpdfformparam name="employeeId" value="123"> <cfpdfformparam name="salary" value="$85,000"> </cfpdfsubform> </cfpdfform>
You can now import files in FDF format using the populateaction. The following example shows how:
<cfpdfform source= "write_acrroform.pdf" action="populate" fdfdata="abc.fdf" destination="hello.pdf"> </cfpdfform>
If the fdf attribute for the populate action is set to true, it allows you to populate data in FDF format with subforms and params instead of XML, as shown in the following example:
<cfpdfform source="acroform2.pdf" destination="source_result17.pdf" action="populate" overwrite="true" fdf="true"> <cfpdfsubform name="Text1"> <cfpdfsubform name="0"> <cfpdfformparam name="0" value="Test1.0.0"> <cfpdfformparam name="1" value="Test1.0.1"> <cfpdfformparam name="2" value="Test1.0.2"> </cfpdfsubform> <cfpdfsubform name="1"> <cfpdfformparam name="0" value="Test1.1.0"> <cfpdfformparam name="1" value="Test1.1.1"> <cfpdfformparam name="2" value="Test1.1.2"> </cfpdfsubform> </cfpdfsubform> <cfpdfsubform name="Text2"> <cfpdfformparam name="0" value="Test2.0"> <cfpdfformparam name="1" value="Test2.1"> <cfpdfformparam name="2" value="Test2.2"> <cfpdfformparam name="3" value="Test2.3"> </cfpdfsubform> <cfpdfformparam name="Text3" value="Test3"> <cfpdfformparam name="Text4" value="Test4"> <cfpdfformparam name="checkbox1" value="Yes"> <cfpdfformparam name="listbox1" value="item4"> <cfpdfformparam name="radiobutton1" value="2"> </cfpdfform>
- read action Use the read action to read the data from the source PDF form and generate a result structure that contains the form fields and their values. Also, you can use the read action to generate an XML data file from a PDF source file.
The following example shows how to read a PDF file and generate a result structure from the data:
<!--- Use the read action to retrieve the values from the saved PDF. ---> <cfpdfform source="c:\employeeid123.pdf" result="resultStruct" action="read"/>
You can use the cfdumptag to display the result structure:
<cfdump var="#resultStruct#">
You can use the result fields in ColdFusion, for example, #resultStruct.employeeId# and #resultStruct.salary#.
The following example shows how to read a PDF file and write the data to an XML file:
<cfpdfform source="c:\employeeid123.pdf" result="c:\employeeid123.xml" overwrite="yes" action="read"/>
The following example shows how to read a PDF file into a variable that contains XML data:
<cfpdfform source="c:\employeeid123.pdf" XMLdata="myXMLdata" action="read"/>
The following example shows how to read a PDF file into an XML data variable and generate a result structure. The cffiletag writes the data to an XML file:
<cfset sourcefile = "Grant Application Updated.pdf"> <cfset resultfile = "Expandpath('datafile_result1.xml')"> <!--- Use the cfpdfform tag to read data extracted from a form into an XML data variable and generate a result structure. ---> <cfpdfform source= "#sourcefile#" action="read" xmldata="xmldata" result="resultstruct"/> <!--- Use the cffile tag to write the XML data to a file. ---> <cffile action="write"file="#resultfile#" output="#xmldata#"> <!---- Use the cfdump tag to display the result structure. ---> <cfdump var="#resultstruct#">
Extracting data from a PDF submission
Use the following code to extract data from a PDF submission and write it to a structure called fields:
<!--- The following code reads the submitted PDF file and generates a result structure called fields. ---> <cfpdfform source="#PDF.content#" action="read" result="fields"/>
Use the cfdump tag to display the data structure, as follows:
<cfdump var="#fields#">
When you extract data from a PDF submission, always specify "#PDF.content#" as the source.
You can set the form fields to a variable, as the following code shows:
<cfset empForm="#fields.form1#">
Use the populate action of the cfpdfform tag to write the output to a file. Specify "#PDF.content#" as the source. In the following example, the unique filename is generated from a field on the PDF form:
<cfpdfform action="populate" source="#PDF.content#" destination="timesheets\#empForm.txtsheet#.pdf" overwrite="yes"/>
Extracting data from an HTTP post submission
An HTTP post submission transmits the data from the PDF form, but not the form itself. You can extract data from the PDF form fields, but you cannot write the output directly to a file. To extract the data and update a database, for example, you must map the fields in the database to the structure and HTTP post data exactly.
The structure of the HTTP post data (after submission) is not the same as the structure of the PDF form (before data submission). For examples of both, see Manipulating PDF Forms in ColdFusion in the Developing ColdFusion Applications.
To determine the structure of the HTTP post data, use the cfdump tag with the form name as the variable to display the data structure, as follows:
<cfdump var="#FORM.form1#">
When you extract data from an HTTP post submission, always specify the form name as the source. For example, specify "#FORM.form1#" for a form generated from a template in LiveCycle Designer. When data extraction that uses the cfpdfform tag results in more than one page, instead of returning one structure, ColdFusion returns one structure per page.
Embedding PDF forms within a PDF document
You can use the cfpdfform tag inside the cfdocument tag to embed an existing interactive PDF form within a PDF document. Use at least one cfdocumentsection tag with the cfpdfform tag, but do not place the cfpdfform tag within the cfdocumentsection tag. For more information about embedding PDF forms, see Manipulating PDF Forms in ColdFusion in the Developing ColdFusion Applications.
Flattening forms created in Acrobat
You use the cfpdf tag to flatten forms created in Acrobat. ColdFusion does not support flattening forms created in LiveCycle. For more information, see Assembling PDF Documents in the Developing ColdFusion Applications.
Printing forms
Use the cfprint tag to print forms created in Acrobat. Markups, such as sticky notes, comments, and editorial revisions, are not printed with the form. You cannot use the cfprint tag to print forms created in LiveCycle Designer.
Exporting PDF Forms in FDF
You can export PDF forms in FDF format using the read action. The following example shows how you can export a PDF form in FDF format:
<cfpdfform source= "acroform_export.pdf" action="read" fdfdata="abc.fdf" > </cfpdfform>
Example
The following example shows how to embed an interactive PDF form in a PDF document created with the cfdocument tag:
<!--- The following code extracts data from the cfdocexamples database based on a username entered in a login form. ---> <cfquery name="getEmpInfo" datasource="cfdocexamples"> SELECT * FROM EMPLOYEES WHERE EMAIL = <cfqueryparam value="#form.username#"> </cfquery> <!--- The following code creates a PDF document with headers and footers. ---> <cfdocument format="pdf"> <cfdocumentitem type="header"> <font size="-1" align="center"><i>Nondisclosure Agreement</i></font> </cfdocumentitem> <cfdocumentitem type="footer"> <font size="-1"><i>Page <cfoutput>#cfdocument.currentpagenumber# of #cfdocument.totalpagecount#</cfoutput></i></font> </cfdocumentitem> <!--- The following code creates the first section in the PDF document. ---> <cfdocumentsection> <h3>Employee Nondisclosure Agreement</h3> <p>Please verify the information in the enclosed form. Make any of the necessary changes in the online form and click the <b>Print</b> button. Sign and date the last page. Staple the pages together and return the completed form to your manager.</p> </cfdocumentsection> <!--- The following code embeds an interactive PDF form within the PDF document with fields populated by the database query. The cfpdpfform tag automatically creates a section in the PDF document. Do not embed the cfpdfform within cfdocumentsection tags. ---> <cfpdfform action="populate" source="c:\forms\embed.pdf"> <cfpdfsubform name="form1"> <cfpdfformparam name="txtEmpName" value="#getEmpInfo.FIRSTNAME# #getEmpInfo.LASTNAME#"> <cfpdfformparam name="txtDeptName" value="#getEmpInfo.DEPARTMENT#"> <cfpdfformparam name="txtEmail" value="#getEmpInfo.IM_ID#"> <cfpdfformparam name="txtPhoneNum" value="#getEmpInfo.PHONE#"> <cfpdfformparam name="txtManagerName" value="Randy Nielsen"> </cfpdfsubform> </cfpdfform> <!--- The following code creates the last document section. Page numbering resumes in this section. ---> <cfdocumentsection> <p>I, <cfoutput>#getEmpInfo.FIRSTNAME# #getEmpInfo.LASTNAME#</cfoutput>, hereby attest that the information in this document is accurate and complete.</p> <br/><br/> <table border="0" cellpadding="20"> <tr><td width="300"> <hr /> <p><i>Signature</i></p></td> <td width="150"><hr /> <p><i>Today's Date</i></p></td></tr> </cfdocumentsection> </cfdocument>