Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


InDesign link update with new path through c++ plugin

Participant ,
May 26, 2021 May 26, 2021

Copy link to clipboard

Copied

Hi Everyone,

 

I need to set the new link path of image and update the link. But my code update the link path and it shows the Yellow highlighted modified icon in links panel.  I shown my code in below.

 

InterfacePtr<ILinkResourceStateUpdateCmdData> cmdData(cmd, UseDefaultIID());
cmdData->SetResource(*iter);
cmdData->SetDatabase(iDatabase);
cmdData->SetNotify(true);
cmdData->SetUpdateAction(ILinkResourceStateUpdateCmdData::kUpdateURI);
cmdData->SetURI(newURI);
cmdData->SetDatabaseModified(kTrue);

 

The issue is, the new link path is updated. But the image thumbnail not changed.

 

Could anyone reply me If I did anything wrong?

 

Thanks.

 

TOPICS
SDK

Views

279

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

correct answers 1 Correct answer

Adobe Community Professional , Jun 05, 2021 Jun 05, 2021
Sorry did not get time before to write some test code for your use case. So the RelinkLink method works fine for me. I started with an InDesign document with a single image placed, then I used the code below to relink the image to a new PDF. The image was successfully linked and the panel was updated accordingly. IDocument * doc = GetExecutionContextSession()->GetActiveContext()->GetContextDocument(); InterfacePtr<const ILinkManager> linkManager(doc,UseDefaultIID()); ILinkManager::QueryResult re...

Likes

Translate

Translate
Adobe Community Professional ,
May 26, 2021 May 26, 2021

Copy link to clipboard

Copied

Did you look into RelinkLink method of ILinkFacade, looks like it could work for your case.

-Manan

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
community guidelines
Participant ,
May 26, 2021 May 26, 2021

Copy link to clipboard

Copied

Thanks Manan. I tried using the ReinitResource method in the code.

for (ILinkManager::QueryResult::const_iterator iter(linkQueryResult.begin()), end(linkQueryResult.end()); iter != end; ++iter)
{
	InterfacePtr<ILinkResource> iLinkResource(iDatabase, *iter ,UseDefaultIID());
	if(iLinkResource!=nil)
	{
		URI newImageURI = iLinkResource->GetURI();
		Utils<Facade::ILinkFacade>()->ReinitResource(UIDRef(iDatabase, *iter), newImageURI);
	}
}

 

Here, I am updating links one by one using loop.

But, nothing changed with invoking ReinitResource function. Still the issue not fixed. Please anyone let me know if I made any wrong in the above code.

 

Thanks.

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
community guidelines
Adobe Community Professional ,
May 26, 2021 May 26, 2021

Copy link to clipboard

Copied

Looking at your code I see that your code does not make any change in my opinion. You are assigning the URI or the *iter again to *iter so nothing changed. The resource URI should be a new one right?

Also, I suggested you to use RelinkLink instead of ReinitResource function, did you try that?

-Manan

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
community guidelines
Participant ,
May 26, 2021 May 26, 2021

Copy link to clipboard

Copied

I have not yet attempted to use the RelinkLink function. 

I'm sorry Manan. I missed to add this line in my previous comment before the ReinitResource function. I changed the scheme name for the link.

newImageURI.SetComponent(URI::kScheme, targetScheme);

 

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
community guidelines
Participant ,
May 26, 2021 May 26, 2021

Copy link to clipboard

Copied

Hi Manan,

 

I tried the below code snippet for RelinkLink function.

InterfacePtr<IUIDData> linkRef(this, UseDefaultIID());
if (linkRef)
{
	UID newLinkUID;
	Utils<Facade::ILinkFacade>()->RelinkLink(linkRef->GetRef(), newImageURI, kMinimalUI, newLinkUID);
}

 

I am using this keyword in getting linkRef. But Indesign quit unfortunately.

I don't know, how to successfully get the linkRef using *iter?

 

Please advise me on this issue.

 

Thanks.

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
community guidelines
Adobe Community Professional ,
Jun 05, 2021 Jun 05, 2021

Copy link to clipboard

Copied

Sorry did not get time before to write some test code for your use case. So the RelinkLink method works fine for me. I started with an InDesign document with a single image placed, then I used the code below to relink the image to a new PDF. The image was successfully linked and the panel was updated accordingly.

IDocument * doc = GetExecutionContextSession()->GetActiveContext()->GetContextDocument();
InterfacePtr<const ILinkManager> linkManager(doc,UseDefaultIID());
ILinkManager::QueryResult results;
LinkQuery query;
linkManager->QueryLinks(query, kIDLinkClientID, results);
for (auto linkUID: results) {
    UIDRef linkUIDRef(GetDataBase( linkManager ), linkUID);
    UID newLinkUID;
    URI newLinkPath("file:///Users/manan/Downloads/test.pdf");
    Utils<Facade::ILinkFacade>()->RelinkLink(linkUIDRef, newLinkPath, UIFlags::kSuppressUI, newLinkUID);
}

You can change the filepath to something on your machine and try.

-Manan

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
community guidelines
Participant ,
Jun 06, 2021 Jun 06, 2021

Copy link to clipboard

Copied

LATEST

 

It works very well. Thank you Manan.

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
community guidelines
Participant ,
Jun 01, 2021 Jun 01, 2021

Copy link to clipboard

Copied

Hi Manan,

 

Could you help me to fixing this issue. Please correct me if I did anything wrong in the adobe code.

 

Thanks.

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