• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Master page text frame change to primary text frame

Contributor ,
Feb 17, 2017 Feb 17, 2017

Copy link to clipboard

Copied

Hi All,

I have trying to add and change the master page's textFrame to primaryTextFrame as below, but can't change to Primary Text Frame. Kindly guide to me.

Kindly suggest if any alternate method.

var myDoc = app.documents.item(0);

myDoc.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.points;

myDoc.viewPreferences.verticalMeasurementUnits = MeasurementUnits.points;

myDoc.viewPreferences.rulerOrigin = RulerOrigin.pageOrigin;

myDoc.zeroPoint = [0, 0];

var m = myDoc.pages[0].marginPreferences;

var marT = m.top-1;

var marL = m.left-1;

var marB = (myDoc.documentPreferences.pageHeight - m.bottom)-1;

var marR = (myDoc.documentPreferences.pageWidth - m.right)-1;

var gbounds = [m.top, m.left, myDoc.documentPreferences.pageHeight - m.bottom, myDoc.documentPreferences.pageWidth - m.right];

var myDoc = app.activeDocument;

var myMaster = myDoc.masterSpreads;

for(m = 0; m<myMaster.length; m++){

    if(myMaster.name == "TX-Text"){

        myMaster.pages[0].textFrames.add({geometricBounds:gbounds})

        myMaster.pages[1].textFrames.add({geometricBounds:gbounds})

        var myT = myMaster.pageItems;

        for(g=0; g<myT.length; g++){

            var T0 = Math.round(myT.geometricBounds[0]);

            var T1 = Math.round(myT.geometricBounds[1]);

            var T2 = Math.round(myT.geometricBounds[2]);

            var T3 = Math.round(myT.geometricBounds[3]);

            if((T0>marT)&&(T1>marL)&&(T2>marB)&&(T3>marR)){

                if(myT.textFrames){myT = myMaster.primaryTextFrame;}// lacked from here

//~                 myT.textFrames.primaryTextFrame = true;

//~             alert(T0+" - "+T1+" - "+T2+" - "+T3+"\r"+marT+" - "+marL+" - "+marB+" - "+marR);}

//~             if(myT == myMaster.primaryTextFrame){alert("Y")}

}

            }

        }

    }

Thanks,

Selva

TOPICS
Scripting

Views

1.8K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Feb 17, 2017 Feb 17, 2017

Hi Selva,

FWIW:

A solution not for InDesign Server

1. Select a text frame on the master spread.

2. Run a menuAction to transform a text frame to a primary text frame.

Lookup the menuAction's name from the context menu after you selected a text frame on a master spread.

Warning! I tried exactly that, but it crashed my InDesign severely.

… ( some minutes later : ) …

Ah. I think I can tell why my InDesign was crashing:

In the moment I was invoking the menu action the master spread was not the active spread.

...

Votes

Translate

Translate
Community Expert ,
Feb 17, 2017 Feb 17, 2017

Copy link to clipboard

Copied

Hi Selva,

FWIW:

A solution not for InDesign Server

1. Select a text frame on the master spread.

2. Run a menuAction to transform a text frame to a primary text frame.

Lookup the menuAction's name from the context menu after you selected a text frame on a master spread.

Warning! I tried exactly that, but it crashed my InDesign severely.

… ( some minutes later : ) …

Ah. I think I can tell why my InDesign was crashing:

In the moment I was invoking the menu action the master spread was not the active spread.

So make sure that the master spread is the active spread!

Other suggestion that is working:

Add a new document where you define a primary text frame.

Duplicate the master spread to your document where you need the primary text frame.

Use the duplicated master spread instead of the one you already have.

( Tested with InDesign CS6 8.1.0 on OSX 10.10.5. )

Regards,
Uwe

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Feb 18, 2017 Feb 18, 2017

Copy link to clipboard

Copied

Hi Uwe,

Thanks for the suggestion, i did with menuAction method (invoke).

myT.select();

app.menuActions.item("Primary Text Frame").invoke();

Thank you so much this,

Selva.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 18, 2017 Feb 18, 2017

Copy link to clipboard

Copied

Hi Selva,

I hope that you are spared from crashes.

Just another comment on the problem:

DOM documentation is suggesting—at least I do interpret it this way—that one should be able to assign a pageItem ( text frame or text path ) as value to property masterSpread.primaryTextFrame . However, this is not working. It is always throwing an error. The documentation is showing that this property is r/w . Maybe other factors must be in order that this would work, but they are not mentioned.

I also tried to set the preferences of the document in advance, but this seems to be not sufficient:

doc.documentPreferences.createPrimaryTextFrame = true;

For all scripters working with or for locale versions of InDesign, the string for the menu action that should work on all desktop versions of InDesign—e.g. my German version—is:

"$ID/kPrimaryTextFrameMenuItem"

Best,
Uwe

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 27, 2020 Feb 27, 2020

Copy link to clipboard

Copied

How do I check this property (Primary Text Frame) already enabled in the master page.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 27, 2020 Feb 27, 2020

Copy link to clipboard

Copied

Hi,

check the value of property primaryTextFrame of masterSpread.

You get null if there is no primary text frame. You get a text frame if there is a primary text frame.

Then you could ask for parentPage of the returned text frame.

If you get null the primary text frame is on the pasteboard. If not a page object is returned.

 

Regards,
Uwe Laubender

( ACP )

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 27, 2020 Feb 27, 2020

Copy link to clipboard

Copied

LATEST

Thanks for this. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines