Skip to main content
Inspiring
November 5, 2022
Answered

paste in place

  • November 5, 2022
  • 7 replies
  • 3231 views

Hi,

 

I try to copy a logo on page 2 and paste it in place on page 3.

When I presee shift+opt+cmd+V, it is pasted on page 2.

 

Is there any better way?

 

Hosun

 

This topic has been closed for replies.
Correct answer Robert at ID-Tasker

Yes it works as long as you explicitly code the destination page.

 

If I want to choose any page, you will need put up a dialog and ask me which page I want, or listen for an active page event, which is trickier. Paste In Place decides where to paste the object based on the currently active page, which might not  be on the same spread as the copied object—it’s whatever page is currently selected in the Pages panel

 

Also, to imitate Paste In Place with a dialog we need to use the duplicate() method—Paste in Place doesn’t remove the original. So the first script I posted with the dialog would be better the duplicate method.

 

 


OK, this WORKS 😄

 

//Paste In Place to destination page
//Select a page item, run script, and double-click a page in the Pages panel

#targetengine "pasteinplace";

PasteInPlace()
var el, b, s;
var or = app.activeDocument.viewPreferences.rulerOrigin = RulerOrigin.PAGE_ORIGIN; 
function PasteInPlace(){
    if (app.selection.length > 0) {
        var doc = app.activeDocument;
        s = doc.selection[0];
//        b = s.geometricBounds;
//        app.copy()
        var el = app.addEventListener("afterAttributeChanged", getBounds);
        el.name = "PIP"
//        alert(app.activeDocument.layoutWindows[0].activePage);
    } else {
        alert("Please Make a Selection")
        return
    } 
} 


function getBounds(e) {
    if (e.attributeValue.constructor.name === 'Page') {    
        app.menuActions.itemByID(118788).invoke();
//        alert(doc.activeWindow.activePage);
//        app.paste();
//        app.selection[0].geometricBounds = b;
//        alert(s.attributeValue.constructor.name);
        s.duplicate(app.activeDocument.layoutWindows[0].activePage);
        app.eventListeners.itemByName("PIP").remove();
        app.activeDocument.viewPreferences.rulerOrigin = or;
    }
} 

7 replies

BobLevine
Community Expert
Community Expert
November 7, 2022

If you're on the same spread, step and repeat would be the way to go. Just set the horizontal offset to the width of the pages. This setting should be sticky so it would work throughout the document. You'd need to change it if you're pasting from right to left pages.

Robert at ID-Tasker
Legend
November 7, 2022

No need for Step & Repeat 😉 there is a quicker way 😉 you can just execute PasteInPlace then - like you've suggested - add page's width to X location - InDesign is doing math automatically in ALL numeric fields 🙂 

 

rob day
Community Expert
Community Expert
November 6, 2022

This version might be better, there’s no dialog—it listens for a page selection in the Pages panel then Pastes In Place on that page. Select the object you want to paste in place, run the script, and double-click the target page in the Pages panel.  You can give the script a key command

 

 

 

 

 

//Paste In Place to destination page
//Select a page item, run script, and double-click a page in the Pages panel

#targetengine "pasteinplace";

PasteInPlace()
var el, b;
var or = app.activeDocument.viewPreferences.rulerOrigin = RulerOrigin.PAGE_ORIGIN; 
function PasteInPlace(){
    if (app.selection.length > 0) {
        var doc = app.activeDocument;
        var s = doc.selection[0];
        b = s.geometricBounds;
        app.copy()
        var el = app.addEventListener("afterAttributeChanged", getBounds);
        el.name = "PIP"
    } else {
        alert("Please Make a Selection")
        return
    } 
} 


function getBounds(e) {
    if (e.attributeValue.constructor.name === 'Page') {    
        app.menuActions.itemByID(118788).invoke();
        app.paste();
        app.selection[0].geometricBounds = b;
        app.eventListeners.itemByName("PIP").remove();
        app.activeDocument.viewPreferences.rulerOrigin = or;
    }
} 

 

 

 

 

 

 

 

 

 

Robert at ID-Tasker
Legend
November 6, 2022

I'm sorry, but am I the only one who knows that ? 😄

 

Function Duplicate([To], [By]) As PageItem
Member of InDesign.Rectangle
Duplicates the Rectangle at the specified location or offset.
Return value: The duplicated Rectangle.
To: The location of the new Rectangle, specified in coordinates in the format [x, y]. Type: Array of 2 Units (Doubles or Strings), Spread, Page or Layer.
By: Amount by which to offset the new Rectangle from the original Rectangle's position. Type: Array of 2 Units (Doubles or Strings)

 

So ... tested in VB and JS:

 

Set myInDi = CreateObject("InDesign.Application")
Set myDoc = myInDi.ActiveDocument
Call myInDi.Selection.Item(1).Duplicate(myDoc.Pages.Item(3))

 

 

main();
function main()
{
  var doc = app.activeDocument;
  doc.selection[0].duplicate(doc.pages[4]);
};

 

(page numbers are just examples and don't corelate with example screens below)

 

have the same effect - it will create a copy in EXACTLY the same location from the TopLeft corner of the page:

 

 

 

 

For some reason - move also accepts Spread, Page, Layer as a destination - but object is moved to the TopLeft corner of the page - so looks like a bug ?

 

rob day
Community Expert
Community Expert
November 6, 2022

Hi @Robert at ID-Tasker , The Paste In Place menu item is supposed to paste the copied object on the currently active page in the same spot as the original. But, if you test it is not doing that—it’s pasting the object in the same spread (not page) position.

 

@Hosun26059267k946 is trying to replicate the position on the opposite righthand page, but you might also want to paste it on an active right hand page on a different spread, e.g. page 9. That’s what the listener in my 2nd script is doing— it’s listening for the activated page for the paste.

 

Make a selection, run the script, and double-click the destination page in the Pages panel.

rob day
Community Expert
Community Expert
November 5, 2022

Hi @Hosun26059267k946 , If @jmlevy ’s Object Style doesn’t work for you, the bug can sort of be fixed via a script with a dialog for selecting the page:

 

 

 

 

//Paste in Place fix

makeDialog();
pg;
function makeDialog(){
    var d = app.dialogs.add({name:"Choose a Page for Paste In Place", canCancel:true});
    with(d.dialogColumns.add()){
        pg = dropdowns.add({stringList:getPresets(app.activeDocument.pages), selectedIndex:0, minWidth:120});
    }
    if(d.show() == true){
        pg = app.activeDocument.pages.item(pg.selectedIndex);
        main();
        d.destroy();
	}
}

function main(){
    var or = app.activeDocument.viewPreferences.rulerOrigin = RulerOrigin.PAGE_ORIGIN;
    var s = app.selection[0];
    if (app.selection.length > 0) {
        s.duplicate(pg)
    } else {
        alert("Please Make a Selection")
        return
    }
    app.activeDocument.viewPreferences.rulerOrigin = or;
}


 function getPresets(p){
    var a = new Array;
    for(var i = 0; i < p.length; i++){
        a.push(p.item(i).name);
    }
    return a
} 

 

 

 

 

Compiled version here:

https://shared-assets.adobe.com/link/8dd50b23-49ad-4c00-6d62-44d4e66ff3ef

 

 

Dialog with a selected item:

 

 

After run:

rob day
Community Expert
Community Expert
November 5, 2022

it is pasted on page 2.

 

 

Hi @Hosun26059267k946 , Looking at your screen capture Paste in Place is pasting the selected object on Page 3, which is the active page in your Pages panel. Your pages have a Landscape Orientation:

 

Peter Spier
Community Expert
Community Expert
November 5, 2022

Rob, I tried this earlier today copying an object from page 2 and trying to paste in place on page 3. No success, even being sure the rulers were set per page.

If you select page 3 in the pages panel it seems that InDesign sees the entire spread as a unit, highlighting the numbers for both pages even though only one is highlighted.

rob day
Community Expert
Community Expert
November 6, 2022

Yes, I should have double-checked before posting. At first I also thought it was because the Ruler Origin needed to be set, but the Paste In Place menu item seems to always treat the Ruler Origin as Spreads.

 

The script should work, but I needed to include a dropdown dialog for the destination page.

Bill Silbert
Community Expert
Community Expert
November 5, 2022

Rather than Paste in Place why not put the logo into position on a Parent (aka Master) page since it looks like you are using the same layout on both pages?

Other than that you might want to log this in as a feature request at https://www.adobe.com/products/wishform.html.

Peter Spier
Community Expert
Community Expert
November 5, 2022

I think this is a long-standing problem (it was that way back in CS6). Paste in place only seems to recognize you've changed pages when you are on a different spread.

I tried jmlevy's object style method and it doesn't seem to work here...

rob day
Community Expert
Community Expert
November 5, 2022

Sorry Peter, I should have checked before posting, I’ve never noticed the problem. Seems like we could script a fix, I’ll check

jmlevy
Community Expert
Community Expert
November 5, 2022

Create an object style and setup the position of the frame in the object syle definition.

Inspiring
November 6, 2022

Hi,

 

I made an Object Style on the logo. (Screenshot 1)

When I copied and pasted it, I have two issues. (Screenshot 2)

 

1.

Logo is not visible, unlike seen in Links panel.

2.

In Links panel, the paseted object is on page 3.

It's still on page 2.

 

Hosun

 

Screenshot 1

 

Screeshot 2

jmlevy
Community Expert
Community Expert
November 6, 2022

1.

Logo is not visible, unlike seen in Links panel.

2.

In Links panel, the paseted object is on page 3.

It's still on page 2.

Yes, that's weird, and I don't understand why you do not see the logo.

But as @Bill Silbert wrote, the best option for you would be to build a parent page with the frame at the position you need.