Chapter 10. upCast Commandline Interface

1. Reference
2. Example
3. Commandfile syntax

Important

Using the Commandline Interface to upCast requires a license that includes the API feature.

The upCast commandline interface essentially is the upCast API wrapped by a commandline interpreting class and delivered as part of the upcast.jar. This is also the reason why a license including the API feature is required to use the commandline interface.

1. Reference

To access upCast via the commandline interface, start upCast as follows:

java -cp upcast.jar de.infinityloop.upcast.UpcastCmdline options...

Available options are:

-debug true | false

Turns writing debug info into the log file on or off.

-license licensefile

Specifies license file to use (absolute, local file system path). This license must include the API feature.

-addencoding encodingfile

Adds the specified custom encoding file to the set of known encodings (absolute, local file system path).

-setfontconfiguration stdfontsconfig

Specifies a custom font configuration to be used (absolute, local file system path).

-addcatalog catalog

Adds the specified catalog file (absolute, local file system path) to the set of known catalogs.

-param param-name param-value

Sets a parameter value to be passed/defined in a commandfile.

-commandfile name

The name of a commandfile, which contains commands as listed here one per line. This is more convenient to write (since you can distribute options over several lines) and a necessity if on your system, the length of the commandline is limited to a certain number of characters.

The commandfile format is described here.

-upcastengine name

Specifies the user identification for this running instance of upCast (visible in log files).

-setglobalparameter param-name param-value

Specifies a global upCast parameter.

-setimportfiltertype rtf

Specifies the import filter to use. Only rtf is supported.

-setimportfilterparameter param-name param-value

Sets a parameter for the earlier specified import filter.

-importfile filename

Specifies the input file, i.e. the document to be processed. This must be an absolute path to a local file.

-setexportfiltertype XML | XHTML | CSS | Commandline | XMLValidator | XSLTProcessor | DocBook42 | XMLRaw | RawTreeDumper | UnicodeTranslator | number

Specifies the export filter to be used.

-setexportfilterparameter param-name param-value

Sets a parameter for the earlier specified export filter.

-exportfile filename

Exports the conversion result to the specified file. This must be an absolute path to a local file location.

Important

The sequence of options is significant! Consider each of them directly resulting in the internal corresponding action as when you were to perform it programmatically via the API. This enables you to perform multiple export operations on the same source file by repeatedly specifying -setexportfiltertype / -setexportfilterparameter ... / -exportfile option sequences.

2. Example

java -cp upcast.jar de.infinityloop.upcast.UpcastCmdline \
-debug true \
-license "C:\Documents and Settings\il\upcast.license" \
-upcastengine "CmdLine" \
-setglobalparameter outputDir "C:\Documents and Settings\il\output" \
-setimportfiltertype rtf \
-setimportfilterparameter IncludeImages false \
-importfile "C:\Documents and Settings\il\test.rtf" \
-setexportfiltertype XML \
-setexportfilterparameter Extension ".xml" \
-exportfile "C:\Documents and Settings\il\output\test.xml"

This calls the commandline interface and converts the document C:\Documents and Settings\il\test.rtf to C:\Documents and Settings\il\output\test.xml, using the XML (upCast DTD) export filter and excluding all images.

3. Commandfile syntax

A commandfile is a plain text file consisting of one complete option (incl. parameters) per line. Commands can be indented for better legibility. Lines starting with a semicolon are considered comments. Parameter values defined on the commandline via the -param option can be referenced using the upCast default variable referencing syntax ${paramname}.

An example says more than 100 words - a look at the following sample commandfile will make everything clear:

Example 10.1. CLI Commandfile example

This converts a single document to XML. The name and some other info is passed by way of the -param option to the commandfile as variables.

The call would look like this (in one line):

java -cp upcast.jar de.infinityloop.upcast.UpcastCmdline -param destpath "/cli/out/" -param infile "/cli/in/test.rtf" -commandfile "/cli/commands.txt"

commands.txt would then have contents similar to the following:

; For debugging output, set the following to true
-debug false
; Set license
-license "/cli/upcast.license"
; Create upCast Engine
-upcastengine MyEngine;
-setglobalparameter outputDir ${destpath}
-setglobalparameter imageDir ${destpath}
; Import
-setimportfiltertype rtf
  -setimportfilterparameter HoistCommonInlines "false"
  -setimportfilterparameter ImageRenderingResolution "96"
  -setimportfilterparameter IncludeImages "true"
  -setimportfilterparameter InlineProcessorClass "*"
  -setimportfilterparameter SectionProcessorClass "*"
-importfile ${infile}
; Export to XML
-setexportfiltertype XML
  -setexportfilterparameter CombineWithLogicalStyle "false"
  -setexportfilterparameter DeleteEmpties "false"
  -setexportfilterparameter Extension ".xml"
  -setexportfilterparameter OutputEncoding "UTF-8"
  -setexportfilterparameter TableModel "HTML"
-exportfile ${destpath}result.xml