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

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

267

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 , 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
...

Votes

Translate

Translate
Community Expert ,
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;

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

Copy link to clipboard

Copied

LATEST

Thank you so much! I appreciate you 🙂

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