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

Copy/paste scripting

Participant ,
Jun 23, 2024 Jun 23, 2024

"Can I copy an object and paste it into all pages in the same position as if I pressed Ctrl+Shift+Alt+V using a script? Could someone please provide the code?"

TOPICS
How to , Performance , Scripting , SDK , Type
511
Translate
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 , Jun 24, 2024 Jun 24, 2024

Hi @aghanjar16430960 , Also, a script can duplicate a selected page item and skip the copy and paste. Something like this:

 

 

//a selected object
var s = app.activeDocument.selection[0]

var pg = app.activeDocument.pages.everyItem().getElements()
for (var i = 0; i < pg.length; i++){
    s.duplicate(pg[i])
}

 

 

Screen Shot 4.png

 

Screen Shot 3.png

Translate
LEGEND ,
Jun 23, 2024 Jun 23, 2024

Yes. 

 

If your document is a single page per Spread then you can iterate through Pages collection and just use app.pasteInPlace().

 

If multiple pages per Spread - then after initial app.pasteInPlace() you'll have to move horizontally by the width of the page - positive or negative - depends on from which page you've copied it from. 

 

Of course you need to take into consideration if all pages have the same width and orientation, etc. 

 

Translate
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
Community Expert ,
Jun 24, 2024 Jun 24, 2024

Hi @aghanjar16430960 , Also, a script can duplicate a selected page item and skip the copy and paste. Something like this:

 

 

//a selected object
var s = app.activeDocument.selection[0]

var pg = app.activeDocument.pages.everyItem().getElements()
for (var i = 0; i < pg.length; i++){
    s.duplicate(pg[i])
}

 

 

Screen Shot 4.png

 

Screen Shot 3.png

Translate
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
Participant ,
Jun 26, 2024 Jun 26, 2024
LATEST

thanks

Translate
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