Skip to main content
Inspiring
June 18, 2018
Answered

Place specific pdf layer into indesign with javascript

  • June 18, 2018
  • 1 reply
  • 4586 views

Hi,

I have multi-layered pdf file and I need to place into indesign CS6 only specific layer from that pdf:

creaseLayer = myDoc.layers.item("Crease");

How can I do it with javascript?

Thank you.

Yulia

This topic has been closed for replies.
Correct answer Loic.Aigon

Yes indeed. I was trying to say that you cannot set layer's visibility during the import phase but later (like just after the place command) once the file has been placed onto the layout.

var f = File ( Folder.desktop+"/layers.pdf" );

var pdf = app.activeDocument.pages[0].rectangles.add().place( f )[0];

pdf.parent.fit ( FitOptions.FRAME_TO_CONTENT );

pdf.parent.move ( [0,0] );

var layers = pdf.graphicLayerOptions.graphicLayers;

var layerA = layers.itemByName ("LAYER A");

var layerB = layers.itemByName ("LAYER B");

layerA.isValid && layerA.currentVisibility = false;

layerB.isValid && layerB.currentVisibility = true;

1 reply

Loic.Aigon
Legend
June 19, 2018

Hi Yulia,

Nothing you set on import but once file has been placed. See "graphicLayerOptions" of PDF instance

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

Inspiring
June 20, 2018

Hi Loic.Aigon,

If I understand you correctly, it can not be done through scripting and can only done by person?

Thank you

Yulia

Community Expert
June 22, 2018

I am sorry, I am just trying to figure out scripting on my own. I don't have an idea of what this is and what to do about it.


Hi Yulia,

see the preferences of InDesign's UI.

Under "File Handling" > "Links" where you can control visibility of layers in placed graphics.

Check its details first without scripting, do your tests updating your placed PDF and see if it is working as intended with your sample file.

After you find a way to make it work using the UI try the same thing using InDesign's scripting DOM. When doing changes in the UI test the state of your placed PDF by using scripting to see what properties with what values are used around graphicLayersOptions and associated graphicLayers.

Regards,
Uwe