Adding commands before or after the document generation process

The pre-command property can contain programming code for commands to run before the document publishing process. The post-command property can contain programming code for commands to run after the entire document generation is completed. Administrator privileges are required to add these preprocessing and postprocessing commands in Document Builder.

Before you begin

  • Deploy Document Builder
    Note: Admin privileges are required to administer Document Builder. You must have the pub_admin role assigned to yourself.

About this task

You might use the post-command property to copy the output files, archive the output files, rename the output files based on variables, mail the output files, or invoke third party applications. Refer to the documentation for your operating system to learn more about the commands you can use. Example: Microsoft Windows Command-line reference


  1. Open the Document Builder in a browser at http://server:port/rpeng
  2. Specify the user name and password with an administrator (pub_admin) permission to authenticate into the Document Builder.
    Remember: The user name and password depends on the user credentials configured and mapped to the pub_admin user roles. See the links on configuring users and authentication for the Document Builder.
  3. In the left pane of Document Builder, click Design.
  4. Optional: If you don't have any assets in Document Builder, you can generate the ready-to-use and sample assets for Document Builder. In the Design reports page, click Click here to generate the ready-to-use assets or Click here to generate Sample assets.
  5. In the Design reports page, click the Reports tab.
  6. Click the An image of the Edit Advanced Configuration icon. Edit Advanced Configuration icon next to the report that you want to add a pre-command or post-command.
    A screen capture of snippet-demo tag.
  7. In the Configure report pop-up window, click the Metadata tab.
  8. Scroll to the following fields:
    • Pre-Command
    • Stop on Pre-Command Failure
    • Post-Command
  9. Enter the values. You can use system variables, such as RPE_HOME, or external template variables in your commands. The format is always ${variable}. Template variables take precedence over system variables when they have the same name. You can also use the output formats as variables to indicate the path specified in the output properties. You must write the variable as its name is displayed in the document specification. Examples:
    • ${RPE_HOME}
    • ${Html}
    • ${Word}
    • ${PDF}
    • ${New PDF}
    • ${XslFo}
    • ${ModuleName}
    Note: You cannot use any variations to these names, like ${WORD} or ${word}. These variations cannot be recognized by IBM® Engineering Lifecycle Optimization - Publishing.
    For example, only the variable ${Word} inserts the path property value specified for the Microsoft Word output. In the log, the variable displays as the value.
  10. Optional: For the stop on pre-command failure property, enter true or false. When set to true, and the pre-command fails, then the document generation stops running. When set to false or no value is entered, and the pre-command fails, then the document generation continues running.
  11. Click Save.


Windows icon To copy the output to a second location, use the following command:

cmd /c copy ${output_format} D:\path\filename.output_extension

When writing commands in JavaScript, enter //!JavaScript to the beginning of the code to use the internal JavaScript engine to evaluate the commands:
var x = output;
var y = variable;

java.lang.System.out.println( X+Y= + x + y);

What to do next

By default, running the preprocessing and postprocessing commands are disabled. Before you can run any of these commands, the administrator must change the flag to true. For details on how to configure the runtime properties, see Configuring run time and formatting flags for Document Builder on WebSphere® Application Server

video icon Video channel
Software Education channel

learn icon Courses

IoT Academy
Skills Gateway

ask icon Community forums library

support icon Support

IBM Support Community
Deployment wiki