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

How to Retrieve the Linked Object from a LinkedPageItem in InDesign

Participant ,
Sep 26, 2024 Sep 26, 2024

Copy link to clipboard

Copied

object.LinkedPageItemOption.parent does *not* get the linked object, it is just the object.

How do I get the linked object!?

 

If object-A is a link of Object-B, how do I get object-B if i have object-A?

 

<Title renamed by MOD>

TOPICS
How to , Scripting , SDK

Views

477

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
community guidelines
Engaged ,
Sep 26, 2024 Sep 26, 2024

Copy link to clipboard

Copied

@Lordrhavin 

The frames in a series of linked/chined frames are not parent of one another but rather Previous and Next frames relative to one another.

I'm not sure how this would translate to scripting, but using the SDK, finding the previous frame in a chain goes something like:

int32 mcfFirstFrameIndex = frameList->GetFrameIndex(mcf->GetUIDInFrameList(kFalse/*first*/));
if (mcfFirstFrameIndex == 0) {
// The given graphic frame contains the first frame in the frame list.
// There is no previous frame.
break;
}
// Determine the graphic frame that contains the previous kFrameItemBoss in the frame list.
InterfacePtr<ITextFrameColumn> previousTFC(frameList->QueryNthFrame(mcfFirstFrameIndex-1));
if (!previousTFC) {
break;
}
UIDRef previousGraphicFrameRef = this->GetGraphicFrameRef(previousTFC, kTrue/*isTOPFrameAllowed*/);
result = previousGraphicFrameRef;

Very best regards,

Olivier

Votes

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
community guidelines
Community Expert ,
Sep 26, 2024 Sep 26, 2024

Copy link to clipboard

Copied

@Olivier Beltrami

 

Are you referring to Text Containers of the Story?

 

Votes

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
community guidelines
Engaged ,
Sep 26, 2024 Sep 26, 2024

Copy link to clipboard

Copied

@Robert at ID-Tasker Ah, srry I thought he was referring to linked/chained text frames.

Votes

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
community guidelines
Guide ,
Sep 28, 2024 Sep 28, 2024

Copy link to clipboard

Copied

This thread is tagged with SDK, but new users with a script centric mindset do not know that the tag is about C++ plug-ins. So let's give an answer from the plug-in perspective:

 

The linked page item is an object of kind kSplineItemBoss, which to scripting identifies as type c_TextFrame.

Such objects have multiple sub-objects "interfaces", the relevant here is IID_ILINKOBJECT.

IID_ILINKOBJECT has a list of multiple links, shared content uses kSharedArticleLinkBoss.

 

The kSharedArticleLinkBoss (scripting type is c_Link) via its IID_ILINK points to a kLinkResourceBoss and back to the "link object" which in scripting shows as parent - the kSplineItemBoss.

 

The kLinkResourceBoss has no direct scripting type, relevant properties are exposed in above c_Link.

Important to us is the link resource URI such as "idinternalSharedArticle:8658".

 

URIs have a protocol such as file:, http:, or in this case idinternalSharedArticle.

The rhs part is interesting for our purposes. While it is numeric, it does not refer to the typical UID that shows as id property in scripting.

 

Instead, there is a global lookup table on the kDocBoss (scripting: c_Document) as interface IID_ISHAREDCONTENTTABLE, which appears to map the ID 8658 to the original kSplineItemBoss / c_TextFrame. Undocumented, missing header, but ISharedContentFacade has promising methods.

 

This ID 8658 is also available to scripting at the original text frame, but only in the IDML scripting subsystem. IDML (and Snippet) will show an attribute LinkResourceId="8658" … that is missing in Javascript, I've also tried AppleScript.

Someone please file a feature request to expose that property to the other scripting languages …

Until then, searching IDML might help.

 

That's the simplified version, though.

 

Pick up your page item via content picker tool, switch to a different document and place it there using content placer tool. The link is still created, pointing to a different document. The URI would be 

link resource URI:"idexternalSharedArticle:/Volumes/Stuff/linked%20page%20items.indd?8658".

Yep, the linked page item may reside in a different document.

 

There is also that other link: the text frame has its story, and the story is linked in a similar way. Of course the original story may have additional text frames (see @Olivier Beltrami above), or actually text containers, which again might be linked so when you're preparing to copy, better consider that.

Besides there might be other link types involved such as InCopy assignment.

 

Happy programming …

Votes

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
community guidelines
Community Expert ,
Sep 28, 2024 Sep 28, 2024

Copy link to clipboard

Copied

Hi @Dirk Becker , There are a few other related threads, @Lordrhavin is coding with ExtendScript.

Votes

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
community guidelines
Community Expert ,
Sep 28, 2024 Sep 28, 2024

Copy link to clipboard

Copied

@Dirk Becker 

 

Thanks for the explanation.

 

Unfortunately, IDMLing would be way more hassle than what @rob day posted earlier - iterating thorught the Links collection and comparing ID of the link's parent to the selected item's ID and executing goToSource() and then restoring selection.

 

Or, In my case, if nothing is selected, I'll just load all links and add extra info if available.

 

Votes

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
community guidelines
Guide ,
Sep 28, 2024 Sep 28, 2024

Copy link to clipboard

Copied

@Robert at ID-Tasker as I said, this is the C++ plug-in perspective.

For scripting, I did not check whether/how InDesign Server supports goToSource(), given the missing selection.

Also a future reader may come frome IDML wondering about that attribute, or decide to start off IDML in the first place.

Votes

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
community guidelines
Community Expert ,
Sep 28, 2024 Sep 28, 2024

Copy link to clipboard

Copied

LATEST

@Dirk Becker

 

Yes, of course, valuable info anyway. 

 

Votes

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
community guidelines
Community Expert ,
Sep 26, 2024 Sep 26, 2024

Copy link to clipboard

Copied

As far as I understand, you can't get it from LinkedPageItemOption. Try to explore the link object properties?

Votes

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
community guidelines
Community Expert ,
Sep 26, 2024 Sep 26, 2024

Copy link to clipboard

Copied

p.s. the "can" in my previous reply is corrected to "can't". added for clarity.

Votes

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
community guidelines
Community Expert ,
Sep 26, 2024 Sep 26, 2024

Copy link to clipboard

Copied

Votes

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
community guidelines
New Here ,
Sep 26, 2024 Sep 26, 2024

Copy link to clipboard

Copied

Votes

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
community guidelines
Community Expert ,
Sep 26, 2024 Sep 26, 2024

Copy link to clipboard

Copied

@rhavin

 

PageItems do not have link property.

 

Only graphic, sound, movie, etc.:

 

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

 

(scroll to the end) 

 

Votes

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
community guidelines
Community Expert ,
Sep 26, 2024 Sep 26, 2024

Copy link to clipboard

Copied

A Link is an element of the Links collection which is a property of Document. For example:

var myLink = app.activeDocument.links[0];

 

Or to go the other way:

var myLink = doc.pageItems[0].graphics[0].itemLink;

 

But maybe we're missing the point if we don't know what you are trying to do.

- Mark

Votes

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
community guidelines
Community Expert ,
Sep 26, 2024 Sep 26, 2024

Copy link to clipboard

Copied

Linked items appear in the Links panel:

 

leor_0-1727395886852.png

 

And, therefore, they are included in the links of the document and you can retrieve their link properties. Whether you can get anything useful for your goal is a different question.

Votes

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
community guidelines
Community Expert ,
Sep 26, 2024 Sep 26, 2024

Copy link to clipboard

Copied

Hi @Lordrhavin, If you are scripting, rather than SDKing, could you share the code that shows the issue?

 

I've done a fair bit of scripting Indesign and never used "linkedPageItemOptions" and I honestly don't know what it does. I did a google search and literally no script examples came up, which seems pretty strange. I wonder if you are using the wrong property? What are you trying to do? My guess is that linkedPageItemOptions aren't needed.

- Mark

Votes

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
community guidelines
New Here ,
Sep 26, 2024 Sep 26, 2024

Copy link to clipboard

Copied

As far as I understand, it is the options of the contentPlace-process. If you place content and it is not a copy but a link, those should be options set in the dialog.

https://www.indesignjs.de/extendscriptAPI/indesign-latest/#PageItem.html#d1e208586__d1e210442

Votes

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
community guidelines
New Here ,
Sep 27, 2024 Sep 27, 2024

Copy link to clipboard

Copied

I dont understand what you're all talking about. Sorry.

 

You have Object-A. (for example: a group of a textframe and and Image)

 

You create Object-B as a link of Object-A. So if you change Object-A's Textframe-text, Object-B will update.

 

Now, later on, you get hold of Object-B.

 

How do ypu get Object-A if you have Object-B? They're linkt, right…? This cant be that complicated..

Votes

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
community guidelines
Community Expert ,
Sep 27, 2024 Sep 27, 2024

Copy link to clipboard

Copied

quote

This cant be that complicated..


By @rhavin

 

Have you tried yourself? 

 

Votes

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
community guidelines
Community Expert ,
Sep 27, 2024 Sep 27, 2024

Copy link to clipboard

Copied

Hi @Lordrhavin , Look at the link object’s goToSource() method. The pageItem’s linkedPageItemOption lets you set the Link Options... for a link, which you access via the Link panel’s flyout menu in the UI.

 

For example here there are 2 linked objects, which both link to the top rectangle:

 

Screen Shot 26.png

 

 

If I select one of the linked page items, I can get its source via goToSource and edit it like this:

 

//get the document links
var lnks = app.activeDocument.links

//a selected linked page item
var sel = app.selection[0]
var ls;

//loop thru the links and if the selection’s id and the link’s parent id match
//use goToSource which selects the source rectangle
for (var i = 0; i < lnks.length; i++){
    if (sel.id == lnks[i].parent.id) {
        lnks[i].goToSource();
        ls = app.selection[0]
    } 
};

//change the source fill color to Black and update the links
ls.fillColor= "Black";
lnks.everyItem().update();

 

 

Screen Shot 27.png

Votes

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
community guidelines
Community Expert ,
Sep 27, 2024 Sep 27, 2024

Copy link to clipboard

Copied

@rob day

 

Can't check it right now - but per my screenshots on the other thread - wouldn't be enough to check if linkedPageItemOptions is valid - and then use goToSource()?

 

Then you won't have to iterate through links collection? 

 

Votes

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
community guidelines
Community Expert ,
Sep 27, 2024 Sep 27, 2024

Copy link to clipboard

Copied

wouldn't be enough to check if linkedPageItemOptions is valid - and then use goToSource()?

 

I’m not sure—a selected pageItem doesn’t have an itemLink property and goToSource() is a method of the link object, so you have to get to the link in order to use goToSource(). I don’t use page item links, so I could be missing something.

Votes

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
community guidelines
Community Expert ,
Sep 27, 2024 Sep 27, 2024

Copy link to clipboard

Copied

@rob day

 

You're right - linkedPageItemOptions belongs to pageItem - but pageItem doesn't have link info.

 

 

But that gave me an idea - looks like, after all - I'll have to include extra parent info in my IDT. 

 

Not for objects / pageItems - that's already included in the Tree column, but for - in this case - links. Then I'll be able to quickly find linked objects. 

 

 

Votes

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
community guidelines
Community Expert ,
Sep 27, 2024 Sep 27, 2024

Copy link to clipboard

Copied

@rob day

 

Unless, somehow - but can't check it right now - linkedPageItemOptions.parent returns linked source item - and not the item queried ...

 

Votes

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
community guidelines