Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


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

113

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

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

Likes

Translate

Translate
Advocate ,
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

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

Copy link to clipboard

Copied

Thanks Mike, I will test it.

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

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

Copy link to clipboard

Copied

LATEST

Thanks so much Mike.
It's working now.

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