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

How do I add custom property using Javascript to inDesign document?

Explorer ,
Jul 30, 2018 Jul 30, 2018

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.]

TOPICS
Scripting

Views

2.3K

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

Community Expert , Jul 30, 2018 Jul 30, 2018

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

Votes

Translate

Translate
Community Expert ,
Jul 30, 2018 Jul 30, 2018

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

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
Explorer ,
Jul 30, 2018 Jul 30, 2018

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!

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 ,
Jul 30, 2018 Jul 30, 2018

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

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
Explorer ,
Jul 30, 2018 Jul 30, 2018

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!

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 ,
Jul 30, 2018 Jul 30, 2018

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

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 ,
Jul 30, 2018 Jul 30, 2018

Copy link to clipboard

Copied

LATEST

petern55563219  wrote

… are there equivalent functions for Illustrator and Photoshop?

Good question.
I'd ask here:

Photoshop Scripting

Illustrator Scripting

Let us know if you find methods like InDesign's insertLabel() and extractLabel() with PhotoShop and Illustrator.

Regards,
Uwe

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