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

Accessing library items from scripts

Contributor ,
Feb 26, 2025 Feb 26, 2025

Copy link to clipboard

Copied

Hello, 

 

Is it possible to access library items from scripts?

 

Really hope there is a way! 

 

Many thanks 

 

Smyth

TOPICS
How to , Scripting , SDK , UXP Scripting

Views

98
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 ,
Feb 26, 2025 Feb 26, 2025

Copy link to clipboard

Copied

CC libraries no, local libraries yes through Extendscript. 

Votes

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
Contributor ,
Feb 27, 2025 Feb 27, 2025

Copy link to clipboard

Copied

Hello, 

 

Thank you for your reply, so in theory a library which sits on my desktop I could access via a script? 

My thinking is, if you can access libary items,  would there be a way to make a script to do things to particular library items via the name of those items?

 

For example if you really wanted to, can you do a paste in place via the script looking for say library item called 'template'... this is just 

 

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

SmythWharf_0-1740655098798.pngexpand image

 

 

Best, 

 

Smyth.

Votes

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 ,
Feb 27, 2025 Feb 27, 2025

Copy link to clipboard

Copied

Hi @SmythWharf 

 

By “library item” do you mean the library itself or some particular asset within such a library? I guess you're using the latter sense (?)

 

  • As such, the Library object (container of assets) corresponds to an indl file — assuming local lib — and can be accessed and/or instanciated through app.libraries. This collection is empty if no library is presently available (=opened) in InDesign, but you can use app.libraries.add("/path/to/MyLibrary.indl"); to load a particular library. The name property of a Library instance — still assumed local — is the underlying file name. If your library is already loaded in ID, just use myLib = app.libraries.itemByName("MyLibrary.indl"); to get the corresponding specifier.

 

  • From then, go to the Assets collection (myLib.assets) to navigate through the items this library contains. As usual, those elements are accessible by index or by name. So, if a particular asset is named template, you can easily retrieve a specifier using myAsset = myLib.assets.itemByName("template"); and then enjoy the Asset API. What you're probably looking after is myAsset.placeAsset(<where>), whose <where> argument refers to either a Document or Text instance, and which returns the placed item(s) as an array. The placeAsset behavior/target depends on myAsset.assetType, but in common cases you should expect this method to position the placed asset at its original location, that is, at the coordinates it owned when the InDesign user drag&dropped the item into the Library panel. (Changing the default placeAsset mechanism is an open question to me, although I admit I haven't experimented much in this field.)

 

Best,

Marc

 

 

Votes

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
Contributor ,
Feb 27, 2025 Feb 27, 2025

Copy link to clipboard

Copied

LATEST

Hello, 

 

This is excellent starter information. Very curious indeed. 

 

Best, 

 

Smyth

Votes

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