Skip to main content
Inspiring
October 1, 2014
Answered

how to fit "frame to content" for a selected textframe by user?

  • October 1, 2014
  • 1 reply
  • 430 views

hi

i am creating a script in which a textframe is selected and several operations are performed but on a line i got stuck since morning.

var sourceDoc = app.activeDocument;

var myFrame = sourceDoc.selection;

myFrame.fit(FitOptions.FRAME_TO_CONTENTS); // error here myFrame.fit is not a function

I tried with

app.activeDocument.selection.fit(FitOptions.FRAME_TO_CONTENTS); // error again

then i copied that textframe to new document and tried.

app.activeDocument.pageItems[0].fit(FitOptions.FRAME_TO_CONTENTS); /// it works fine

Please help.

thanks

virender

This topic has been closed for replies.
Correct answer Sajeev Sridharan

Try this,

var sourceDoc = app.activeDocument;

var myFrame = sourceDoc.selection[0];

myFrame.fit(FitOptions.FRAME_TO_CONTENT);

Vandy

1 reply

Sajeev SridharanCorrect answer
Legend
October 1, 2014

Try this,

var sourceDoc = app.activeDocument;

var myFrame = sourceDoc.selection[0];

myFrame.fit(FitOptions.FRAME_TO_CONTENT);

Vandy

Inspiring
October 1, 2014

Thanks Vandy!!