Open danderson421 opened 2 years ago
Interesting. At first glance I don't see anything suggesting the process should be left open, but I also don't see anything in the API to close anything either.
When I get a chance, I can see about reproducing and digging into it more. If anything, may need to ask as a general question regarding these Java classes on the official Adobe repo.
One thing to point out...
Looking here: https://opensource.adobe.com/pdfservices-java-sdk-samples/apidocs/latest/com/adobe/pdfservices/operation/io/FileRef.html
The saveAs method will throw an exception when a file exists in the file/path passed to it.
Throws: FileAlreadyExistsException - if the file already exists at the target location
Now as to why CF cannot act on the file after, I'm not sure off hand.
After reading a few other posts, it appears there is another method saveASFile, that may overcome this issue, but it doesn't appear to be included in your library...
Can you point to where you see that, so I can cross-reference?
This repo is a borrow of Adobe's Java repo, so it builds the same sample JAR (excluding slf4j) that makes use of com.adobe.documentservices 2.2.2. There is a beta release, but I have held off updating in favor of waiting for a full release. I have not looked at the beta release. Perhaps the function exists there.
The relevant API docs I am aware of for this project are here: https://opensource.adobe.com/pdfservices-java-sdk-samples/apidocs/latest/index.html
clearly a different operation, but the OP is having the exact same problem.
Hmm ok. That function is being referenced from the Node SDK. But from what I can tell, the flow of logic works similar in that if the file exists, it will throw an error.
https://opensource.adobe.com/pdfservices-node-sdk-samples/apidocs/latest/FileRef.html#saveAsFile
It does mention the following, and I believe the Java API method works similar - "If this FileRef instance refers to a temporary local file created by the SDK, that temporary file is deleted.". I'm not sure what qualifies as a temporary file in this case, though. That's something I'd have to look into more.
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)>