Copy link to clipboard
Copied
Hi,
I want to fetch all Aframes information in an active doc whose layout has three columns for each page.
I wrote the code below:
#target framemaker
var doc = app.ActiveDoc;
if (doc.ObjectValid() == true) {
var page = doc.FirstBodyPageInDoc;
while (page.ObjectValid()) {
var graFrame = page.PageFrame.FirstGraphicInFrame;
while (graFrame.ObjectValid()) {
var subcol = graFrame.FirstSubCol;
while (subcol.ObjectValid()) {
var aFrame = subcol.FirstAFrame;
while (aFrame.ObjectValid()) {
alert(page.PageNum + " " + aFrame.Width); // display Info about Aframe
aFrame = aFrame.NextAFrame;
}
subcol = subcol.NextSubCol;
}
graFrame = graFrame.NextGraphicInFrame;
}
page = page.PageNext;
}
}
This code does not work correctly.
Alert message like below;
-----------------------------
0 1000
0 2000
1 2000
-----------------------------
The second alert, "0 2000" is undesirable, because this information about Aframe on page 1.
"var subcol" ignores the page.
Could you teach me how to fix it, please?
Thanks,
Koji Koike
I would do something like this:
...#target framemaker
var doc = app.ActiveDoc;
var flow = doc.MainFlowInDoc;
var textList, i, aframe, page;
// Get a list of anchored frame text items in document order.
textList = flow.GetText (Constants.FTI_FrameAnchor);
for (i = 0; i < textList.length; i += 1) {
// Get the anchored frame object.
aframe = textList.obj;
// Get the page that contains the anchored frame.
page = getAFramePage (aframe);
}
function getAFramePage (aframe) {
var textFrame, uframe
Copy link to clipboard
Copied
Are all of the anchored frames in the document's main text flow? Or are some of them in tables? Do you have to process the anchored frames in document order or can you process them in in any order? If you can answer these questions, I can give you some help. Thanks.
Copy link to clipboard
Copied
> Are all of the anchored frames in the document's main text flow?
Yes, all of them in a document's main text flow.
>Do you have to process the anchored frames in document order
Yes, I just want to collect information about width of anchored frames, in page sequence.
The following is the solution I considered.
...................................................................
var subcol = graFrame.FirstSubCol;
while (subcol.ObjectValid()) {
var aFrame = subcol.FirstAFrame;
while (aFrame.ObjectValid()) {
alert(page.PageNum + " " + aFrame.Width); // display Info about Aframe
aFrame = aFrame.NextAFrame;
}
// Below lines are the solution not to go subcol.NextSubCol on next page.
// first column's LecX value is 1857710.
if (subcol.NextSubCol.LocX == 1857710) {
break;
} else {
subcol = subcol.NextSubCol;
}
...................................................................
But, it is not smart, I think.
If you have better way to solve, please teach me.
Thanks.
Copy link to clipboard
Copied
I would do something like this:
#target framemaker
var doc = app.ActiveDoc;
var flow = doc.MainFlowInDoc;
var textList, i, aframe, page;
// Get a list of anchored frame text items in document order.
textList = flow.GetText (Constants.FTI_FrameAnchor);
for (i = 0; i < textList.length; i += 1) {
// Get the anchored frame object.
aframe = textList.obj;
// Get the page that contains the anchored frame.
page = getAFramePage (aframe);
}
function getAFramePage (aframe) {
var textFrame, uframe, page;
textFrame = aframe.InTextFrame;
uframe = textFrame.FrameParent;
page = uframe.PageFramePage;
return page;
}
Copy link to clipboard
Copied
I see, even better way than mine.
And, this is a nice to understand how to handle the objects in FrameMaker.
Many Thanks!
Copy link to clipboard
Copied
Keep in mind that this will only get anchored frames in the main text flow, not including those that might be in tables.