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

How to set script label on documents in the UI

Contributor ,
Sep 08, 2024 Sep 08, 2024

Copy link to clipboard

Copied

The Script Label window allows you to set an arbitrary label value to more or less any page object, a label which will subsequently be available in scripting.

 

According to the DOM, documents and book files (of type BookContent) also have the `label` property, but unlike page objects, documents and book files cannot – as far as I can tell – be ‘selected’ in a way that makes the Script Label field editable, so I cannot figure out a way to set the label on them from the UI – that is, without scripting.

 

Is there a way to do this?

TOPICS
Scripting

Views

405

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 , Sep 08, 2024 Sep 08, 2024

If you can't select it in the UI - then it's not possible to set a label. 

 

Votes

Translate

Translate
Community Expert ,
Sep 08, 2024 Sep 08, 2024

Copy link to clipboard

Copied

If you can't select it in the UI - then it's not possible to set a label. 

 

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 ,
Sep 08, 2024 Sep 08, 2024

Copy link to clipboard

Copied

As @Robert at ID-Tasker said, no way to do it from the UI. But if you're going to use scripting, ask yourself what you would set the label as and see if there's a way to do that through scripting. Is it part of the filename or some other property that would be available through the DOM?

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
Contributor ,
Sep 08, 2024 Sep 08, 2024

Copy link to clipboard

Copied

It’s for a value that cannot be inferred from anything in the document. The purpose is a script to export digital offprints for individual authors of anthologies, and the label is to indicate whether a specific document should be included in all offprints (for front and back matter), no offprints (for indices and things like that) or just one offprint (for individual articles/chapters).

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 ,
Sep 08, 2024 Sep 08, 2024

Copy link to clipboard

Copied

@Janus Bahs Jacquet

 

But in that case, you'll have to open document first?

 

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
Contributor ,
Sep 08, 2024 Sep 08, 2024

Copy link to clipboard

Copied

Basically, yes.

 

What I had hoped would be simple and easy was to select files in a Book in groups (in the UI) and mark each group with one of those three categories, then run the offprint script to generate the PDF files. The slightly more roundabout way I made do with for now is to open the files and use a script to assign the appropriate labels and then run the offprint script. A little more work, but still manageable.

 

If I can be bothered, perhaps at some point I’ll make a script with an interactive window that shows all the book files and lets me categorise them with drag-and-drop or something like that. That would have the added benefit of just adding the label to the BookContent object instead of the individual documents, which is where it really belongs anyway.

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 ,
Sep 08, 2024 Sep 08, 2024

Copy link to clipboard

Copied

@Janus Bahs Jacquet 

 

If it's specifically about Books - you could store all the information in the Book - using "hidden" labels:

 

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

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

 

This will save you time opening each document in the book.

 

On the other hand, if you store labels in the document - you can process all inidividual files without opening the book - but then you'll have to open each document.

 

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 ,
Sep 08, 2024 Sep 08, 2024

Copy link to clipboard

Copied

@Janus Bahs Jacquet 

 

Or you can store label with each BookContent object in the BookContents collection:

 

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

 

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
Contributor ,
Sep 08, 2024 Sep 08, 2024

Copy link to clipboard

Copied

That’s actually sort of what I’m doing now: as part of the main offprint script, I store a dictionary of which book files belong to which category in the Book file itself; that way, I only have to open all the files once, and on subsequent runs I can just export PDFs based on the data stored in the Book file.

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 ,
Sep 09, 2024 Sep 09, 2024

Copy link to clipboard

Copied

LATEST

There are also the UI’s File Info fields, which you could get via metadataPreferences.

 

alert(app.activeDocument.metadataPreferences.description)
 
 

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 ,
Sep 08, 2024 Sep 08, 2024

Copy link to clipboard

Copied

Hi @Janus Bahs Jacquet , You could make a scripted UI to label a document. Something like this:

 

makeDialog();

var d, lbl;
function makeDialog(){
  var theDialog = app.dialogs.add({name:"Label Document", canCancel:true});
  with(theDialog){
    with(dialogColumns.add()){
      staticTexts.add({staticLabel:"Open Documents:"});
      staticTexts.add({staticLabel:"Add Label:"});
    }
    with(dialogColumns.add()){
      d = dropdowns.add({stringList:app.documents.everyItem().name, selectedIndex:0, minWidth:150});
      lbl = textEditboxes.add({editContents:"", minWidth:150});
    }
    if(theDialog.show() == true){
      d = app.documents.item(d.selectedIndex);
      d.label = lbl.editContents
      $.writeln(d.label)
      theDialog.destroy();
    }
	}
}

 

Screen Shot 6.png

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
Contributor ,
Sep 08, 2024 Sep 08, 2024

Copy link to clipboard

Copied

Yeah, that’s basically what I ended up doing as a workaround (except just for the current document for simplicity). Not ideal, but better than nothing.

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 ,
Sep 08, 2024 Sep 08, 2024

Copy link to clipboard

Copied

@Janus Bahs Jacquet

 

But what is your end goal? Why do you need to label document or book - from the UI? 

 

 

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 ,
Sep 08, 2024 Sep 08, 2024

Copy link to clipboard

Copied

If you're on Mac, you can add comments to the files in the Finder, then read them.

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 ,
Sep 08, 2024 Sep 08, 2024

Copy link to clipboard

Copied

@leo.r 

 

On a PC it works as well - as long as you use Bridge to add information:

 

RobertatIDTasker_0-1725832425337.png

 

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

 

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