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

Save a Copy as PDF with Presets for Multiple Open Tabs Script

Participant ,
Jan 25, 2024 Jan 25, 2024

Copy link to clipboard

Copied

I currently have a working script for SaveDocsAsPDF_Presets and it works great, but now that we can Save a Copy instead of Save As, I was hoping someone could modify my script to be Save a Copy instead of Save As?  I don't know how to write scripts and my feeble attempt to modify it has resulted in no results...any help apprecitated!

 

Here is my current script:

 

var w = new Window("dialog", "Choose a Preset");
var dropdownlist = w.add("dropdownlist", undefined, app.PDFPresetsList);
dropdownlist.preferredSize.width = 200;
dropdownlist.selection = 0;
var choice = dropdownlist.selection;
dropdownlist.onChange = function () {
choice = dropdownlist.selection;
};
var button = w.add("button", undefined, "OK");
button.onClick = function () {
saveDocsAsPDF(choice);
w.close();
};
w.show();

function saveDocsAsPDF(choice) {
// original SaveDocsAsPDF script
try {
if (app.documents.length > 0 ) {
var destFolder = null;
destFolder = Folder.selectDialog('Select folder for PDF files.', '~');
if (destFolder != null) {
var options, i, sourceDoc, targetFile;
options = getOptions();
for ( i = 0; i < app.documents.length; i++ ) {
sourceDoc = app.documents[i];
targetFile = getTargetFile(sourceDoc.name, '.pdf', destFolder);
sourceDoc.saveAs( targetFile, options );
}
alert('Documents saved as PDF');
}
} else {
throw new Error('There are no document open!');
}
} catch(e) {
alert( e.message, "Script Alert", true);
}
function getOptions() {
var options = new PDFSaveOptions();
options.pDFPreset = choice;
return options;
}
function getTargetFile(docName, ext, destFolder) {
var newName = "";
if (docName.indexOf('.') < 0) {
newName = docName + ext;
} else {
var dot = docName.lastIndexOf('.');
newName += docName.substring(0, dot);
newName += ext;
}
var myFile = new File( destFolder + '/' + newName );
if (myFile.open("w")) {
myFile.close();
}
else {
throw new Error('Access is denied');
}
return myFile;
}
}

Views

437

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

correct answers 1 Correct answer

Community Expert , Jan 30, 2024 Jan 30, 2024

[MOVED TO THE ILLUSTRATOR DISCUSSIONS]

Votes

Translate

Translate
Adobe
Community Expert ,
Jan 25, 2024 Jan 25, 2024

Copy link to clipboard

Copied

What app does you use?

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
Participant ,
Jan 29, 2024 Jan 29, 2024

Copy link to clipboard

Copied

Not sure how my post got in the Acrobat community, meant to be in the Illustrator help as this is an Illustrator script.  I will move it there.

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 ,
Jan 25, 2024 Jan 25, 2024

Copy link to clipboard

Copied

What do you mean by "save a copy"?

In Acrobat, it's a misnamed function used only to disable Extended Rights for Reader.

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
Participant ,
Jan 29, 2024 Jan 29, 2024

Copy link to clipboard

Copied

Not sure how my post got in the Acrobat community, meant to be in the Illustrator help as this is an Illustrator script.  I will move it there.

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 ,
Jan 30, 2024 Jan 30, 2024

Copy link to clipboard

Copied

LATEST

[MOVED TO THE ILLUSTRATOR DISCUSSIONS]

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