Copy link to clipboard
Copied
How do I add custom property using Javascript to inDesign document?
I think Metadata could be one solution but I am new to all this so need more information.
[Question moved to the InDesign Scripting forum. -Mod.]
petern55563219 wrote
… I guess these functions work on selected item.
Absolutely not.
Methods insertLabel() and extractLabel() are available on object document as well.
Even on object app. If used with object document the information will also travel on with IDML export.
And the two methods are with a lot of other objects as well. Simply check DOM documentation:
https://www.indesignjs.de/extendscriptAPI/indesign-latest/#about.html
Best,
Uwe
Copy link to clipboard
Copied
Hi Peter,
do you like to add something like comments?
See into methods insertLabel( keyString , valueString ) and extractLabel( keyString ) that returns valueString.
Method insertLabel():
Adobe InDesign CS6 (8.0) Object Model JS: Document
Method extractLabel():
Adobe InDesign CS6 (8.0) Object Model JS: Document
Note: There is a limit of the amount of data that can go into a value string.
InDesign will not throw an error if you exceed the limit with insertLabel().
Reards,
Uwe
Copy link to clipboard
Copied
Hi Uwe,
Thank for your reply and thanks for sharing links. I guess these functions work on selected item.
I want to add some information on document level. Like property of that document; which need not to be visible on page itself.
Warm regards!
Copy link to clipboard
Copied
petern55563219 wrote
… I guess these functions work on selected item.
Absolutely not.
Methods insertLabel() and extractLabel() are available on object document as well.
Even on object app. If used with object document the information will also travel on with IDML export.
And the two methods are with a lot of other objects as well. Simply check DOM documentation:
https://www.indesignjs.de/extendscriptAPI/indesign-latest/#about.html
Best,
Uwe
Copy link to clipboard
Copied
Just tried that after posting my reply and it worked.
Laubender​ How can I verify in UI that label in inserted?
are there equivalent functions for Illustrator and Photoshop?
Thanks in advance!
Copy link to clipboard
Copied
Hi Peter,
you cannot. Not on object document. For that you'd have to export to IDML and check the interior XML file designmap.XML of the package.
<Properties>
<Label>
<KeyValuePair Value="2" Key="kAdobeDPS_Version"/>
<KeyValuePair Value="XXXX" Key="YYYY"/>
</Label>
</Properties>
Where I inserted a value "XXXX" with a key "YYYY".
Key "kAdobeDPS_Version" is set by app every time you add a document.
If you want to add visible key-value pairs you have to insert them with a special key and that is "Label".
On selectable objects you can see the value with InDesign's ScriptLabel functionality.
"Label" is also working as property of an object like:
rectangle.label = "ValueString";
rectangle.extractLabel("Label")
would return "ValueString".
Regards,
Uwe
Copy link to clipboard
Copied
petern55563219 wrote
… are there equivalent functions for Illustrator and Photoshop?
Good question.
I'd ask here:
Let us know if you find methods like InDesign's insertLabel() and extractLabel() with PhotoShop and Illustrator.
Regards,
Uwe