How to - Keep Filename During InDesign Script Export

New Here ,
Mar 24, 2022 Mar 24, 2022

Copy link to clipboard

Copied

Hi - this script exports my InDesign files into PDFs with security settings. Unfortunately, it also renames the file during export. Is there a way to tweak this script to retain the original file name?

 

var currPrefs = app.pdfExportPreferences;
with (currPrefs) {
    useSecurity = true;
    changeSecurityPassword = "**********";
    acrobatCompatibility = AcrobatCompatibility.ACROBAT_5;
    viewPDF = true;
    pageRange = PageRange.ALL_PAGES;
    disallowPrinting = true;
    disallowCopying = false;
    disallowChanging = true;
}


var doc = app.activeDocument;
doc.exportFile(ExportFormat.PDF_TYPE, File("~/Desktop/name.pdf"), false);

currPrefs.useSecurity = false;

 

TOPICS
How to , Import and export , Scripting

Views

81

Likes

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

Adobe Community Professional , Mar 24, 2022 Mar 24, 2022
Edited the penultimate line of code to save as the current doc's name, replacing indd with pdf. This assumes that the document has been saved and has a name (ie., not Untitled). Will still save to your desktop.   var currPrefs = app.pdfExportPreferences; with (currPrefs) { useSecurity = true; changeSecurityPassword = "**********"; acrobatCompatibility = AcrobatCompatibility.ACROBAT_5; viewPDF = true; pageRange = PageRange.ALL_PAGES; disallowPrinting = true; disallowCo...

Likes

Translate

Translate
Adobe Community Professional ,
Mar 24, 2022 Mar 24, 2022

Copy link to clipboard

Copied

Edited the penultimate line of code to save as the current doc's name, replacing indd with pdf. This assumes that the document has been saved and has a name (ie., not Untitled). Will still save to your desktop.  

var currPrefs = app.pdfExportPreferences;
with (currPrefs) {
    useSecurity = true;
    changeSecurityPassword = "**********";
    acrobatCompatibility = AcrobatCompatibility.ACROBAT_5;
    viewPDF = true;
    pageRange = PageRange.ALL_PAGES;
    disallowPrinting = true;
    disallowCopying = false;
    disallowChanging = true;
}


var doc = app.activeDocument;
doc.exportFile(ExportFormat.PDF_TYPE, File("~/Desktop/" + doc.name.replace(/indd$/gi,"pdf")), false);

currPrefs.useSecurity = false;

Likes

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 ,
Mar 24, 2022 Mar 24, 2022

Copy link to clipboard

Copied

LATEST

Thank you so much! I appreciate you 🙂

Likes

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