Skip to main content
Participant
June 18, 2020
Answered

How can I create a tex frame on a specific layer on a specific page range with script?

  • June 18, 2020
  • 2 replies
  • 541 views

I need to create a text frame on a specific layer on a specified range of pages. 

 

Here's part of my scripts inside of a function 

 

myLayer = myDoc.layers.itemByName("DATE");

myPage = myDoc.pages[i];

rect = myPage.textFrames.add({layer:myLayer, geometricBounds : [158,91,183,330]});

 

I end up getting the texts created on the current active layer instead of the "DATE" one. Anyone could tell me what went wrong in my scripts? or any alternative ways I can achieve this?

 

Thanks

 

This topic has been closed for replies.
Correct answer Manan Joshi

The property you are looking for is itemLayer and not Layer. So the last line should be changed to

 

rect = myPage.textFrames.add({itemLayer:myLayer, geometricBounds : [158,91,183,330]});

 

 

For more properties/methods available on textframe object, see the following

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

 

-Manan

2 replies

YuqiWAuthor
Participant
June 18, 2020

Hi Manan

It worked!!!

Thank you very much!!!

I guess I'll get a lot of help and improve my scripting skills here 🙂

Yuqi

Manan JoshiCommunity ExpertCorrect answer
Community Expert
June 18, 2020

The property you are looking for is itemLayer and not Layer. So the last line should be changed to

 

rect = myPage.textFrames.add({itemLayer:myLayer, geometricBounds : [158,91,183,330]});

 

 

For more properties/methods available on textframe object, see the following

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

 

-Manan

-Manan