Highlighted

Anchor the images in the same page using javascript

Community Beginner ,
Aug 23, 2020

Copy link to clipboard

Copied

Hi Everyone,

How to anchor the images in the same page using javascript. Please help me!!!

 

Thanks,

Magesh

Adobe Community Professional
Correct answer by Laubender | Adobe Community Professional

Hi Magesh,

let's assume you want to anchor a rectangle to a text insertion point.

Study the method insertAnchoredObject() of the anchoredObjectSettings of a rectangle object:

https://www.indesignjs.de/extendscriptAPI/indesign-latest/#AnchoredObjectSetting.html#d1e383930__d1e384388

 

Basically you need an insertion point and the rectangle, that contains the image you want to anchor.

Let's assume you selected the text frame with the mouse first and added the rectangle to your selection.

Then the following will work:

 

 

var myTextFrame = app.selection[0];
var myInsertionPoint = myTextFrame.insertionPoints[0];
var myRectangle = app.selection[1];

myRectangle.anchoredObjectSettings.
insertAnchoredObject
(
myInsertionPoint ,
AnchorPosition.ANCHORED
);

 

 

Regards,
Uwe Laubender

( ACP )

 

// EDITED CODE: AnchorPosition.ANCHORED is needed instead of AnchorPosition.Anchored.

Topics

Scripting

Views

64

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

Anchor the images in the same page using javascript

Community Beginner ,
Aug 23, 2020

Copy link to clipboard

Copied

Hi Everyone,

How to anchor the images in the same page using javascript. Please help me!!!

 

Thanks,

Magesh

Adobe Community Professional
Correct answer by Laubender | Adobe Community Professional

Hi Magesh,

let's assume you want to anchor a rectangle to a text insertion point.

Study the method insertAnchoredObject() of the anchoredObjectSettings of a rectangle object:

https://www.indesignjs.de/extendscriptAPI/indesign-latest/#AnchoredObjectSetting.html#d1e383930__d1e384388

 

Basically you need an insertion point and the rectangle, that contains the image you want to anchor.

Let's assume you selected the text frame with the mouse first and added the rectangle to your selection.

Then the following will work:

 

 

var myTextFrame = app.selection[0];
var myInsertionPoint = myTextFrame.insertionPoints[0];
var myRectangle = app.selection[1];

myRectangle.anchoredObjectSettings.
insertAnchoredObject
(
myInsertionPoint ,
AnchorPosition.ANCHORED
);

 

 

Regards,
Uwe Laubender

( ACP )

 

// EDITED CODE: AnchorPosition.ANCHORED is needed instead of AnchorPosition.Anchored.

Topics

Scripting

Views

65

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
Adobe Community Professional ,
Aug 23, 2020

Copy link to clipboard

Copied

Hi Magesh,

you can anchor graphic frames to text. And you can move around text frames in your document. The anchored frames will move along. What you cannot do: Anchor a graphic frame so that it is visible on one spread but it is anchored to a text on a different spread.

 

That are some basics. I have no idea what you exactly like to do.

 

Show some screenshots with a before and after situation.

And explain better, please. What do you mean by "same page" for example? "same" like what?

 

Regards,
Uwe Laubender

( ACP )

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
Reply
Loading...
Community Beginner ,
Aug 24, 2020

Copy link to clipboard

Copied

Hi Laubender,

Thanks for your reply!!

My question is very simple. InDesign document has the image without an anchor. So we need to provide the anchor to near text (same page or spread) using script.

Mageshwaran_1-1598272321213.png

 

Thanks,

Magesh

 

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
Reply
Loading...
Adobe Community Professional ,
Aug 24, 2020

Copy link to clipboard

Copied

Hi Magesh,

let's assume you want to anchor a rectangle to a text insertion point.

Study the method insertAnchoredObject() of the anchoredObjectSettings of a rectangle object:

https://www.indesignjs.de/extendscriptAPI/indesign-latest/#AnchoredObjectSetting.html#d1e383930__d1e...

 

Basically you need an insertion point and the rectangle, that contains the image you want to anchor.

Let's assume you selected the text frame with the mouse first and added the rectangle to your selection.

Then the following will work:

 

 

var myTextFrame = app.selection[0];
var myInsertionPoint = myTextFrame.insertionPoints[0];
var myRectangle = app.selection[1];

myRectangle.anchoredObjectSettings.
insertAnchoredObject
(
myInsertionPoint ,
AnchorPosition.ANCHORED
);

 

 

Regards,
Uwe Laubender

( ACP )

 

// EDITED CODE: AnchorPosition.ANCHORED is needed instead of AnchorPosition.Anchored.

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
Reply
Loading...