Whatever message this page gives is out now! Go check it out!
| Mode | Syntax |
Creating the service | new pdf()}}or {{createObject("component", "pdf") |
Initializing the attributes | Any one of the following:
|
Executing the service action | pdfService.action_method(attribute-value pair) |
addQuads | algo | align | ascending |
bottomMargin | compressTiffs | copyFrom | ddxfile |
destination | directory | encodeAll | encrypt |
flatten | foreground | format | height |
hires | honourSpaces | hScale | image |
imagePrefix | info | inputFiles | isBase64 |
jpgDpi | keepBookmark | leftMargin | maxBreadth |
maxLength | maxScale | name | newOwnerPassword |
newUserPassword | noAttachments | noBookmarks | noComments |
noJavascripts | noLinks | noMetadata | noThumbnails |
numberFormat | opacity | order | outputFiles |
overridePage | overwrite | package | pages |
password | permissions | position | resolution |
rightMargin | rotation | saveOption | scale |
showOnPrint | source | stopOnError | text |
topMargin | transparent | type | useStructure |
version | vscale | width |
<cfpdf action="getInfo" source="myBook.pdf" name="PDFInfo"> |
pdfInfo = pdfService.getPdfInfo(source="myBook.pdf", name="pdfinfo"); |
Description | Used in CFScript to add cfpdfparam tags. Applicable only to action="merge". |
Returns | Nothing |
Syntax | pdfService.addParam(attribute-value pair) |
Arguments | All attributes supported by the cfpdfparam tag can be used as attribute-value pairs. |
addWatermark | removeWatermark | deletePages | getPDFInfo |
setPDFInfo | merge | processDDX | protect |
read | write | thumbnail | transform |
optimize | extractImage | extractText | addHeader |
addFooter | removeHeaderFooter |
Description | All methods correspond to the PDF actions specified for the tag cfpdf. For details of each method, refer to the corresponding section for cfpdf . |
Returns | Depends on the action. If the name attribute is specified, the result of the pdf operation is returned. Else, an empty string. For example, the following code returns a structure containing the pdf information for "book.pdf": pdfinfo = pdfService.getPDFInfo(source="book.pdf",name="var")}}PDF manipulation is done using the {{cfpdf tag. This is why, you must specify the name attribute. Accessing "var" directly does not work since "var" does not exist in the page variables scope. |
Syntax | serviceName.methodName(attribute-value pair) |
Arguments | All attributes supported by the cfpdf tag for a given action are supported. |
Description | Sets attributes for the pdf function. |
Returns | Nothing |
Syntax | pdfService.setAttributes (attribute-value pair) |
Arguments | All attributes supported by the cfpdf tag. |
Description | Gets the attributes that were set for the pdf function. |
Returns | Returns a struct with all or some of the attribute values. |
Syntax | pdfService.get_Attributes_ (attributelist) |
Arguments | A comma-separated list of attributes. If no list is specified, all defined attributes are returned. |
Description | Removes all attributes added for the pdf function. |
Returns | Nothing |
Syntax | pdfService.clearAttributes(attribute_list) |
Arguments | A comma-separated list of attributes that must be removed. |
Description | Removes params that were added using addParam method. |
Returns | Nothing |
Syntax | pdfService.clearParams() |
Arguments | None |
Description | Removes all attributes and params added using the addParam method. |
Returns | Nothing |
Syntax | pdfService.clear() |
Arguments | None |
<h3>PDF Thumbnail</h3> <cfscript> // Create a variable for the name of the PDF document. mypdf = "book"; thumbnailsDirectory = ExpandPath(".") & "\" & "#mypdf#_thumbnails"; //create new PDF service pdfService = new pdf(); //set attributes using implicit setters pdfService.setSource(expandpath('./#mypdf#.pdf')); //Use the getPdfInfo action to retrieve the total page count for the PDF document. PDFInfo = pdfService.getPdfInfo(name="pdfinfo"); pageCount = PDFInfo.TotalPages; WriteOutput("pageCount=" & pageCount); //Generate a thumbnail image for each page in the PDF source document, //create a directory (if it does not exist) in the web root that is //a concatenation of the PDF source name and the word "thumbnails", and //save the thumbnail images in that directory. pdfService.thumbnail(destination=thumbnailsDirectory, scale=60, overwrite=true); //Loop through the images in the thumbnail directory and generate a link //from each image to the corresponding page in the PDF document. for(i="1";i lte pageCount;i++) { //Click the thumbnail image to navigate to the page in the PDF document. WriteOutput("<a href='#mypdf#.pdf##page=#i#' target='_blank'><img src='#mypdf#_thumbnails/#mypdf#_page_#i#.jpg'></a>"); } </cfscript |