User Guide Cancel

IsPDFFile

 

Description

Verifies whether a PDF file is valid.

Returns

True, if the value returns a valid PDF file. False, otherwise.

Category

Syntax

IsPDFFile("path")
IsPDFFile("path")
IsPDFFile("path")

See also

History

ColdFusion 8: Added this function.

Parameters

Parameter

Description

path

Pathname to an on-disk or in-memory PDF file. The pathname can be absolute or relative to the CFM page and must be enclosed in quotation marks.

Usage

This function returns False if the value is not a valid pathname to a PDF file, the pathname is null, the PDF file is not valid, or the PDF file is corrupted.

Example

 

<cfscript>
a=[
"https://helpx.adobe.com/coldfusion/kb/coldfusion-2016-updates.html",
"https://helpx.adobe.com/captivate/using/whats-new.html"
]
after_last_slash=[];
for (i=1;i<=arraylen(a);i++){
//b[i]=a[i]
after_last_slash[i]=reMatch("([^\/]+$)",a[i]);
final_last_slash[i]=ArrayToList(after_last_slash[i]);
}
//writedump(final_last_slash)
for (i=1;i<=arrayLen(final_last_slash);i++){
before_dot[i]=reMatch(".*(?=\.)",final_last_slash[i]);
final_before_dot[i]=ArrayToList(before_dot[i]);
}
writeDump(final_before_dot);
// cfhtmltopdf
theDir=GetDirectoryFromPath(GetCurrentTemplatePath());
theFolder=theDir & "Assets"
a.map(function(value,item){
cfhtmltopdf(
destination="#theFolder#/#final_before_dot[item]#.pdf",
source="#value#",
orientation="portrait",
pagetype="A4",
margintop="1",
marginbottom="1",
marginleft="1",
marginright="1",
overwrite="true"
);
});
writeOutput(isPDFFile("#theFolder#/#final_before_dot[1]#.pdf"))
</cfscript>
<cfscript> a=[ "https://helpx.adobe.com/coldfusion/kb/coldfusion-2016-updates.html", "https://helpx.adobe.com/captivate/using/whats-new.html" ] after_last_slash=[]; for (i=1;i<=arraylen(a);i++){ //b[i]=a[i] after_last_slash[i]=reMatch("([^\/]+$)",a[i]); final_last_slash[i]=ArrayToList(after_last_slash[i]); } //writedump(final_last_slash) for (i=1;i<=arrayLen(final_last_slash);i++){ before_dot[i]=reMatch(".*(?=\.)",final_last_slash[i]); final_before_dot[i]=ArrayToList(before_dot[i]); } writeDump(final_before_dot); // cfhtmltopdf theDir=GetDirectoryFromPath(GetCurrentTemplatePath()); theFolder=theDir & "Assets" a.map(function(value,item){ cfhtmltopdf( destination="#theFolder#/#final_before_dot[item]#.pdf", source="#value#", orientation="portrait", pagetype="A4", margintop="1", marginbottom="1", marginleft="1", marginright="1", overwrite="true" ); }); writeOutput(isPDFFile("#theFolder#/#final_before_dot[1]#.pdf")) </cfscript>
<cfscript>
    a=[
 "https://helpx.adobe.com/coldfusion/kb/coldfusion-2016-updates.html",
 "https://helpx.adobe.com/captivate/using/whats-new.html"
 ]
 
 after_last_slash=[];
 for (i=1;i<=arraylen(a);i++){
  //b[i]=a[i]
  after_last_slash[i]=reMatch("([^\/]+$)",a[i]);
  final_last_slash[i]=ArrayToList(after_last_slash[i]);
  
 }
 //writedump(final_last_slash)
 
 for (i=1;i<=arrayLen(final_last_slash);i++){
  before_dot[i]=reMatch(".*(?=\.)",final_last_slash[i]);
  final_before_dot[i]=ArrayToList(before_dot[i]);
 }
 writeDump(final_before_dot);
 
 // cfhtmltopdf
 theDir=GetDirectoryFromPath(GetCurrentTemplatePath()); 
    theFolder=theDir & "Assets"
 a.map(function(value,item){
  cfhtmltopdf(
   destination="#theFolder#/#final_before_dot[item]#.pdf",
   source="#value#",
   orientation="portrait",
   pagetype="A4",
   margintop="1",
   marginbottom="1",
     marginleft="1",
     marginright="1",
     overwrite="true"  
  );
 });
 writeOutput(isPDFFile("#theFolder#/#final_before_dot[1]#.pdf"))
</cfscript>

Output

Get help faster and easier

New user?