In this chapter…

…you will learn how to run pdfHarmony on the command line.

Using Command-line Options

Command-line options are used in all Appligent Document Solutions server applications. The tables below shows command-line options for pdfHarmony. The following is an example of command syntax for pdfHarmony:

pdfharmony [options] inPDFFile1 [inPDFFile2]

Document Save and Optimize Options

Option Description Example
-verifyonly Verify only; search for corrupt files without creating new files. pdfharmony -p -verifyonly
input.pdf
-verifypage Verify page drawing. pdfharmony -verifypage
-verifyonly input.pdf
-rewritepage Rewrite page contents to cleanup at the page content level.  This option rebuilds the entire contents of the page eliminating many types of malformed content. pdfharmony -rewritepage
-o output.pdf input.pdf
-removerotation Remove rotation from all pages pdfharmony -removerotation
-o output.pdf input.pdf
-retaincreator Retain original document creator pdfharmony -retaincreator
-o output.pdf input.pdf
-optimize Combine -flate-rascii-nolzw-optxobj-optcontent and -optfonts. pdfharmony -optimize
-o output.pdf input.pdf
-nocomp Do not compress using Object Streams; compatible with all versions of Acrobat.* pdfharmony -p -nocomp
-verifyonly
-comp Compress using Object Streams; compatible with Acrobat 6 and later.* pdfharmony -p -comp
-o output.pdf input.pdf
-cstruct Compress logical structure.*
*: -nocomp, -comp and -cstruct are mutually exclusive; these options can all be off, but only one can be used at a time.
pdfharmony -cstruct
-o output.pdf input.pdf
-iso32000 Set file for ISO 32000 compliance (PDF 1.7).
pdfharmony -iso32000
-o output.pdf input.pdf
-flate Encode non-encoded streams using Flate compression.
pdfharmony -flate
-o output.pdf input.pdf
-rascii Remove ASCII85 filters from all streams.
pdfharmony -rascii
-o output.pdf input.pdf
-nolzw Replace LZW encoded streams with Flate encodings. pdfharmony -nolzw
-o output.pdf input.pdf
-optxobj Merge identical XObjects and Images. pdfharmony -optxobj
-o output.pdf input.pdf
-optcontent Optimize common sequences in page content. pdfharmony -optcontent
-o output.pdf input.pdf
-optfonts Merge identical font descriptors and encodings. pdfharmony -optfonts
-o output.pdf input.pdf
-xreadonly Suppresses the generation of padding in the XMP metadata. pdfharmony -xreadonly
-o output.pdf input.pdf
-xpadding <int> XMP metadata padding bytes. Default is 2048. pdfharmony -xpadding 3045
-o output.pdf input.pdf
-w Save the output as a linearized file. pdfharmony -w
-o output.pdf input.pdf
-wauto Auto-detect linearized and save linearized; otherwise, save as normal. pdfharmony -wauto
-o output.pdf input.pdf
-wforms Extends “w” and “wauto” to linearize Acrobat forms. Default is to not linearize forms. Requires -w or -wauto. pdfharmony -wforms
-o output.pdf input.pdf
-nomod Retain current file modification date. pdfharmony -w -nomod
-o output.pdf input.pdf
-nosign Ignore digital signatures. Default is to incrementally save files with digital signatures. pdfharmony -optimize -nosign
-o output.pdf input.pdf

Document Metadata Options

Option Description Example
-title <string> Document title. pdfharmony -title
“This is the title”
-o output.pdf input.pdf
-author <string> Author of the document. pdfharmony -author
“John Doe”
-o output.pdf input.pdf
-subject <string> Subject of the document. pdfharmony -subject Test
-o output.pdf input.pdf
-keyword <string> Keywords associated with the document, separated by commas. pdfharmony -keyword
Value1,Value2
-o output.pdf input.pdf
-addinfo Add the new information to any existing in the file. pdfharmony -addinfo
-author “Jane Smith”
-o output.pdf input.pdf
-custom <string> Custom document information. For example, in -custom “name,value”, name and value are separated by a comma. This option may be repeated. pdfharmony -custom
“Field1,Value1”
-custom “Field2,Value2”
-o output.pdf input.pdf

Document Open and Layout Options

Option Description Example
-pageMode <string> Set the document’s page mode (DontCare | UseNone | UseThumbs | UseBookmarks | Fullscreen | UseOC | UseAttachments). pdfharmony -pageMode
UseBookmarks
-o output.pdf input.pdf
-layout <string> Set the document’s layout (single | oneColumn | twoColLeft | twoColRight | twoPageLeft | twoPageRight). pdfharmony -layout single
-o output.pdf input.pdf
-openAction <string> Set the document’s Open Action (FitPage | FitWidth | FitHeight | FitBoundingBox). pdfharmony -openAction
FitHeight
-o output.pdf input.pdf
-openToPage <int> Open the document to the given page number. pdfharmony -openToPage 3
-o output.pdf input.pdf
-hideToolbar Hide the toolbar upon opening the document. pdfharmony -hideToolbar
-o output.pdf input.pdf
-hideMenubar Hide the menubar upon opening the document. pdfharmony -hideMenubar
-o output.pdf input.pdf
-hideWinUI Hide scrollbars and other controls upon opening the document. pdfharmony -hideWinUI
-o output.pdf input.pdf
-fitWin Resize the window to the initial page. pdfharmony -fitWin
-o output.pdf input.pdf
-centerWin Center the window on the screen. pdfharmony -centerWin
-o output.pdf input.pdf
-showTitle Display the document title in the Windows title bar. pdfharmony -showTitle
-o output.pdf input.pdf
-LeftToRight Left-to-right reading order used to determine relative position of pages for side-by-side display. pdfharmony -LeftToRight
-o output.pdf input.pdf
-RightToLeft Right-to-left reading order; includes vertical writing systems like Chinese, Japanese and Korean. pdfharmony -RightToLeft
-o output.pdf input.pdf

Bookmarks, Annotations and Form Fields Options

Option Description Example
-openBookmarks Open all bookmarks. pdfharmony -openBookmarks
-o output.pdf input.pdf
-closeBookmarks Close all bookmarks. pdfharmony -closeBookmarks
-o output.pdf input.pdf
-openLevel <int> Open all bookmarks up to and including the specified level. pdfharmony -openLevel 2
-o output.pdf input.pdf
-removeBookmarks Remove all bookmarks. pdfharmony -removeBookmarks
-o output.pdf input.pdf
-removeAnnots Remove all annotations including notes, highlights, form fields, etc. pdfharmony -removeAnnots
-o output.pdf input.pdf
-removeFields Remove all form fields. pdfharmony -removeFields
-o output.pdf input.pdf

Watched Folders Options

Option Description Example
-watch <string> Path to watched folder base directory. pdfharmony -optimize
-watch OutDir
-watchin <string> Path to input watched folder. Optional. pdfharmony -w
-watch OutDir
-watchin OutDir\NewDir
-watchout <string> Path to output of watched folder. Optional.
**The command line to the right will create a sub-folder beneath OutDir
called NewOutDir. This is the directory where the output files will be
placed once processed.
pdfharmony -w
-watch OutDir
-watchout OutDir\NewOutDir

General Options

Option Description Example
-l <string> Write progress information to log file. pdfharmony -l logfile.txt -optimize
-o output.pdf input.pdf
-p Write progress information to the log file and/or stdout. pdfharmony -p -title
“this is a test”
-author “Jane Smith”
-o output.pdf input.pdf
-r <string> Pass  registration number to pdfHarmony. pdfharmony -r
XXXX-XXXX-XXXX-XXXX-XXXX-XXXX
-p -optimize
-o output.pdf input.pdf
-v Display version information. pdfharmony -v
-h or -help Display usage information. pdfharmony -h
or
pdfharmony -help
-html <string> Output results to an HTML file. See an example report. pdfharmony -html
Report.html
-verifyonly input.pdf
-htmlurl <string> Specify path to server hosting HTML support files.
-o <string> Output directory name or PDF filename. pdfharmony -openToPage 5
-o output.pdf input.pdf
-d <string> Owner password to open the document. pdfharmony -d Ownerpass
-subject “Test File”
-o output.pdf input.pdf

Notes on options

If -hideWinUI is on the command line, then pageMode is ignored.

If you are running pdfHarmony on a file that contains form fields and you want the output to be linearized, you must have both -wforms and -w on the command line. Running with -w alone does not linearize output files that contain active form fields.

The -html reporting option cannot be used with watched folders.

A note on using -p and -l <logfile> together

As outlined in the above sections the -p option gives you progress messages on your screen and the -l <logfile> option writes error messages to a file if errors occur. The table below provides more detail on using these options alone or together.

l p  errors Result
Nothing will be written to the screen or to the log file you specify
Progress message will be written to the screen and pdfHarmony.log
Progress messages will be written to the screen and to the log file you specify
A pdfHarmony.log file will be created with the errors in your working directory
Errors will be written to the log file you specify
Errors will be written to pdfHarmony.log and your screen
Both progress and error messages will be written to the screen and to the log file you specify

Therefore, -l <logfile> used on its own will only go into action if there are errors. With -p and -l <logfile> combined, you will get a text file with full details on pdfHarmony operations whether there are errors or not.

Sample pdfHarmony Commands

To optimize a PDF file:

pdfharmony -p -optimize -o output.pdf input.pdf

To optimize multiple files:

pdfharmony -p -optimize -o OutputDir input.pdf input2.pdf

To set document properties:

pdfharmony -p -subject pdfHarmony -author "Jane Smith" -title "Testing pdfHarmony" -o output2.pdf input.pdf