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

Export InDesign document to separate IDML files?

New Here ,
Nov 05, 2021 Nov 05, 2021

Copy link to clipboard

Copied

Does anyone have a InDesign script that exports a multi-page InDesign document to separate IDML files?

TOPICS
Import and export , Scripting

Views

718

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

Advisor , Nov 05, 2021 Nov 05, 2021

Hello @Adeprimo,

I should have tested my JUNK code before I posted it as it doesn't work...it was early and i didn't have any coffee yet.

Try the code below for your needs, it's kinda convoluted but it works!!

 

 

   var doc = app.activeDocument;
   var myFolder =doc.filePath;
   var fileName = doc.name.replace(/.indd$/i, "");
   var myPages = app.activeDocument.pages;
   
   for (i = 0; i < myPages.length; i++){ 
    var myPageName = myPages[i].name;
  
   doc.saveACopy(File(myFolder + "/Temp_P" + m
...

Votes

Translate

Translate
Advisor ,
Nov 05, 2021 Nov 05, 2021

Copy link to clipboard

Copied

Hello @Adeprimo 

 

Here you go...

doc = app.activeDocument;
var docPages = doc.pages;
var fileName = doc.name.replace(/.indd$/i, "");

for(p=0;p<docPages.length;p++){
var myPageName = docPages[p].name;

var myIDML = new File(File(doc.filePath).fsName + "/" + fileName + "_P" + myPageName + ".idml");
doc.exportFile(ExportFormat.INDESIGN_MARKUP, myIDML);
}
alert("Done exporting idml files!")

 

Regards,

Mike

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 ,
Nov 05, 2021 Nov 05, 2021

Copy link to clipboard

Copied

Thanks Mike, I will test it.

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
Advisor ,
Nov 05, 2021 Nov 05, 2021

Copy link to clipboard

Copied

Hello @Adeprimo,

I should have tested my JUNK code before I posted it as it doesn't work...it was early and i didn't have any coffee yet.

Try the code below for your needs, it's kinda convoluted but it works!!

 

 

   var doc = app.activeDocument;
   var myFolder =doc.filePath;
   var fileName = doc.name.replace(/.indd$/i, "");
   var myPages = app.activeDocument.pages;
   
   for (i = 0; i < myPages.length; i++){ 
    var myPageName = myPages[i].name;
  
   doc.saveACopy(File(myFolder + "/Temp_P" + myPages[i].name + ".indd"));

   tempDoc = app.open(File(myFolder + "/Temp_P" + myPages[i].name + ".indd"), false);

   doc.pages[i].duplicate(LocationOptions.AT_END, tempDoc.pages[-1]);

   tempDoc.pages.itemByRange(tempDoc.pages[0], tempDoc.pages[-2]).remove();

   var myIDML = new File(File(doc.filePath).fsName + "/" + fileName + "_P" + myPageName + ".idml");
   tempDoc.exportFile(ExportFormat.INDESIGN_MARKUP, myIDML);

   tempDoc.close(SaveOptions.NO);

   var tempDoc = File(myFolder.fsName + "/Temp_P" + myPageName + ".indd"); 
  
   tempDoc.remove();
   }
   alert("Done exporting idml files!")

 

 

 

Regards,

Mike

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 ,
Nov 05, 2021 Nov 05, 2021

Copy link to clipboard

Copied

Thanks so much Mike.
It's working now.

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
Explorer ,
Mar 21, 2022 Mar 21, 2022

Copy link to clipboard

Copied

I have to say Mike, Thank you!

 

You are a javascript GOD.

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 ,
Jul 15, 2022 Jul 15, 2022

Copy link to clipboard

Copied

LATEST

Is there a way to generate unique file names for each of the exported pages based on the content on each page? I.e. I have 500 business cards that need unique INDD files but it would be nice if it could pull the name from the card as the file name. Not sure if that is possible.

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