Skip to main content
Mario Fritsche
Legend
November 21, 2022
Question

Create primaryTextFrame

  • November 21, 2022
  • 3 replies
  • 1261 views

Hello,
per script I want to create a new MasterPage and create a primaryTextFrame on it? TextFrame is no problem, but I can't get it set to primary.

This topic has been closed for replies.

3 replies

brian_p_dts
Community Expert
Community Expert
November 22, 2022

The MasterSpread object has a primaryTextFrame property. I've enver used it but I would imagine it would be something like: 

myParentSpread.primaryTextFrame = myParentSpread.textFrames.add();

 

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

Peter Kahrel
Community Expert
Community Expert
November 22, 2022

Nope, doesn't work: "Invalid object for this request".

brian_p_dts
Community Expert
Community Expert
November 22, 2022

Hmm, bug? If you have a PTF set on the parent, then mySpread.primaryTextFrame.isValid is true, but you're right, doesn't seem you can set it on the fly. Weird. 

Peter Kahrel
Community Expert
Community Expert
November 21, 2022

There's a property createPrimaryTextFrame, which is a creation property, that is, you have to set the property when you create a document. You can't change an existing frame to a primary frame. here's how to use it:

 

 

doc = app.documents.add ({
  documentPreferences: {
    createPrimaryTextFrame: true,
    // And whatever else
  }
);

 

Willi Adelberger
Community Expert
Community Expert
November 21, 2022

Click on the symbol on the upper part of the left edge of the text frame once. It will change it to a primary text frame.

Mario Fritsche
Legend
November 21, 2022

Hello,
yes, but I want to create it via JavaScript.

---Mario
Willi Adelberger
Community Expert
Community Expert
November 21, 2022

Why do you want a script, when a single click will solve your problem?