Skip to main content
Janus Bahs Jacquet
Inspiring
September 8, 2024
Answered

How to set script label on documents in the UI

  • September 8, 2024
  • 3 replies
  • 1226 views

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?

This topic has been closed for replies.
Correct answer Robert at ID-Tasker

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

 

3 replies

rob day
Community Expert
September 8, 2024

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();
    }
	}
}

 

Janus Bahs Jacquet
Inspiring
September 8, 2024

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.

Robert at ID-Tasker
Brainiac
September 8, 2024

@Janus Bahs Jacquet

 

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

 

 

brian_p_dts
Community Expert
September 8, 2024

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?

Janus Bahs Jacquet
Inspiring
September 8, 2024

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

Robert at ID-Tasker
Brainiac
September 8, 2024

@Janus Bahs Jacquet

 

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

 

Robert at ID-Tasker
Robert at ID-TaskerCorrect answer
Brainiac
September 8, 2024

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