Skip to main content
Known Participant
July 10, 2015
Question

how to move image from one page to another page using indesign javascript.

  • July 10, 2015
  • 14 replies
  • 3407 views

hi ,

right now i can able to move image from one place to another place using geometricBounds.. within single page its working fine.

now i want to move the image from one page to another page using indesign javscript.

This topic has been closed for replies.

14 replies

mani4Author
Known Participant
July 29, 2015

this below code , showing INLINE_POSITION ...

alert( img.parent.anchoredObjectSettings.anchoredPosition);

and its working ..but first time its releasing the anchoredposition of the image .

next time while i run this script .. it showing error like ..

"the property is not applicable in the current state...

because the anchoredposition is released ..

now i need a condition like,,

wheather the image is anchored or not...

mani4Author
Known Participant
July 20, 2015

yeah i add this two lines , but it showing error in this line..

Inspiring
July 20, 2015

You need to investigate the object.

What is  img.parent.anchoredObjectSettings.anchoredPosition ?

Is your image inline? Can you manually move it to a different page, different spread?

I checked the dom reference for CS6 and all it looks fine.

mani4Author
Known Participant
July 20, 2015

yeah,

i checked and alert(doc.pages[Number(myPage)-1]); it shows the correct page object.

i did alert(img.parent); and correctly it shows the rectangle object of that image.

Inspiring
July 20, 2015

OK, try to add these two lines:

     img.parent.anchoredObjectSettings.anchoredPosition = AnchorPosition.ANCHORED;

     img.parent.anchoredObjectSettings.releaseAnchoredObject();

     img.parent.move(doc.pages[Number(myPage)-1]);

I suppose, the image you placed is anchored to the text. You need to release the parent rectangle before you move it.

Nicolai

mani4Author
Known Participant
July 17, 2015

i can move images inside the same page but if i want to move the page to some other page . it showing error in this line.

img.parent.move(doc.pages[Number(myPage)-1]);


Inspiring
July 17, 2015

Check if doc.pages[Number(myPage)-1] evaluates to a page.

I suspect that image parent is different, could you do alert(img.parent);?

mani4Author
Known Participant
July 17, 2015

see this line gives the correct page number where the image name text is present.

myPage = finds[0].parentTextFrames[0].parentPage.name;


but i'm getting error in this line..


img.parent.move(doc.pages[Number(myPage)-1]); 




mani4Author
Known Participant
July 16, 2015

no i have 5 different images in my document.

here this program concept is , i have to move the images to its correct location.

Inspiring
July 16, 2015

I see. You problem is this line:

myPage = finds[0].parentTextFrames[0].parentPage.name;


You need to get the page of your finds[0].


Check what you get for  parentPage above, it might be an array of all pages.


So if you add myPage = finds[0].parentTextFrames[0].parentPage[0].name; this might move your image to the first page.



Inspiring
July 17, 2015

This works for me (CS 5.5 OSX 10.9):

myPage = finds[0].parentTextFrames[0].parent.pages[0].name;



mani4Author
Known Participant
July 16, 2015

now i found , in my document i have 15 pages but i have only one text frame and that text frame is extended to 15 pages ..

i think thats why im getting this error..now how to resolve this ..

mani4Author
Known Participant
July 16, 2015

yeah i checked everything is there in my document.

image is there in page 2 and text references is there in page 5.

now image has to move to page 5. but im getting this error..

Inspiring
July 16, 2015

Is it one image only does not work, or you only have one image to move? If it is the case, try to move it explicitly:

img.parent.move(doc.pages[4]);


Disable everything else - second move and text-wrap.

Inspiring
July 16, 2015

Not sure if move will work for inline image. I would try to get the filepath, remove the image and place it again at the found[0] insertion point

mani4Author
Known Participant
July 16, 2015

now im getting error in that line. when i try to run this script in another document.

Inspiring
July 16, 2015

Check what all your references are correct, check that there is a page, check there is a graphic frame and there is an image in it.

mani4Author
Known Participant
July 13, 2015

thank u so much . i used this code and its working fine,.