Copy link to clipboard
Copied
Hi,
I was trying to run a script to extract all Paragraphs in a fm file with a specific tag name and I could see that I did not extract texts for many paragraphs.
However when I saved the fm file as a mif file, and on running my script hereafter I was able to extract all paragraphs including paragraphs that were hidden.
Please let me know why is there such a difference between running on a FM file and a MIF File.
Secondly, If i were to update the MIF files with new paragraphs (and text ), could I save it as an FM file and use it interchangably.
Thanks,
Sebin
(Attaching my Script)
var doc = app.ActiveDoc;
var pgf= doc.FirstPgfInDoc;
var count = 0 ;
while (pgf.ObjectValid()){
if (pgf.Name == 'Specific_Par_Name')
{
count += 1;
var test = pgf.GetText(Constants.FTI_String );
var text, str;
text = "";
//$.writeln(test);
for (var i=0; i < test.len ; i +=1)
{
var str=test .sdata.replace(/^\s+|\s+$/g, '') ;
//var str=test .sdata;
text = text + str;
//PrintTextItem (test);
}
// file.writeln(text);
}
// $.writeln(paraname);
pgf=pgf.NextPgfInDoc;
}
$.writeln(count);
//file.close();
There should be no difference between an FM binary file and a MIF file after they are opened and sitting in memory. When you open a MIF file with FrameMaker, the MIF parser should convert it into a binary representation, which is what your script would operate on.
One possibility for the differences: Does your file have conditional text that may have been hidden before you saved as MIF? It could be that when you opened the MIF file, the MIF parser made all of the conditional text shown.
Copy link to clipboard
Copied
In the FM doc, you should be running the script against the first paragraph in the flow (typically Flow "A", but FM docs can have many flows). The first paragraph in the document may not be the first thing that you see in on a Body page. The Body page shows the flow content.
Copy link to clipboard
Copied
Arnis, is there really a difference processing FM binaries and MIF files, when they are opened in FM. I wasn't aware about that, yet, but I also can't really imagine with my way of thinking how FM works in Background.
@sebinkur: Yes you can add paragraphs and save MIF back to binary format.
Strange
Copy link to clipboard
Copied
Depending upon how the FM file was created, saving as MIF organizes and cleans up the internal database, so I think it's possible that some items in the document order may be re-arranged vs. accessing those in the flow order. However, my scripting experience is much more ad hoc and most of my stuff is generated as MIF first via Miramo, so I'll defer to your and Rick's expertise on this.
Copy link to clipboard
Copied
Thank you. I was able to do that.
Copy link to clipboard
Copied
There should be no difference between an FM binary file and a MIF file after they are opened and sitting in memory. When you open a MIF file with FrameMaker, the MIF parser should convert it into a binary representation, which is what your script would operate on.
One possibility for the differences: Does your file have conditional text that may have been hidden before you saved as MIF? It could be that when you opened the MIF file, the MIF parser made all of the conditional text shown.
Copy link to clipboard
Copied
Hi Rick,
My script does have conditional text, so I do have a check in my script to extract text if the "ConFmtisShown". This does extract everything when I'm running on the mif file.
As Arnis suggested, there may be many flows in the document, probably due to which I am only able to extract a subset of all the text that I could otherwise extract from a mif file. Could you let me know how I could modify my script to accommodate all the flows or an other way I could tackle this problem?
Thanks,
Sebin