Skip to main content
Participant
January 23, 2024
Answered

InDesign SDK - how to get link's properties from insertLabel?

  • January 23, 2024
  • 1 reply
  • 259 views

Hi everyone,

 

On INDD server, I am using insertLabel method to save my custom data

var links = document.links;
var link = links[0];
link.insertLabel("AAA", "Test1");
link.insertLabel("BBB", "Test");

 

When exporting, I got the result as expected

<Rectangle Self="ue9" ContentType="GraphicType">
	<TextWrapPreference Inverse="false" ApplyToMasterPageOnly="false" TextWrapSide="BothSides" TextWrapMode="None">
		...
	</ObjectExportOption>
	<Image Self="u143" Space="$ID/#Links_RGB" ActualPpi="72 72">
		<Properties>
			...
		</Properties>
		<TextWrapPreference Inverse="false" ApplyToMasterPageOnly="false" TextWrapSide="BothSides" TextWrapMode="None">
			...
		<Link Self="ue8" AssetURL="$ID/" AssetID="$ID/" RenditionData="Actual" LinkResourceURI="file:D:/AAA.jpg" LinkClassID="35906" LinkClientID="257" LinkResourceSize="0~1e97c">
			<Properties>
				<Label>
					<KeyValuePair Key="AAA" Value="Test1" />
					<KeyValuePair Key="BBB" Value="Test2" />
				</Label>
			</Properties>
		</Link>
		<ClippingPathSettings ClippingType="None" InvertPath="false" IncludeInsideEdges="false" />
		<ImageIOPreference ApplyPhotoshopClippingPath="true"  />
	</Image>
</Rectangle>

 

Now, comes to the SDK with cpp code (I don't have much expierence and knowlege...)

I have tried many different ways but couldn't get these properties

 

How should I do here?

PMRsrcID MyCustomLinkProvider::GetUpdatedIconForLink(const ILink* link, const ILinkResource* linkResource) const {
   // How to get these properties?
}

 

Thanks very much !

This topic has been closed for replies.
Correct answer codsay

Thanks for your reply.

 

I finally made it works.

Here is example code for everyone:

InterfacePtr<IScript> iScript(link, UseDefaultIID());
if (iScript)
{
	IScriptLabel::ScriptLabelKeyValueList tags = iScript->GetTags();
	if (!tags.empty())
	{
		IScriptLabel::ScriptLabelKeyValueList::iterator iter;
		for (iter = tags.begin(); iter < tags.end(); iter++)
		{
			std::string key = (*iter).Key().GetPlatformString().c_str();
			std::string value = (*iter).Value().GetPlatformString().c_str();
		}
	}
}

 

1 reply

Community Expert
January 23, 2024

I think you would have to query the IScript interface from the LinkBoss and then you can call the method GetTag method

virtual ScriptLabelValue  GetTag (const ScriptLabelKey &key)

-Manan

-Manan
codsayAuthorCorrect answer
Participant
January 23, 2024

Thanks for your reply.

 

I finally made it works.

Here is example code for everyone:

InterfacePtr<IScript> iScript(link, UseDefaultIID());
if (iScript)
{
	IScriptLabel::ScriptLabelKeyValueList tags = iScript->GetTags();
	if (!tags.empty())
	{
		IScriptLabel::ScriptLabelKeyValueList::iterator iter;
		for (iter = tags.begin(); iter < tags.end(); iter++)
		{
			std::string key = (*iter).Key().GetPlatformString().c_str();
			std::string value = (*iter).Value().GetPlatformString().c_str();
		}
	}
}