Skip to main content
Participant
November 11, 2022
Question

How to copy frames from one InDesign document to the other?

  • November 11, 2022
  • 2 replies
  • 1635 views

Hello everyone,

 

I am trying to write a script to copy some specific frames (text/graphic) from one master indesign document to another document which has to be dynamically.

 

For example, if the master InDesign document has ten frames, i'd like to copy five specific frames based on the id and copy these frame to a new document created dynamically with the styles, alignment and all other criteria as same as in the master document. 

 

Could someone please guide me with any already available scripts , documentation or suggestions on how this can be achieved? 

This topic has been closed for replies.

2 replies

Willi Adelberger
Community Expert
Community Expert
November 11, 2022

Apply object styles to the frames with all relevant properties defined, copy them and paste them. 
For future use, save them in a CC Library. 

brian_p_dts
Community Expert
Community Expert
November 11, 2022

All the documentation you need is here: https://www.indesignjs.de/extendscriptAPI/indesign-latest/#about.html

 

Specifically, look at the Applicationn, Document, Documents, TextFrame, and TextFrames APIs. You'll need a way to reference the active document and the target document (generally app.documents[0] and app.documents[1]). Then, I would name the target text frames in the master document under the Layer panel, and target them with itemByName property, then use the duplicate() methord for a text frame. A sample line would be:

 

app.documents[0].textFrames.itemByName("trgt1").duplicate(app.documents[1].pages[0]);

 

But a lot more goes into it than that. Do you have any scripting knowledge? 

Participant
November 11, 2022

Hi @brian_p_dts ,

Thank you for the link to the documentation.

I do not have any prior scripting knowledge. I am basically a .net developer, is there any SDK available? I read that there is an SDK and it's in C++. But when i try to download that from here https://developer.adobe.com/console/servicesandapis/id# , it says access denied. I already have the Adobe CC license.

Community Expert
November 11, 2022

You don't need to use C++ SDK for the use case you described. You can accomplish all what you described using JavaScript code whose DOM documentation link was supplied by @brian_p_dts in the post above. Using C++ SDK would be an overkill for this much work and is a very steep learning curve, so make your choices wisely.

You have two choices which according to me should be investigated first, unless you are stuck and identify that C++ is absolutely needed.

  • Extendscript, the one mentioned by Brian. It uses an old version of ECMAScript and has lots of samples shipped with InDesign installation(Scripts panel), that should get you started
  • UXP scripting, this can be used in the latest version of InDesign. This uses modern JS, but is a work in progress so may lack some functionality

-Manan

 

-Manan