Create your own AutoFM Script

AutoFM scripts are simple XML files that can be created in FrameMaker or by other tools and processes.

AutoFM scripts must have a suffix of “autofm.xml”. You can provide additional text as a prefix. For example, mybook-autofm.xml.

  1. Choose DITA-FMx > FMx-Addons > FMx-Auto > New AutoFM Script.

    You will be prompted for a file name, then a new AutoFM XML file is created.

  2. Add and modify elements and attributes to create the process needed.

    Refer to the AutoFM documentation for details on the data model and element structure for an AutoFM script. The Element Catalog shows the valid elements. Check the attributes for each element to see if there are any properties that should be set for elements you’ve added. Be sure to add the exit element to close FrameMaker after processing is complete.

  3. Always test a new script manually by choosing the Run AutoFM Script command.

    Once you’ve confirmed that everything is working as expected, proceed to automated testing.

  4. Set up a batch file or other command line scripting tool to run your AutoFM script.

    Any scripting language that can run an executable should be able to drive your AutoFM script. You just specify the FrameMaker executable and pass the AutoFM script to it as a command line parameter. It is typically best to specify the full path to both the FrameMaker executable and the AutoFM script, but this can change depending on your environment. Be sure to wrap paths in quotes if they contain spaces.

    You may want to include additional scripting code to ensure files are set up in an expected manner. In particular, it may be useful to test for and delete any “recover” files that may have been generated in a previous build. If a recover file exists, it will interrupt the automatic opening of the associated file.

When generating a PDF you have the option to use the “SaveAs” command (via the saveas AutoFM element) or you can print to a PDF using the AutoFM print element. The print element uses a number of attributes (mirroring the options in the FrameMaker Print dialog) to allow complete control over the features in the output. Be sure to specify the “Adobe PDF” printer name (or whatever this is named on your system) in the @printername attribute in order for the PDF to be created. Also, the @acrobatdata attribute can be set to enable the Generate Acrobat Data option so bookmarks are created.

Keep in mind that you can perform various types of pre and post processing in the batch file that runs the AutoFM script in FrameMaker. To ensure a successful build, you might consider testing for and deleting any errant lock (*.lck) or recover (*.recover.fm) files that may be lying around.