This post looks at how to update an existing paragraph format and then, having made several updates, apply those updates to all paragraphs that use that format.
As the paragraph format exists, the script uses its name to get its object:
The script then changes several properties of the format:
In ExtendScript, this translates to the SimpleImportFormats method with the following parameters:
var err = doc.SimpleImportFormats(doc, Constants.FF_UFF_PGF|
Constants.FF_UFF_REMOVE_EXCEPTION);
IMPORTANT: The FrameMaker ESTK documentation calls for ORing the constants. The FDK documentation calls for a bitwise or and, based on my observations, that appears to be correct here as well.
Use the Portrait template in your testing or any other template that has a Body paragraph format defined. Your file must be saved or the import of formats cannot succeed.
var doc = app.ActiveDoc;
var tframe = doc.MainFlowInDoc.FirstTextFrameInFlow;
var pgfFmt = doc.GetNamedObject(Constants.FO_PgfFmt, "Body");
if (pgfFmt.ObjectValid) {
pgfFmt.PgfIsAutoNum = true;
pgfFmt.AutoNumString= "<n+>. ";
pgfFmt.Capitalization = Constants.FV_CAPITAL_CASE_UPPER;
pgfFmt.ChangeBar = true;
var formatFlags = Constants.FF_UFF_PGF | Constants.FF_UFF_REMOVE_EXCEPTIONS;
doc.SimpleImportFormats (doc, formatFlags);
}
else
Err("Format not found");
As the paragraph format exists, the script uses its name to get its object:
var pgfFmt = doc.GetNamedObject(Constants.FO_PgfFmt, "Body");
The script then changes several properties of the format:
- The paragraph is set to be auto-numbered.
- An autonumbering string is defined. (This is the definition string.)
- Capitalization is set to upper case.
- Change bars are turned on.
In ExtendScript, this translates to the SimpleImportFormats method with the following parameters:
var err = doc.SimpleImportFormats(doc, Constants.FF_UFF_PGF|
Constants.FF_UFF_REMOVE_EXCEPTION);
IMPORTANT: The FrameMaker ESTK documentation calls for ORing the constants. The FDK documentation calls for a bitwise or and, based on my observations, that appears to be correct here as well.
Use the Portrait template in your testing or any other template that has a Body paragraph format defined. Your file must be saved or the import of formats cannot succeed.
var doc = app.ActiveDoc;
var tframe = doc.MainFlowInDoc.FirstTextFrameInFlow;
var pgfFmt = doc.GetNamedObject(Constants.FO_PgfFmt, "Body");
if (pgfFmt.ObjectValid) {
pgfFmt.PgfIsAutoNum = true;
pgfFmt.AutoNumString= "<n+>. ";
pgfFmt.Capitalization = Constants.FV_CAPITAL_CASE_UPPER;
pgfFmt.ChangeBar = true;
var formatFlags = Constants.FF_UFF_PGF | Constants.FF_UFF_REMOVE_EXCEPTIONS;
doc.SimpleImportFormats (doc, formatFlags);
}
else
Err("Format not found");
No comments:
Post a Comment