Skip to main content
grafik-kl
Inspiring
February 9, 2023
Answered

Is there a way to set and change the transparency of a complete layer?

  • February 9, 2023
  • 1 reply
  • 499 views

Hi community,

is there a way to set and change the transparency of a complete layer in InDesign?

I've several layers in my InDesign document. The items (usually PDFs) on the top layer need to be semi-transparent while working with the document, but must be fully visible in the later PDF. 

The layer-sets are always named in the same way (e.g. Construction-Paths, Bilder, Texte).

Thanks in advance

Jens

This topic has been closed for replies.
Correct answer Peter Kahrel

You'd have to set the transparency of all the items on those layers. Here's a script that does that.

 

At lines 3-5 you include the names of the layers that should be targeted.

Then at 'opacity' you set the desired opacity. To return to 'normal', set it to 100.

 

(function () {
  
  const layers = [
    'Construction-Paths',
    'Bilder',
    'Texte',
  ];
  
  const opacity = 50;
  
  
  function setOpacity (layer) {
    if (!layer.isValid) {
      return;
    }
    var items = layer.pageItems.everyItem().getElements();
    for (var i = 0; i < items.length; i++) {
      try {
        items[i].transparencySettings.blendingSettings.opacity = opacity;
      } catch (_) {
      }
    }
  }
        
  
  for (var i = 0; i < layers.length; i++) {
    setOpacity (app.documents[0].layers.item(layers[i]));
  }

}());

 

1 reply

Peter Kahrel
Community Expert
Peter KahrelCommunity ExpertCorrect answer
Community Expert
February 9, 2023

You'd have to set the transparency of all the items on those layers. Here's a script that does that.

 

At lines 3-5 you include the names of the layers that should be targeted.

Then at 'opacity' you set the desired opacity. To return to 'normal', set it to 100.

 

(function () {
  
  const layers = [
    'Construction-Paths',
    'Bilder',
    'Texte',
  ];
  
  const opacity = 50;
  
  
  function setOpacity (layer) {
    if (!layer.isValid) {
      return;
    }
    var items = layer.pageItems.everyItem().getElements();
    for (var i = 0; i < items.length; i++) {
      try {
        items[i].transparencySettings.blendingSettings.opacity = opacity;
      } catch (_) {
      }
    }
  }
        
  
  for (var i = 0; i < layers.length; i++) {
    setOpacity (app.documents[0].layers.item(layers[i]));
  }

}());

 

grafik-kl
grafik-klAuthor
Inspiring
February 9, 2023

Thank's al lot! I will test it tomorrow morning.

 

Jens

grafik-kl
grafik-klAuthor
Inspiring
February 10, 2023

Works like a charm... 🙂