Copy link to clipboard
Copied
Hello to everyone,
first of all: I am pretty new to FM and ExtendScript. I am integrating some old .mif files into existing FM documents with ExtendScript.
I am loading the needed parameters via propVal and using the method doc.Import().
Importing these .mif files works properly, but correctly aligning them is causing difficulties because I am not able place the files whereever I want.
As far as I see, there is no obvious ability to create and place a new pgf object in some specific place in the doc.
If that would be possible, before importing a .mif file, I certainly would create a new pgf object and import the .mif file right into it.
Is there a possibility to accomplish this, or do you guys know a better way to do so?
Thanks and king regards
Hi selimc,
To put text into a document at a specific location, you need to have some familiarity with TextLoc structures. For a beginner, these can be confusing, so your questions are not unusual. Obviously, I can't give some long tutorial here, but I can give you a little sample code that inserts a new paragraph at a specific place; that is, after the second existing paragraph of the document:
...var doc = app.ActiveDoc;
var pgf = doc.MainFlowInDoc.FirstTextFrameInFlow.FirstPgf;
pgf = pgf.NextPg
Copy link to clipboard
Copied
Hi selimc,
To put text into a document at a specific location, you need to have some familiarity with TextLoc structures. For a beginner, these can be confusing, so your questions are not unusual. Obviously, I can't give some long tutorial here, but I can give you a little sample code that inserts a new paragraph at a specific place; that is, after the second existing paragraph of the document:
var doc = app.ActiveDoc;
var pgf = doc.MainFlowInDoc.FirstTextFrameInFlow.FirstPgf;
pgf = pgf.NextPgfInFlow;
pgf = doc.NewSeriesObject(Constants.FO_Pgf, pgf);
var textLoc = new TextLoc();
textLoc.obj = pgf;
textLoc.offset = 0;
doc.AddText(textLoc, "New paragraph");
If you want to get a better idea of ExtendScript overall, might I suggest that you check out some of these samples that I have available:
FrameMaker ExtendScript Samples - West Street Consulting
Good luck. I hope you get things working correctly. ExtendScript is a lot of fun once you figure it out.
Russ
Copy link to clipboard
Copied
Thank you very much for answer Russ. I appreciate it.
The code you have provided is helping me a lot - but how could I perform inserting a new pgf before the first pgf?
I tried setting NewSeriesObject(Constants.FO_Pgf, 0) naively, but it didn't work.
Thanks a lot!
edit: I solved it!
-> just used: NewSeriesObject(Constants.FO_Pgf, doc.MainFlowInDoc)