-
Notifications
You must be signed in to change notification settings - Fork 0
Description
I can't seem to find a way to overwrite an existing pdf file. the saveAs function will not overwrite an existing file. ColdFusion keep the file open and a simple cffile delete & rename cannot be done.
Error says file is open by Coldfusion.
I'm simply trying to replace the input file after the operation is complete.
<cfset variables.source = createObject('java','com.adobe.pdfservices.operation.io.FileRef').createFromLocalFile(variables.docPath)> <cfset variables.destination = variables.docDir & "\COM." & variables.docFile> <cfset pdfOp = createObject('java', 'com.adobe.pdfservices.operation.pdfops.CompressPDFOperation').createNew()> <cfset pdfOp.setInput(source)> <cfset ev = auth()> <cfset result = pdfOp.execute(ex)> <cfif IsObject(result)> <cfset result.saveAs(variables.destination)> <cfif FileExists(variables.destination)> <cffile action="delete" file="#variables.docPath#"> <cffile action="rename" source="#variables.destination#" destination="#variables.docPath#"> </cfif> </cfif>