<cfpdf>
Manipulates existing PDF documents.
The following list describes some of the tasks you can perform with the cfpdf tag:
- Merge several PDF documents into one PDF document.
- Delete pages from a PDF document.
- Merge pages from one or more PDF documents and generate a new PDF document.
- Linearize PDF documents for faster web display.
- Remove interactivity from forms created in Acrobat(c) to generate flat PDF documents.
- Encrypt and add password protection to PDF documents.
- Generate thumbnail images from PDF documents or pages. (not implemented yet)
- Add or remove watermarks from PDF documents or pages.
- Retrieve information associated with a PDF document, such as the software used to generate the file or the author, and set information for a PDF document, such as the title, author and keywords.
- Create PDF portfolios
- Add and remove header/footer from PDF documents
- Optimize PDF documents
- Extract all the words from the pdf
- Extract images from PDF documents using the
extractimageaction.
This tag may have a body.
This tag is also supported within <cfscript>
Requires Extension: PDF Extension for Jakarta EE (Lucee 7+)
<cfpdf
action=addHeader|addFooter|addWatermark|deletePages|extractBookmarks|extractImage|extractText|getInfo|merge|open|removePassword|protect|read|removeWatermark|setInfo|thumbnail|write
ascending=boolean
type=string
copyFrom=any
ddxfile=string
destination=string
directory=string
encrypt=string
flatten=boolean
foreground=boolean
format=string
image=any
imagePrefix=string
filter=string
info=struct
inputFiles=struct
isBase64=boolean
keepBookmark=boolean
name=string
newOwnerPassword=string
newUserPassword=string
opacity=number
order=string
outputFiles=struct
overwrite=boolean
pages=string
password=string
permissions=string
position=string
resolution=string
rotation=number
saveOption=string
scale=number
showOnPrint=boolean
source=any
stopOnError=boolean
transparent=boolean
version=number
text=string
numberformat=NUMERIC|LOWERCASEROMAN|UPPERCASEROMAN
align=left|right|center
leftmargin=numeric
rightmargin=numeric
topmargin=numeric
bottommargin=numeric
><!--- body --->[</cfpdf>]
Merge PDF documents
action="merge" - Merges several PDF documents into one PDF document
| Attribute | Description |
|---|---|
|
action
string, optional
|
edit
Note:
|
|
source
any, optional
|
edit
PDF document used as the source. |
|
directory
string, optional
|
edit
Directory of the PDF documents to merge. You must specify either the directory attribute or the source attribute. If you specify the directory attribute, CFML orders the documents by filename in descending order, by default. To change the order of the files, use the order attribute. |
|
filter
string, optional
|
edit
file filter, used with attribute directory |
|
ascending
boolean, optional
|
edit
Order in which the PDF files are sorted |
|
stopOnError
boolean, optional
|
edit
Valid only if the directory attribute is specified. If the specified directory contains files other then readable PDF files, Lucee either stops merge process or continues. |
|
destination
string, optional
|
edit
Pathname of the modified PDF document. If the destination file exists, you must set the overwrite attribute to yes. If the destination file does not exist, CFML creates the file, if the parent directory exists. |
|
name
string, optional
|
edit
PDF document variable name Alias: variable |
|
overwrite
boolean, optional
|
edit
Specifies whether PDF output overwrites the destination file |
|
keepBookmark
boolean, optional
|
edit
Specifies whether bookmarks from the source PDF documents are retained in the merged document |
|
version
number, optional
|
edit
Version of the PDF used to write the document |
Read a PDF document
action="read" - Reads a PDF document and stores it in a variable
| Attribute | Description |
|---|---|
|
action
string, optional
|
edit
Note:
|
|
source
any, optional
|
edit
PDF document used as the source. |
|
name
string, optional
|
edit
PDF document variable name Alias: variable |
|
password
string, optional
|
edit
Owner or user password of the source PDF document, if the document is password-protected. |
Write a PDF document
action="write" - Writes a PDF document to a file
| Attribute | Description |
|---|---|
|
action
string, optional
|
edit
Note:
|
|
source
any, optional
|
edit
PDF document used as the source. |
|
destination
string, optional
|
edit
Pathname of the modified PDF document. If the destination file exists, you must set the overwrite attribute to yes. If the destination file does not exist, CFML creates the file, if the parent directory exists. |
|
overwrite
boolean, optional
|
edit
Specifies whether PDF output overwrites the destination file |
|
version
number, optional
|
edit
Version of the PDF used to write the document |
|
encrypt
string, optional
|
edit
Encryption type for the PDF output file |
|
permissions
string, optional
|
edit
type of permissions on the PDF document |
|
newOwnerPassword
string, optional
|
edit
Password used to set permissions on a PDF document |
|
newUserPassword
string, optional
|
edit
Password used to open PDF document |
Protect a PDF document
action="protect" - Encrypts and adds password protection to PDF documents
| Attribute | Description |
|---|---|
|
action
string, optional
|
edit
Note:
|
|
source
any, optional
|
edit
PDF document used as the source. |
|
destination
string, optional
|
edit
Pathname of the modified PDF document. If the destination file exists, you must set the overwrite attribute to yes. If the destination file does not exist, CFML creates the file, if the parent directory exists. |
|
name
string, optional
|
edit
PDF document variable name Alias: variable |
|
overwrite
boolean, optional
|
edit
Specifies whether PDF output overwrites the destination file |
|
encrypt
string, optional
|
edit
Encryption type for the PDF output file |
|
permissions
string, optional
|
edit
type of permissions on the PDF document |
|
newOwnerPassword
string, optional
|
edit
Password used to set permissions on a PDF document |
|
newUserPassword
string, optional
|
edit
Password used to open PDF document |
Remove password protection
action="removePassword" - Removes password protection from a PDF document
| Attribute | Description |
|---|---|
|
action
string, optional
|
edit
Note:
|
|
source
any, optional
|
edit
PDF document used as the source. |
|
destination
string, optional
|
edit
Pathname of the modified PDF document. If the destination file exists, you must set the overwrite attribute to yes. If the destination file does not exist, CFML creates the file, if the parent directory exists. |
|
name
string, optional
|
edit
PDF document variable name Alias: variable |
|
password
string, optional
|
edit
Owner or user password of the source PDF document, if the document is password-protected. |
|
overwrite
boolean, optional
|
edit
Specifies whether PDF output overwrites the destination file |
Delete pages
action="deletePages" - Deletes pages from a PDF document
| Attribute | Description |
|---|---|
|
action
string, optional
|
edit
Note:
|
|
source
any, optional
|
edit
PDF document used as the source. |
|
pages
string, optional
|
edit
Page or pages in the source PDF document on which to perform the action. You can specify multiple pages and page ranges as follows: "1,6-9,56-89,100, 110-120". |
|
destination
string, optional
|
edit
Pathname of the modified PDF document. If the destination file exists, you must set the overwrite attribute to yes. If the destination file does not exist, CFML creates the file, if the parent directory exists. |
|
name
string, optional
|
edit
PDF document variable name Alias: variable |
|
password
string, optional
|
edit
Owner or user password of the source PDF document, if the document is password-protected. |
|
overwrite
boolean, optional
|
edit
Specifies whether PDF output overwrites the destination file |
Generate thumbnail images
action="thumbnail" - Generates thumbnail images from PDF document pages
| Attribute | Description |
|---|---|
|
action
string, optional
|
edit
Note:
|
|
source
any, optional
|
edit
PDF document used as the source. |
|
destination
string, optional
|
edit
Pathname of the modified PDF document. If the destination file exists, you must set the overwrite attribute to yes. If the destination file does not exist, CFML creates the file, if the parent directory exists. |
|
pages
string, optional
|
edit
Page or pages in the source PDF document on which to perform the action. You can specify multiple pages and page ranges as follows: "1,6-9,56-89,100, 110-120". |
|
format
string, optional
|
edit
File type of thumbnail image output |
|
imagePrefix
string, optional
|
edit
prefix used for each image thumbnail file generated. The image filenames use the format: imagePrefix_page_n.format. |
|
resolution
string, optional
|
edit
Image quality used to generate thumbnail images |
|
scale
number, optional
|
edit
Size of the thumbnail relative to the source page. The value represents a percentage from 1 through 100. |
|
transparent
boolean, optional
|
edit
(format="png" only) Specifies whether the image background is transparent or opaque |
|
overwrite
boolean, optional
|
edit
Specifies whether PDF output overwrites the destination file |
|
password
string, optional
|
edit
Owner or user password of the source PDF document, if the document is password-protected. |
Extract text
action="extractText" - Extracts text from a PDF document
| Attribute | Description |
|---|---|
|
action
string, optional
|
edit
Note:
|
|
source
any, optional
|
edit
PDF document used as the source. |
|
destination
string, optional
|
edit
Pathname of the modified PDF document. If the destination file exists, you must set the overwrite attribute to yes. If the destination file does not exist, CFML creates the file, if the parent directory exists. |
|
name
string, optional
|
edit
PDF document variable name Alias: variable |
|
pages
string, optional
|
edit
Page or pages in the source PDF document on which to perform the action. You can specify multiple pages and page ranges as follows: "1,6-9,56-89,100, 110-120". |
|
type
string, optional
|
edit
used for action "extractText", defines the format type of the extraction, valid values are: string,xml |
|
password
string, optional
|
edit
Owner or user password of the source PDF document, if the document is password-protected. |
|
overwrite
boolean, optional
|
edit
Specifies whether PDF output overwrites the destination file |
Extract images
action="extractImage" - Extracts images from a PDF document
| Attribute | Description |
|---|---|
|
action
string, optional
|
edit
Note:
|
|
source
any, optional
|
edit
PDF document used as the source. |
|
destination
string, optional
|
edit
Pathname of the modified PDF document. If the destination file exists, you must set the overwrite attribute to yes. If the destination file does not exist, CFML creates the file, if the parent directory exists. |
|
pages
string, optional
|
edit
Page or pages in the source PDF document on which to perform the action. You can specify multiple pages and page ranges as follows: "1,6-9,56-89,100, 110-120". |
|
imagePrefix
string, optional
|
edit
prefix used for each image thumbnail file generated. The image filenames use the format: imagePrefix_page_n.format. |
|
format
string, optional
|
edit
File type of thumbnail image output |
|
overwrite
boolean, optional
|
edit
Specifies whether PDF output overwrites the destination file |
|
password
string, optional
|
edit
Owner or user password of the source PDF document, if the document is password-protected. |
Extract bookmarks
action="extractBookmarks" - Extracts bookmarks from a PDF document
| Attribute | Description |
|---|---|
|
action
string, optional
|
edit
Note:
|
|
source
any, optional
|
edit
PDF document used as the source. |
|
name
string, optional
|
edit
PDF document variable name Alias: variable |
|
password
string, optional
|
edit
Owner or user password of the source PDF document, if the document is password-protected. |
Add watermark
action="addWatermark" - Adds a watermark to PDF document pages
| Attribute | Description |
|---|---|
|
action
string, optional
|
edit
Note:
|
|
source
any, optional
|
edit
PDF document used as the source. |
|
copyFrom
any, optional
|
edit
Pathname of the PDF document from which to use the first page as a watermark |
|
image
any, optional
|
edit
Image used as a watermark. You can specify a pathname, a variable that contains an image file, or an image variable |
|
pages
string, optional
|
edit
Page or pages in the source PDF document on which to perform the action. You can specify multiple pages and page ranges as follows: "1,6-9,56-89,100, 110-120". |
|
destination
string, optional
|
edit
Pathname of the modified PDF document. If the destination file exists, you must set the overwrite attribute to yes. If the destination file does not exist, CFML creates the file, if the parent directory exists. |
|
name
string, optional
|
edit
PDF document variable name Alias: variable |
|
password
string, optional
|
edit
Owner or user password of the source PDF document, if the document is password-protected. |
|
overwrite
boolean, optional
|
edit
Specifies whether PDF output overwrites the destination file |
|
foreground
boolean, optional
|
edit
Placement of the watermark on the page |
|
opacity
number, optional
|
edit
Opacity of the watermark. Valid values are integers in the range 0 (transparent) through 10 (opaque). |
|
position
string, optional
|
edit
Position on the page where the watermark is placed. The position represents the top-left corner of the watermark. Specify the x and y coordinates; for example "50,30". |
|
rotation
number, optional
|
edit
Degree of rotation of the watermark image on the page. |
Remove watermark
action="removeWatermark" - Removes watermarks from a PDF document
| Attribute | Description |
|---|---|
|
action
string, optional
|
edit
Note:
|
|
source
any, optional
|
edit
PDF document used as the source. |
|
pages
string, optional
|
edit
Page or pages in the source PDF document on which to perform the action. You can specify multiple pages and page ranges as follows: "1,6-9,56-89,100, 110-120". |
|
destination
string, optional
|
edit
Pathname of the modified PDF document. If the destination file exists, you must set the overwrite attribute to yes. If the destination file does not exist, CFML creates the file, if the parent directory exists. |
|
name
string, optional
|
edit
PDF document variable name Alias: variable |
|
password
string, optional
|
edit
Owner or user password of the source PDF document, if the document is password-protected. |
|
overwrite
boolean, optional
|
edit
Specifies whether PDF output overwrites the destination file |
Add header
action="addHeader" - Adds a header to PDF document pages
| Attribute | Description |
|---|---|
|
action
string, optional
|
edit
Note:
|
|
source
any, optional
|
edit
PDF document used as the source. |
|
destination
string, optional
|
edit
Pathname of the modified PDF document. If the destination file exists, you must set the overwrite attribute to yes. If the destination file does not exist, CFML creates the file, if the parent directory exists. |
|
name
string, optional
|
edit
PDF document variable name Alias: variable |
|
pages
string, optional
|
edit
Page or pages in the source PDF document on which to perform the action. You can specify multiple pages and page ranges as follows: "1,6-9,56-89,100, 110-120". |
|
text
string, optional
|
edit
text for header or footer, you can add the following place holders within the text:
|
|
align
string, optional
|
edit
Aligns the header and footer in PDF:
|
|
leftmargin
numeric, optional
|
edit
left margin of the text in header/footer |
|
rightmargin
numeric, optional
|
edit
right margin of the text in header/footer |
|
topmargin
numeric, optional
|
edit
top margin of the text in header |
|
numberformat
string, optional
|
edit
Specify the numbering format for PDF pages in the header/footer. possible values are:
|
|
password
string, optional
|
edit
Owner or user password of the source PDF document, if the document is password-protected. |
|
overwrite
boolean, optional
|
edit
Specifies whether PDF output overwrites the destination file |
Add footer
action="addFooter" - Adds a footer to PDF document pages
| Attribute | Description |
|---|---|
|
action
string, optional
|
edit
Note:
|
|
source
any, optional
|
edit
PDF document used as the source. |
|
destination
string, optional
|
edit
Pathname of the modified PDF document. If the destination file exists, you must set the overwrite attribute to yes. If the destination file does not exist, CFML creates the file, if the parent directory exists. |
|
name
string, optional
|
edit
PDF document variable name Alias: variable |
|
pages
string, optional
|
edit
Page or pages in the source PDF document on which to perform the action. You can specify multiple pages and page ranges as follows: "1,6-9,56-89,100, 110-120". |
|
text
string, optional
|
edit
text for header or footer, you can add the following place holders within the text:
|
|
align
string, optional
|
edit
Aligns the header and footer in PDF:
|
|
leftmargin
numeric, optional
|
edit
left margin of the text in header/footer |
|
rightmargin
numeric, optional
|
edit
right margin of the text in header/footer |
|
bottommargin
numeric, optional
|
edit
bottom margin of the text in footer |
|
numberformat
string, optional
|
edit
Specify the numbering format for PDF pages in the header/footer. possible values are:
|
|
password
string, optional
|
edit
Owner or user password of the source PDF document, if the document is password-protected. |
|
overwrite
boolean, optional
|
edit
Specifies whether PDF output overwrites the destination file |
Get document information
action="getInfo" - Retrieves information about a PDF document
| Attribute | Description |
|---|---|
|
action
string, optional
|
edit
Note:
|
|
source
any, optional
|
edit
PDF document used as the source. |
|
name
string, optional
|
edit
PDF document variable name Alias: variable |
|
password
string, optional
|
edit
Owner or user password of the source PDF document, if the document is password-protected. |
Set document information
action="setInfo" - Sets information for a PDF document such as title, author, and keywords
| Attribute | Description |
|---|---|
|
action
string, optional
|
edit
Note:
|
|
source
any, optional
|
edit
PDF document used as the source. |
|
info
struct, optional
|
edit
Structure variable for relevant information |
|
destination
string, optional
|
edit
Pathname of the modified PDF document. If the destination file exists, you must set the overwrite attribute to yes. If the destination file does not exist, CFML creates the file, if the parent directory exists. |
|
name
string, optional
|
edit
PDF document variable name Alias: variable |
|
password
string, optional
|
edit
Owner or user password of the source PDF document, if the document is password-protected. |
|
overwrite
boolean, optional
|
edit
Specifies whether PDF output overwrites the destination file |
Unimplemented Attribute(s)
| Attribute | Description |
|---|---|
|
ddxfile
string, optional
|
edit
Pathname of the DDX file, or a string with DDX instructions * unimplemented * |
|
flatten
boolean, optional
|
edit
Applies to forms created in Acrobat only (not forms created in LiveCycle); specifies whether interactivity is turned off * unimplemented * |
|
inputFiles
struct, optional
|
edit
Structure that maps the PDF source files to the input variables in the DDX file, or a string of elements and their pathname. * unimplemented * |
|
isBase64
boolean, optional
|
edit
Valid only when the image attribute is specified. Specifies whether the image used as a watermark is in Base64 format * unimplemented * |
|
order
string, optional
|
edit
Order in which the PDF documents in the directory are merged * unimplemented * |
|
outputFiles
struct, optional
|
edit
Structure that contains the output files in the DDX file or string as keys and the pathname to the result file as the value. * unimplemented * |
|
saveOption
string, optional
|
edit
Save options for the PDF output * unimplemented * |
|
showOnPrint
boolean, optional
|
edit
Specify whether to print the watermark with the PDF document * unimplemented * |
Examples
editThere are currently no examples for this tag.
See also
- PDFs
- <cfdocument>
- <cfpdfparam>
- Search Issue Tracker open_in_new
- Search Lucee Test Cases open_in_new (good for further, detailed examples)