Skip to main content
Inspiring
May 12, 2014
Answered

Script for collect the 'Master page-Text frame-Content' details

  • May 12, 2014
  • 1 reply
  • 2594 views

Hi,

How to collect 'Masterpage--TextFrame--content' details from Indesign file.

If the Master page spread has text frame, I need to collect that text frame content in the separate file. If this possible by Indesign script?

thanks,

hasvi

This topic has been closed for replies.
Correct answer Chinnadk

Hi Chinna,

Everything is fine, but I need the 'text frame content' from inside of Page size, but its collect the text frame content overall masterspread (that means out side of page). can you please correct it?

by

hasvi


Hi Hasvi,

Hope this helps you!

var doc = app.activeDocument;

var master = doc.masterSpreads;

var contents = "";

for(var i =0;i<master.length;i++)

{

        for(var j =0;j<master.textFrames.length;j++)

        {

                if(master.textFrames.parentPage != null){

                    contents += master.textFrames.contents + "\t" + master.name + "\r";

                }

            }

    }

var file = new File("c:/1.txt");

file.open("w");

file.write(contents);

file.close();

Regards,

Chinna

1 reply

Chinnadk
Legend
May 12, 2014

Hi Hasvi,

Try this,

var doc = app.activeDocument;

var master = doc.masterSpreads;

var contents = "";

for(var i =0;i<master.length;i++)

{

        for(var j =0;j<master.textFrames.length;j++)

        {

                contents += master.textFrames.contents + "\r";

            }

    }

var file = new File("c:/1.txt");

file.open("w");

file.write(contents);

file.close();

Regards,

Chinna

hasviAuthor
Inspiring
May 12, 2014

Hi Chinna,

Very Nice, But Master page name is missing in txt file, its default to search which master page has which content.

How can we update this?

thanks

hasvi

Chinnadk
Legend
May 12, 2014

Hi Hasvi,

Here is the modified code.

var doc = app.activeDocument;

var master = doc.masterSpreads;

var contents = "";

for(var i =0;i<master.length;i++)

{

        for(var j =0;j<master.textFrames.length;j++)

        {

                contents += master.textFrames.contents + "\t" + master.name + "\r";

            }

    }

var file = new File("c:/1.txt");

file.open("w");

file.write(contents);

file.close();

Regards,

Chinna