• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Using saveAs funtion with portfolios no longer working with Acrobat DC

New Here ,
Apr 16, 2021 Apr 16, 2021

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();
});

 

TOPICS
Acrobat SDK and JavaScript

Views

184

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 17, 2021 Apr 17, 2021

Copy link to clipboard

Copied

You're using = instead of == in your comparisons of the "os" variable.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 17, 2021 Apr 17, 2021

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?

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 18, 2021 Apr 18, 2021

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 19, 2021 Apr 19, 2021

Copy link to clipboard

Copied

What does you mean with "protected funtion" ?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 19, 2021 Apr 19, 2021

Copy link to clipboard

Copied

LATEST

Sorry I ment to write a trusted funtion

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines