Home » fmpython on comp.text.frame: insert text into Framemaker document

fmpython on comp.text.frame: insert text into Framemaker document

Saw a post on comp.text.frame that had a couple of sizeable fmpython example scripts for iterating through and adding to the content of a Framemaker doc…

For future reference, a follow-up to an old post by “Kyle M On Jul 20
2004″ (see below for the complete post. For some reason I wasn’t able
to reply to the old thread, so I just post it as a new one)

A FrameMaker document contains more than only the paragraphs on the
Body page: there are paragraphs as well in the Master Page(s) and
Reference Page(s). Moreover, notwithstanding that the “doc.firstPgf”
is the first paragraph in FrameMaker’s *list* of paragraphs, this list
does not order the paragraphs as you/I would expect, i.e. the first
paragraph on the Body page doesn’t seem to always come first in the
list.

The following script does what you want, i.e. insert something in the
first Body page paragraph of your document:

import maker
doc = maker.session.activeDoc
par=doc.mainFlow.firstFrame.firstPgf
newTxLocation =maker.TxLocation(par, 0)
newTxLocation.addText(”hello at the beginning”)
newTxLocation =maker.TxLocation(par, maker.symbol.EndOffset-1)
newTxLocation.addText(”hello at the end”)

Post a Comment

You must be logged in to post a comment.