Copy link to clipboard
Copied
Hi,
I need help using the saveAs funtion in a portfolio. My portfolio contains multipe pdf files and i use a protected funtion.
This funtion use to work as intended in acrobat 11. However since upgrading to acrobat DC the file no longer saves or reopens the file i am working on.
Basicly my protected funtion saves the original document, then saves the document as a tempory file and flattents it, then attaches it self to an email, then reopens the original document.
any help would be very much appreciated.
Running this.saveAs funtion through the console while working inside of a portfolio throws an error that the file is already open.
below is the code for my mouse up button
var docName = this.documentFileName;
var saveDirectoryFull = this.path;
var certNo = this.getField ("CertificateNo").value;
if (saveDirectoryFull.indexOf("|") > -1 ) {
saveDirectoryFull = saveDirectoryFull.replace ("|", "");
saveDirectoryFull = saveDirectoryFull.split ("|",1);
};
savecopyemail(saveDirectoryFull, docName, certNo);
below is my code for my trusted funtion
var savecopyemail = app.trustedFunction(function(saveDirectoryFull, docName, certNo){
app.beginPriv();
this.closeDoc();
var os = app.platform;
if (os = "WIN") {
var userdoc = app.getPath("user","documents");
var temporaryDirectory = userdoc.replace ("Documents", "AppData/Local/Temp");
};
if (os = "MAC") {
try{
var temporaryDirectory = app.getPath("user", "temp");}catch(e){}
};
var docNameStriped = docName.replace(".pdf", " ");
var tempDirFull = temporaryDirectory + "/" + docNameStriped + certNo + ".pdf" ;
reopen = app.openDoc(saveDirectoryFull);
reopen.saveAs ({cPath: saveDirectoryFull, bPromptToOverwrite: false});
this.flattenPages({nNonPrint: 2});
this.saveAs ({cPath: tempDirFull, bPromptToOverwrite: false});
this.submitForm({cURL:"mailto:?subject=",
cSubmitAs:"PDF"
});
this.closeDoc(true);
app.openDoc(saveDirectoryFull);
app.endPriv();
});
Copy link to clipboard
Copied
You're using = instead of == in your comparisons of the "os" variable.
Copy link to clipboard
Copied
Thanks for seeing that error in my code.
however it that didnt solve the issue of save.As not working in the portfolio to save the original file.
As that os if statement only sets the temporary directory of the file to be emailed
the problem lies somewhere within these lines of code
reopen = app.openDoc(saveDirectoryFull);
reopen.saveAs ({cPath: saveDirectoryFull, bPromptToOverwrite: false});
this.saveAs ({cPath: tempDirFull, bPromptToOverwrite: false});
my suspions in the pdf file within the portfolio becomes a data object and therefore doesnt have a directory path.
where in acrobat 11 it use to?
Copy link to clipboard
Copied
Correct. The attached files in a Portfolio don't have a path of their own. They share the file of the Portfolio file, plus an additional identifier that contains their own file name and a couple of extra characters.
Copy link to clipboard
Copied
What does you mean with "protected funtion" ?
Copy link to clipboard
Copied
Sorry I ment to write a trusted funtion