The Command line

Command-line parameter were widely used in the DOS days, when programs were called by typing their file name, which may be followed by additional parameters. In the present time parameters are commonly used in .bat files and by computer programmers, but many Window users also use them.

Bersoft HTML Print is designed to work with and be called by other software or at least, by a batch file, passing the filename (HTML page, GIF, JPEG, BMP, PNG, WMF or EMF image) or directory to be printed as a parameter in the command line. Alternatively, HTML code to be printed can be passed in the command line, without requesting any file. Images or text file should be located locally, but HTML files can be online.


htmlprint.exe myfile.html


htmlprint.exe myimage.pgn  


htmlprint.exe ""


htmlprint.exe "c:\document folders\folder1"


HTMLPrint runs as a visible application only when it is started without passing any argument in the command-line.
When running in Directory Printing or List Printing Mode it runs in the Task Bar, when printing a file passed in the command line it runs invisibly.


Although HTMLPrint looks for a configuration file named HTMLPRINT.INI, situated in its same directory, it is possible to use other configuration file, passing the filename as the second command-line argument.


htmlprint.exe myfile.html conf1.ini


Passing alternative configuration files in the command line is useful to configure HTMLPrint in different ways.


If any filename passed in the command line have spaces, it always should be enclosed in double quotes.


htmlprint.exe "images of the beach.html" "c:\configuration files\conf2.ini"


If relative paths are used, they should be relative to the location of HTMLPrint.

The file or directory to be printed (if any) and the configuration file (if any) should always be the first and second parameter. If no file is printed (using the /HTML switch or Directory Printing mode), the configuration file can be the first parameter.


Command Line Switches

The following switches are optional. They should be added at the end of the command line, after the filename to be printed and (optional second parameter) the configuration filename. All the settings available as command line switches (and much more) can be also set in the configuration file, but the command line switches will always take precedence over the configuration file settings.


Sets the page range to be printed. Examples: /R=5-9 /R=3


Sets the printer to be used.


Sets the footer. More information about Headers/Footers.


Sets the header. More information about Headers/Footers.


HTMLPrint will count and return the number of pages in the HTML document, instead printing it.


If  the /Pre switch is specified, HTMLPrint  will show the preview window before printing any file.


Sets directly the HTML code to be printed, without using any file.

Enclose the code in double quotes. If needed, use only single quotes inside the code.

If the character % is used, put it always duplicated (example width=50%%).


If /HTML is used, /Base defines a path for the purposes of resolving relative image URLs.


/List should point to an ASCII file with a list of HTML documents to be batch printed. See Batch Printing Editor and Directory Monitoring & Batch Printing.


/Dir sets the directory to be used a Printing Directory. It will be the only Printing Directory, cancelling any other HTML Printing Directories set in the Directory/List Tab.


Sets the printing scale, from 10 to 500%. Example: /Scale=50  (will print a 50% size copy).


Sets the number of copies to be printed.


Collate arranges the printed pages in their proper sequence when printing several sets of copies. /CO=1 (turn collate on) /CO=0 (turn collate off)


Sets the page orientation (P or L: Portrait or Landscape). Example: /O=L


Sets duplex option:  Default = 0 (use printer settings). Simplex = 1. LongEdge = 2. ShortEdge = 3.


Sets the Paper Tray.


Sets the Paper Size.


These parameters set  the printing margins in mm (Top, Bottom, Left and Right). Notice that the bottom margin cannot be set in the TRIAL version.






htmlprint.exe doc1.htm /P="HP LaserJet 4000" /H="<!--C#-->"  /F="<!--D#-->"


htmlprint.exe dummy.htm /HTML="<table width=50%% height=99%%><tr><td valign=center align=center>TEXT TO BE PRINTED</td></tr></table>" /H="<!--C#-->"  /F="<!--D#-->"


The first parameter should point always  to an HTML or configuration file. A command line switch cannot be used as first parameter.
Therefore at least always include a dummy HTML file as first parameter, no matter if it doesn't exists.