Publish a Formal Document Using a Batch File

Running Document Publisher in the Background

Publishing a Draft or Formal Document can take time. If you need to use Microsoft® Word for other work, is a nuisance when having to wait.

Users can run a batch file to create the documents either as a Draft and/or as a Formal document. The batch file can be used in a task while the user is not using their computer; for example at night or a weekend if many documents are being generated.

The command line needs to have all the options set the same as they would  be through the UI (User Interface):

Publish Formal Document User Interface
Publish Formal Document User Interface

Formal Document Command line Options

The normal batch file command line options for just a draft document are:

Draft Options for batch file
Command Line Draft Options

Each of the following shows what the command line options for each Formal option in the User Interface:

Formal Options for batch file
Formal Options needed in a batch file

All the above -fdoc options are requirements within the command line except -newversion. Only use the -newversion option, if a new version of the document is required.

The final command line to generate the DEMO Template will look like this: (NOTE: Options with more than a single word are required to be in quotes e.g. -fdoccomment “Published DEMO Template Using Batch File”)

"%CRADLEHOME%\bin\exe\windows\DocPub.exe" -login MANAGER,MANAGER,demo -file "DEMO Template" -location PROJECT -type DOCX -output "C:\Temp\DEMO Template.doc" -formal -fdocname "DEMO Template" -fdoctype REQUIREMENTS -fdoctitle "DEMO Template" -fdocissue 1 -fdocdate Jun -fdocref DEMO1 -fdocclass UNCLASSIFIED -fdoccomment "Published DEMO Template Using Batch File" –log

Any template that generates through Document Publisher can generate through a batch file.

As you can see in the command window below, 3 templates are being generated, a doc, a docx and a docm.

Command line window
Command Window showing 3 types of document being generated

Once the documents are generated, they can be seen in WorkBench in the Project sidebar under the Formal Document sections:

Project sidebar Formal Documents sections
Project sidebar – Formal Documents sections showing the 3 generated documents

Using parameters within a batch file

The great thing about using a command line batch file is that parameters can be set, as long as the template has parameters setup. This means you can run the same document many times but use different parameters for each run with a different document output name. For example if you used ?reqID within the Key or Identity you could output different Requirement Documents.