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

ExtendScript to check Overflowed property of a text frame

Community Expert ,
Jul 24, 2023 Jul 24, 2023

Copy link to clipboard

Copied

Hi,

I am working on a script which should check, if a certain text frame on a master page has the Overflowed property and adapt the height and the position accordingly.

if (lTextFrame.FirstSubCol.Overflowed == 1) ...

However, I see that the script passes the "if" only, if the text frame in the file has already the Overflowed property, when it is opened. Not, if I open the file and then change text (via a variable) in this text frame, so that the text frame then assumes this Overflowed property.

Could it be that I have to open the master page  and go to the corresponding page, so that FrameMaker is able to notice this issue?

foDoc.Redisplay(); before the if had not helped.

Best regards, Winfried

Views

288

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 2 Correct answers

Community Expert , Jul 24, 2023 Jul 24, 2023

Hi Winfried,

I have had similar problems with this and other properties. Apparently, FrameMaker has to display a page in order to calculate certain properties correctly. When checking overflow, I make sure to leave app.Displaying = 1 and also set these properties:

// doc is the Doc object.
doc.IsOnScreen = 1;
doc.IsInFront = 1;
// page is the Page object of the page I am checking.
doc.CurrentPage = page;

Votes

Translate

Translate
Community Expert , Jul 24, 2023 Jul 24, 2023

This might be better because it includes the descender height of the last line.

#target framemaker

var doc, textFrame, pgf, textLoc, prop, locY;

doc = app.ActiveDoc;
textFrame = doc.FirstSelectedGraphicInDoc;

// Get the last paragraph in the text frame.
pgf = textFrame.LastPgf;
// Make a text location at the very end of the paragraph.
textLoc = new TextLoc (pgf, Constants.FV_OBJ_END_OFFSET - 1);
// Get the baseline offset from the top of the text frame.
prop = doc.GetTextPropVal (textLoc, Con
...

Votes

Translate

Translate
Community Expert ,
Jul 24, 2023 Jul 24, 2023

Copy link to clipboard

Copied

Hi Winfried,

I have had similar problems with this and other properties. Apparently, FrameMaker has to display a page in order to calculate certain properties correctly. When checking overflow, I make sure to leave app.Displaying = 1 and also set these properties:

// doc is the Doc object.
doc.IsOnScreen = 1;
doc.IsInFront = 1;
// page is the Page object of the page I am checking.
doc.CurrentPage = 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 ,
Jul 24, 2023 Jul 24, 2023

Copy link to clipboard

Copied

Hi Rick,

Thank you very much for this info! Then I will change the script accordingly.

Best regards, Winfried

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 ,
Jul 24, 2023 Jul 24, 2023

Copy link to clipboard

Copied

I added all your commands, but this did not suffice.

I also had to show an Alert message.

Then FrameMaker was able to detect the Overflowed property.

I did not check, if the Alert message alone would have worked.

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 ,
Jul 24, 2023 Jul 24, 2023

Copy link to clipboard

Copied

You might find this approach more reliable.

#target framemaker

var doc, textFrame, pgf, textLoc, prop, locY;

doc = app.ActiveDoc;
textFrame = doc.FirstSelectedGraphicInDoc;

// Get the last paragraph in the text frame.
pgf = textFrame.LastPgf;
// Make a text location at the very end of the paragraph.
textLoc = new TextLoc (pgf, Constants.FV_OBJ_END_OFFSET - 1);
// Get the baseline offset from the top of the text frame.
prop = doc.GetTextPropVal (textLoc, Constants.FP_LocY);
locY = prop.propVal.ival;
// See if the baseline offset is greater than the text frame height.
if (locY > textFrame.Height) {
    alert ("Overflowed!");
}
else {
    alert ("No overflow!");
}

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 ,
Jul 24, 2023 Jul 24, 2023

Copy link to clipboard

Copied

This might be better because it includes the descender height of the last line.

#target framemaker

var doc, textFrame, pgf, textLoc, prop, locY;

doc = app.ActiveDoc;
textFrame = doc.FirstSelectedGraphicInDoc;

// Get the last paragraph in the text frame.
pgf = textFrame.LastPgf;
// Make a text location at the very end of the paragraph.
textLoc = new TextLoc (pgf, Constants.FV_OBJ_END_OFFSET - 1);
// Get the baseline offset from the top of the text frame.
prop = doc.GetTextPropVal (textLoc, Constants.FP_LocY);
locY = prop.propVal.ival;
// Add the descender height to the baseline.
prop = doc.GetTextPropVal (textLoc, Constants.FP_LineDescent);
locY += prop.propVal.ival;
// See if the text offset is greater than the text frame height.
if (locY > textFrame.Height) {
    alert ("Fixing overflow!");
    textFrame.Height = locY;
}
else {
    alert ("No overflow!");
}

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 ,
Jul 24, 2023 Jul 24, 2023

Copy link to clipboard

Copied

LATEST

Wow, perfect! Thank you very much!

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