click to download Download DOSPrinter (170KB zip file)




What is DOSPrinter:
DOSPrinter is an universal printer driver for DOS applications running under Windows. DOSPrinter is an Epson matrix printer emulator. It allows your DOS (or UNIX) applications to print to any printer, including the GUI (windows only) printers, USB printers, fax-modems and even to email or MS Word. You can preview your reports in the best previewer out there - Adobe Reader.
DOSPrinter is a win32 program. It is windowless to keep it simple and discreet. It is small in size, robust and runs very fast.



Usage
Examples
Supported ESC commands
How to print graphics
How to select a font
How to print barcodes
Other howtos
About Localization and code pages
What if my DOS program cannot print to file
Known issues and additional info
Pricing and licensing





Usage:
Command line: DOSPrinter.exe [switches] filename

switches:

/TRAY Start in UI mode by showing a system tray icon. The switches and the filename are not required in the command line when /TRAY switch is present. In that case you can specify everything in the Configurator dialog (right mouse click on the icon) later, at any time. Everything stated for /R switch, also applies here.
/R Start in resident mode. Similar to TSR under DOS, but since this is a win32 exe, you should consider resident mode as the background process mode.
What "resident" means: DOSPrinter prints the specified file(s) and after that it waits in background for the specified file(s) to change. After the file(s) has changed, DOSPrinter prints out this changed file(s). Multiple instances of DOSPrinter are allowed with /R switch.
Your application could print on several different printers this way: start more instances of DOSPrinter /R, each one with a different input file (or different folder) and a different destination printer specified. It's up to your application to provide different filenames for input files.
/R1 Same as /R, but it allows only one instance of DOSPrinter per computer (also, all desktops and users under WinNT/2000/XP). If any previous instance of DOSPrinter exists, an error message pops up and the second DOSPrinter instance does not start.
/U Unload instance(s) of DOSPrinter from the memory. If used together with /IDn switch, unloads only the instance(s) with the specified ID number
/IDn Optionally specify the ID for the instance. n is the ID number of the instance. This switch can be combined with /R /TRAY and /U switches.
/DEL Delete the file after printing it. It deletes the file permanently (does not move the file in the recycle bin).
/nn force nn lines per page (nn is a number).
For example the /72 switch emulates the Fanfold page size (perforated German Std Fanfold), which is 12'' long on any other page size (letter, A4 etc). This switch gets disabled if any kind of "set vertical motion" esc-command is present in the file.
/FOCUSn Restore the focus to the calling window after DOSPrinter did the job. This is useful when the printer driver pops up with a print-status-monitor window, which a lot of modern printer drivers (mostly inkjets) do. This could be very annoying when printing from a full-screen DOS window. In that case, the printer's popup window takes the focus from the DOS window, which gets minimized, and the user has to take the focus back manually, by pressing Alt+Tab.
This switch prevents other windows from taking the focus in a period of time. n is the number of seconds to guard over the focus after the job is placed in the spooler. Increase this number for more efficient guarding of the focus, or decrease it for faster DOSPrinter response. If n is omitted, default value is 7 seconds.
/GOFF Switch off interpreting of the ASCII graphical characters (forces letters instead of lines and boxes).
/GON Force graphical characters (lines and box drawing). Optional: install MS LineDraw font for optimal interpretation of the graphical characters.
/SEL Display the "select printer dialog" before printing the file.
/SEL'printer' Specify a printer. 'printer' is a printer name from Windows OR a network share name OR the printer port.
For example, all of this forms are valid:  /SEL'HP LaserJet 2200'  /SEL'\\ACCOUNTING\HP'  /SEL'LPT2:'.
Must be enclosed in singlequotes('), not doublequotes. Note that there is no space between SEL and 'printer'.
Download PrnList utility for help with this switch. It lists all installed printers.
/SEL2 Display the "select destination dialog" before printing the file. The destination can be the printer, previewer or email. The previewer can be Acrobat reader or MS Word. Optionally, combine this switch with /PDF or /RTF to specify which one to use as the previewer. Also, you can combine it with /EMAIL, /EMLUI, /SMTP or /SMUI to specify the email destination and with /SEL'printer' to specify the printer destination.
/EMAIL'to' Print to email instead of printer. 'to' is the email address of the recipient. Specify more recipients by separating them with the sign ',' or ';'. Include the email subject by separating it with the '\' sign (backslash).
This is the complete format for the switch: /EMAIL'recipient_1[,recipient_n][\subject]'. See the examples for an example.
Must be enclosed in singlequotes('), not doublequotes. The printout is sent as an attachment in the EMF (enhanced metafile) format by default. If you prefer the RTF or PDF format, combine this switch with the /RTF or /PDF switch.
Note that there is no space between /EMAIL and 'to'. If you find the "Would you like to send email" dialog too annoying, disable it in Outlook Express under the Options / Security / Warn when others sending email.
When sending, DOSPrinter is stopped until the message is sent or canceled.
If you need more options when sending email, unzip DOSPrinter.ini in the working directory. You can edit it with Notepad.
A special form of this switch is /EMLUI'to', which brings up the email client's user interface.
/SMTP'to' Print to email instead of printer. Everything is the same as with /EMAIL switch, except it sends the mail directly to mail server over the SMTP protocol. To make it work, you need to download a plug-in program: DOSPrinter.SMTP.exe. Unzip it and read readme.html for further details.
'to' is the optional recipients email address and the subject. The 'to' string format is the same as explained for /EMAIL'to' switch.
A special form of this switch is /SMUI'to', which brings up a "Send eMail" window. Again, 'to' is not required.
/FILE Print to file instead of printer. The output file is a graphical format type (EMF format). EMF format is viewable with majority of available graphical viewers. The output filename is: input_filename + page_number + .emf extension.
Another option would be to print to a RTF or PDF file type by including the /RTF or /PDF switch together with the /FILE switch. In that case, the output filename is: input_filename + .rtf or .pdf extension.
Short version of this switch is /FI.
/RTF Print to MS Word instead of printer. RTF is "Rich Text Format" viewable with most modern word processors (editors). You can set the default viewer for RTF file extension in Windows explorer / Tools / Folder options / File Types / RTF / Change...
If you don't have MS Word, consider free MS Word Viewer. Other RTF editors/viewers are just not so rich.
A special form of this switch is /RTFG. "G" is for graphics. Use /RTFG when printing bit-image graphics (when using ESC* or ESCJ commands on the document). Another form is /RTP or /RTPG, which immediately prints (using Word), instead showing the document.
/PDF Print to PDF. You must have Adobe Acrobat Reader installed in order to view PDF files (Haven't you already).
A special form of this switch is /PDP, which prints immediately from Adobe Reader, instead previewing the document.
If you want to create a PDF file without opening the Acrobat Reader, use this switch together with /FILE switch.
DOSPrinter uses its own PDF composer. You don't need any third party PDF printer driver.
Known problems and solutions related to /PDF:
- Adobe Reader version 5 and 6 are slow inn load time. Install version 7 or 8, which are acceptable fast.
- You cannot use GIF images in PDF for embbedded graphics (ESC"file" command) or watermarking (/IMAGE switch). JPG and BMP are only supported.
- There is a bug in Adobe Reader version 5.x, which makes some nonenglish and graphical characters invisible with Courier New font. Solution is to use /LUC switch to use Lucida Console font, or even better, to install latest Adobe Reader version.
/LEFTn.nn Set the left margin in inches. n.nn is a decimal number value for inch distance from the left paper edge. If you specify the margin lesser than the printer's physical (mechanical) margin is, the value of n.nn is ignored. Note that there is no space between LEFT and n.nn.
/TOPn.nn Set the top margin in inches. n.nn is a decimal number value for the inch distance from the top paper edge. If you specify the margin lesser than the printer's physical (mechanical) margin is, the value of n.nn is ignored. Note that there is no space between TOP and n.nn.
/PAGExx Set page size. The format can be one of these: /PageA3, /PageA4, /PageA5, /PageB4, /PageB5, /PageLETTER (short /PageLET), /PageLEDGER (short /PageLED), /PageLEGAL (short /PageLEG), /PageEXECUTIVE (short /PageE), /PageFOLIO (short /PageF).
A special form is /PAGEnnnXnnn where you can set the page width and height in tenths of a millimeter. For example for the page 20cm by 30cm the switch is /Page2000x3000. If you are measuring in inches, multiply the inches by 254 to get tenths of mm.
/CPInn Sets characters per inch (vertical character pitch) initially. nn is the number of characters per inch. This are the standard CPI values:
- /CPI12 (sets 12 CPI)
- /CPI15 (sets 15 CPI)
- /CPI17 (sets 17.14 CPI, which is the samme as CONDENSED MODE)
- /CPI20 (sets 20 CPI)
Default is 10 CPI. You can also set any other nonstandard number of characters per inch.
A special form of this switch is /CPIAUTO (short /CPIA) that sets the CPI automatically. If your report is large, the letters will be too small. In that case combine /CPIAUTO with /LAND (landscape).
The CPI value set by this switch is superseded with a cpi-related command (like ESCP or ESCM) present in the file.
/F'font' Set font name. 'font' is the font name. The default font is "Courier New". Click here for more details.
/LINES Draw graphical lines when the lines in the report are represented with minuses ('-----') or equal signs ('====='). The short version of this switch is /LIN.
/LAND Set landscape orientation.
/9PIN Print in 9-pin compatibility. Default is 24 (or 48) pin compatibility. Some ESC/P commands work differently for 9-pin and 24-pin printers (like ESC 3, ESC A, ESC *, etc). The short form for this switch is /9P.
/MODERN Select "Modern" style font. Default is "Old" style. As you can see on the image, the old style letters are bigger and more readable. This switch affects 17 and 20 cpi font size only. The short form for this switch is /M.
/RAW Print directly to a printer in text mode, without any interpreting or emulating. Useful with matrix printers.
There are two different worlds in printing: text mode and graphical mode. The graphical mode becomes the issue with matrix printers - they are just too slow in graph mode and DOSPrinter by default works in graph mode.
On the other side, there are ink-jets and laser printers; even if some of them do have the text-mode printing capabilities, they are not so slow in graphical mode, so this switch is obsolete for this kind of printers.
But, a DOS program can print directly to a matrix printer, without the need of an intermediator like DOSPrinter. So, where is the purpose for this switch? First: If you have a text-mode printer with USB port, you cannot print directly to it from a DOS program, and this switch is one of the possible solutions for that. Second: you can use DOSPrinter as the print server for your (DOS or Win) application, and not caring about what type of printer is on the other side of DOSPrinter interface. If the printer is a matrix one, you could use the /RAW switch, and your application doesn't have to be aware of that.
Following switches could be combined with the /RAW switch: /TRAY, /R, /R1, /DEL, /SEL, /SEL'prn', /FOCUS, /S, others are ignored.
/S Silent mode. Prevents showing the error message dialog window.
/EUROnnn Euro symbol is character with the ASCII code nnn. nnn is a number between 33 and 255. Note that there is no space between EURO and nnn. If nnn is omitted, by default Euro is ASCII code 128.
/DELAYnn Delay printing for nn seconds. nn is a minimal delay. It is proportionally prolonged when the file changes during the delay. Delaying is suitable when the input file closes before it is completed (buffered file writing). Default value is 0 (no delay).
/CHOPnn Some printers are too slow in start (1 minute or more to start printing) when the report is large. This switch cuts the large reports in multiple spool jobs. nn is a number greater than or equal to 1, and represents the max number of pages to put in a single spool job. Smaller nn value means smaller jobs and faster starting of printing.
Use this switch sparingly in a multiuser environment, because your printed pages might be interspersed with the other documents that are using the same printer spooler.
/FITnn Set the percent of the text width. nn is percent value. Percent smaller than 100% will shrink the text, while a percent value greater than 100% enlarges the text width. This is useful with nonstandard paper sizes. If you are using a common paper size like Letter, A4, A5, etc, then you don't need to specify this switch. In that case DOSPrinter fits the text width automatically to the paper width. If you have to fit the text by the height, use the /nn switch (see details above).
/IMAGE'file' Set background image on every page (watemark). The complete format is: /IMAGE'file,x,y,dpi' where 'file' is the image filename, x and y are coordinates in thousands of inch, dpi is the resolution of the image. For example, if you'd like the image 2 inches from the left and the top edge, the switch would be /IMAGE'file.jpg,2000,2000'.
'image,x,y,dpi' must be enclosed in single quotes ('). If x and y are not specified, the default is 0. If dpi not specified the default is 200.
The background image should be a light color image to not interfere with the foreground text.
/JOB'name' Set printer spooler job name to 'name'. 'name' is any string enclosed in single quotes ('). If not specified, the job name by default is 'DOSPrinter'. Job name is visible in the printer spooler queue, on some printer status manager windows etc.
/CP1252 Force code page 1252, which is the default ANSI charset (US English).
/CP932 Force code page 932, which represents the SHIFTJIS charset.
/CP949 Force code page 949, which represents the HANGUL charset.
/CP936 Force code page 936, which represents the GB2312 charset.
/CP950 Force code page 950, which represents the CHINESEBIG5 charset.
/CP1253 Force code page 1253, which represents the GREEK charset.
/CP1254 Force code page 1254, which represents the TURKISH charset.
/CP1255 Force code page 1255, which represents the HEBREW charset.
/CP1256 Force code page 1256, which represents the ARABIC charset.
/CP1257 Force code page 1257, which represents the BALTIC charset.
/CP1251 Force code page 1251, which represents the RUSSIAN charset.
/CP874 Force code page 874, which represents the THAI charset.
/CP860 Force code page 860, which represents the PORTUGUESE charset.
/CP1250 Force code page 1250, which represents the EASTEUROPEAN charset.
/CP437 Force the nonstandard easteuropean DOS code page 437.
/LNG Set user interface language. This are currently supported languages:
/LngBR (Brasilian Portuguese)
/LngPT (Portugal Portuguese)
/LngES (Spanish)
/LngEN (English)
/LngFR (French)
/LngNL (Dutch)
            /LngHR (Croatian)
/LngSI (Slovenian)
/LngIT (Italian)
/LngDE (German)
/LngHU (Hungarian)
/LngCA (Catalan)
Translations are stored in editable file Language.ini. English is default. If using English you can delete the file Language.ini.
Notes: Switches can be in any combination and sequence. Switches are case insensitive. Instead of '/' you can also use the '-' sign.

filename - the text file name to print. If the filename contains spaces, use doublequotes.
Wildcard * is alowed in the filename.
You can use full path (absolute path) or filename only (relative path). In the case of filename only, DOSPrinter searches the current directory for the filename.



Examples:
1. DOSPrinter.exe REPORT.RPT - just print the file named report.rpt to the default printer.
2. DOSPrinter.exe /TRAY - show the systray icon. You can change the settings by clicking on the tray icon. Hint: For the simplest usage, put a shortcut with the target "DOSPrinter.exe /TRAY" in the Startup program group. This way you will have DOSPrinter installed and active all the time without any intervention.
3. DOSPrinter.exe /R1 REPORT.RPT - print the report.rpt file and wait in memory for report.rpt to change. After the file has changed, print it again. Since /TRAY switch is not specified, DOSPrinter works in background, invisible.
4. DOSPrinter.exe /U - unload DOSPrinter from memory.
5. DOSPrinter.exe /SEL /DEL /FOCUS10 C:\TEMP\*.RPT - print all files with the extension 'rpt' from c:\temp directory. Before printing, show select printer dialog. After each file is printed, delete it automatically. /FOCUS keeps the focus of the active window protected from intruder windows (like printer status monitors) for 10 seconds after each document starts printing.
6. DOSPrinter.exe /SEL'HP LaserJet 2200' "C:\MY RPTS\*.*" - print all files from 'c:\my rpts' directory to HP LaserJet printer.
7. DOSPrinter.exe /EMLUI'kurt@abc.com,john@def.com\Monthly report' "rpt.rpt" - print the file rpt.rpt to an email message with the subject 'Monthly report'.
8. DOSPrinter.exe /SMUI'anna@abc.com\Monthly report' "rpt.rpt" - print the file rpt.rpt to an email message and send it over SMTP directly to mail server.
9. DOSPrinter.exe /RTF rpt.prn - print the file rpt.prn in MS Word for previewing.
10. DOSPrinter.exe /PDF /F'Lucida Console' rpt.prn - print the file rpt.prn in Adobe Reader for previewing. Use the font named Lucida Console.
11. DOSPrinter.exe /PDF /IMAGE'watermark.jpg,1000,2000,100' rpt.prn - print the file rpt.prn in Adobe Reader. Set the image watermark.jpg as the background on every page. Watermark.jpg will be placed 1 inch from the left paper edge and 2 inches from the top edge. The resolution will be 100 DPI.

Note: If you are starting DOSPrinter from a batch file (*.bat), put a start command before DOSPrinter.exe,
something like this:
                 @echo off
                 rem - Start DOSPrinter and arm it for watching "abc.prn" file:
                 start DOSPrinter.exe /R1 /DEL /72 abc.prn
                 rem - Run your DOS program, assuming that it has the report output to "abc.prn" file:
                 MyDosPrg.exe
                 rem - At this point the user has exited from MyDosPrg.exe. Disarm and unload DOSPrinter:
                 DOSPrinter.exe /U




Esc/P Esc/P2 supported commands:
BS Backspace
HT Tab horizontally
LF Line feed
VT Tab vertically
FF Form feed
CR Carriage return
SO Select double-width printing (one line)
SI Select condensed printing
DC2 Cancel condensed printing
DC4 Cancel double-width printing (one line)
ESC SO Select double-width printing (one line)
ESC SI Select condensed printing
ESC ! Master select
ESC - Turn underline on/off
ESC + Set n/360-inch line spacing
ESC 0 Select 1/8-inch line spacing
ESC 1 Select 7/72-inch line spacing
ESC 2 Select 1/6-inch line spacing
ESC 3 Set n/180-inch line spacing
ESC 4 Select italic font
ESC 5 Cancel italic font
ESC @ Initialize printer
ESC * Select bit image (also ESC ^, ECS K, ESC L, ESC Y, ESC Z)
ESC A Set n/60-inch line spacing
ESC C Set page length in lines
ESC E Select bold font
ESC F Cancel bold font
ESC G Select double-strike printing
ESC H Cancel double-strike printing
ESC P Select 10-cpi
ESC M Select 12-cpi
ESC g Select 15-cpi
ESC l Set left margin. This margin is added to the margin specified through the /LEFT switch.
ESC J Advance print position vertically
ESC j Reverse paper feed (n/216 inch)
ESC N Set bottom margin (set skip-over-perforation)
ESC O Cancel bottom margin (cancel skip-over-perforation)
ESC R Select an international character set
ESC S Select superscript/subscript printing
ESC T Cancel superscript/subscript printing
ESC W Turn double-width printing on/off
ESC w Turn double-height printing on/off
ESC r Select printing color
ESC x Set LQ of draft
ESC ( - Select line/score (underline/strikethrough)
ESC B Set vertical tabs
ESC D Set horizontal tabs
ESC e Set fixed tab increment
ESC f Horizontal/vertical skip
ESC ( V Set absolute vertical print position
ESC $ Set absolute horizontal print position
ESC \ Set relative horizontal print position
ESC EM Control paper loading/ejecting (select paper source)
ESC ( B Barcode setup and print
ESC k Select typeface
ESC p Turn proportional mode on/off
ESC X Select font size by pitch and point
ESC z n Select font size. n is a byte number representing the Word font size. This is a nonstandard ESC sequence.
ESC SP Set intercharacter space by n/120 inch
These are the mostly used commands. If you are using some other command(s), fell free to contact us for an update of DOSPrinter.
Download complete ESC/P ESC/P2 specification from here.
(ESC/P and ESC/P2 is a trademark of Seiko Epson Corporaton)


How to print graphics:
There are three ways to put images on the printed documents:
1. Put inside the text to print this sequence: ESC"filename.bmp". ESC is ASCII code 27, filename.bmp is the name of the image file to print. Don't forget to enclose the filename in doublequotes. The image is printed with the resolution of 200DPI. This means that if you need the result image with dimensions 1inch x 1inch on the paper, you should provide an image with the size of 200pixels x 200pixels.
You can change the default resolution by specifying a new resolution for the image: ESC"filename.bmp,400DPI".
When the image is colored and the printer is black+white, the colors appearance is dictated by the printer driver graphics settings, which are changeable.
Note that there is no space between ESC and "filename". Images can be BMP, GIF, JPG, ICO format.
This is a nonstandard ESC command.
2. Use the ESC* sequence (Bit-image mode) in your documents. This is a standard ESC/P ESC/P2 command.
3. If you'd like to print an image on every page, use the switch /IMAGE'filename'. This is useful for watermarking a company logo, or using a standard form image in the back of the text.




How to select font:
There are two ways to specify the printing font:
1. By using /F'fontname' switch with the DOSPrinter command line, where 'fontname' is name of the font as installed under the windows. Open Control panel/Fonts to see the fonts that you have installed.
2. By using the ESCkn (Select typeface) sequence in your documents. This is a standard ESC/P ESC/P2 command.
The third byte of the sequence ESCkn is a number representing the font name by this table:
n Font name n Font name n Font name
0 Courier New 6 Impact 12 Monofur
1 Lucida Console 7 Comic Sans MS 13 Haettenschweiler
2 Andale Mono 8 Bookman Old Style 14 Garamond
3 Letter Gothic 9 Script 15 Verdana
4 Monotype Corsiva 10 Times New Roman 16 Tahoma
5 Arial 11 Century Gothic 17
Note that not every font supports every code page.
There are two types of fonts: fixed pitch and proportional pitch. Fixed pitch means that every letter has the same width. DOSPrinter yields the best results with the fixed pitch fonts. I personally like Lucida Console, Consolas, Letter Gothic or Andale Mono. Download this few fonts and try them. You can find much more fonts on the internet. Majority of fonts are not free.
With some laser printers, the printed text is too light with the default Courier New font. The solution is Dark Courier font.
Click here for the instructions about how to install a new font.
By default DOSPrinter works with proportional mode turned off (works in fixed pitch mode). Use the ESC sequence ESCp1 to set the proportional mode on, or ESCp0 to set it off.
You can change the font size (or CPI) with the standard ESC sequences like ESC P, ESC M, ESC g, ESC X, etc.
A special ESC sequence for setting the font size is ESC z n, where n is a byte number representing the Word font size. This is a nonstandard ESC sequence.



How to print barcodes:
The standard ESC sequence for printing barcodes is ESC ( B nL nH k m s v1 v2 c BarCodeData
where ESC is ASCII 27, ( is ASCII 40, B is ASCII 66,

nL and nH are two bytes representing total number of data bytes to follow, determined by the following equation: (number of data bytes) = 6 bytes + BarCodeData bytes = ((nH*256) + nL). (where 6 bytes are k, m, s, v1, v2, and c). nH is ignored in DOSPrinter. This means you can print barcodes with max 255-6=249 characters, which should be enough.

k is barcode type. Possible values for k and meanings are:
0 = EAN-13
1 = EAN-8
2 = Interleaved 2 of 5
3 = UPC-A
4 = UPC-E
5 = Code 39
6 = Code 128
7 = POSTNET
8 = Code 93
9 = CODABAR

m is barcode width measure. Possible values are 1, 2, 3, 4, 5. 1 is smallest, 5 is largest size.

s is "Space adjustment value". It is ignored by DOSPrinter.

v1 and v2 are barcode length (height) calculated by the formula: inches = (v1 + v2*256) / 180. For 9pin mode emulation the formula is (v1 + v2*256) / 72.

c is Control flag. Each bit of Control flag has a meaning:
if bit 0 is 0: A check digit is not added by DOSPrinter
if bit 0 is 1: A check digit is added by DOSPrinter
if bit 1 is 0: The human readable characters are added by DOSPrinter
if bit 1 is 1: The human readable characters are not added by DOSPrinter
if bit 2 is 0: Flag character is centered (for EAN-13 and UPC-A only)
if bit 2 is 1: Flag character is under (for EAN-13 and UPC-A only)
if bit 3 is 0: For CODE39 and CODE93 only - start and stop characters (*) are added by DOSPrinter.
if bit 3 is 1: For CODE39 and CODE93 only - start and stop characters (*) are not added by DOSPrinter.
Other bits are ignored.


BarCodeData are characters to be printed. Here are some comments about barcode characters:

Barcode type

Notes about check character

Notes about BarCodeData characters

EAN-13 The last digit is a checksum digit. DOSPrinter calculates the checksum digit automatically. You have to provide 12 digits. If provided 13 digits, the last digit is ignored and replaced by DOSPrinter in all cases. Valid barcode characters are 13 digits in the range 0 - 9
Invalid characters are replaced with zeroes.
EAN-8 The last digit is a checksum digit. DOSPrinter calculates the checksum digit automatically. You have to provide 7 digits. If provided 8 digits, the last digit is ignored and recalculated by DOSPrinter in all cases. Valid barcode characters are 8 digits in the range 0 - 9
Invalid characters are replaced with zeroes.
UPC-A The last digit is a checksum digit. DOSPrinter calculates the checksum digit automatically. You have to provide 11 digits. If provided 12 digits, the last digit is ignored and recalculated by DOSPrinter in all cases. Valid barcode characters are 12 digits in the range 0 - 9
Invalid characters are replaced with zeroes.
UPC-E The last digit is a checksum digit. DOSPrinter does not calculate the checksum digit automatically for this barcode type. Valid barcode characters are 8 digits in the range 0 - 9
Invalid characters are replaced with zeroes.
First digit (named number system digit) must be 0 or 1.
Interleaved 2 of 5 Optionally, DOSPrinter inserts a mod 10 checksum character at the end, if bit 0 of flag c is set to 1. Valid barcode characters are 0 - 9. Invalid characters are replaced with zeroes.
The specification requires that the barcode must have even number of digits. If you provide odd number of digits, DOSPrinter adds a zero at the beginning to satisfy the specification.
CODE 39 Optionally, DOSPrinter inserts a mod 43 checksum character at the end, before the stop character (*), if bit 0 of flag c is set to 1. The start(*) and stop(*) characters are not required, but (by default) DOSPrinter adds them. You can override the automatic generation of start and stop characters by setting the bit 3 of flag c to 1.
Valid characters are numbers, big letters and characters '-','.',' ','$','/','+','%','*'. Other characters are skipped.
POSTNET The last digit is a checksum digit. DOSPrinter calculates the checksum digit automatically. If you provide the checksum digit, it is ignored and replaced by DOSPrinter. Valid barcode characters are 0 - 9
Valid number of digits are 6, 10 and 12 with the check digit included, or 5, 9 and 11 without the check digit. Only special POSTNET code scanner can read this type of barcode.
CODE 93 Two checksum characters are required for this barcode type. DOSPrinter calculates and inserts them automatically if bit 0 of flag c is set to 1, at the end, before the stop character (*). It is a high-density barcode, suitable for long alphanumeric data.
The start(*) and stop(*) characters are not required, but (by default) DOSPrinter adds them. You can override the automatic generation of start and stop characters by setting the bit 3 of flag c to 1.
Valid are all the ASCII characters with code from 0 to 127.
CODE 128 Checksum character is required for this barcode type. DOSPrinter calculates and inserts one automatically if bit 0 of flag c is set to 1. It is a high-density barcode (especially dense for numbers), suitable for long alphanumeric data.
Valid are all ASCII characters with code 32 to 127. Invalid characters are ignored.
Codabar There is no checksum character for this barcode. You must manually provide the start and stop characters, which could be characters A, B, C or D.
Valid data is numbers 0-9 and characters '-','$',':','/','.' and '+'. Other, invalid characters are ignored.
Download this file for an example of how to use the ESC ( B command.



How to change the paper orientation (Landscape/Portrait):
By default DOSPrinter prints in Portrait orientation. There are two methods to change the orientation to Landscape:
1. Use /LAND switch in the command line. This is very simple, but changes the orientation globally, for all the pages under that job.
2. If you need to change the orientation at the page level, put inside the document this command seqence: ESCoL or ESCoP, where ESC is ASCII code 27, o is ASCII code 111, L is ASCII code 76, P is ASCII code 80.
ESCoL is for setting the Landscape orientation, ESCoP is for setting the Portrait orientation at the page level.
The rule for this two commands is: If an ESCo command is found at the beginning of the page, it affects the current page (and next pages). If it is not at the beginning of the page, it affects next pages. Beginning of the page is first 20 bytes of the page.
ESCo is a nonstandard ESC command. Download this file for an example of the usage of ESCo command.



How to print multiple copies of pages:
By default DOSPrinter prints one copy of each page. You can set the number of copies with the ESC sequence ESCnN placed in document to print, where ESC is ASCII code 27, n is ASCII code 110, N is number of copies.
You can set different number of copies for different pages. The rule is: If the ESCnN sequence is found at the beginning of the page, it affects the current page (and next pages). If it is not at the beginning of the page, it affects next pages only.
Beginning of the page is first 20 bytes of the page. ESCnN is a nonstandard ESC command. Download this file for an example of the usage of ESCnN command.
Some printers are not capable to print multiple-page copies (virtual printers, for example).



How to print on both sides of the page (duplex printing):
Not all printers can print in duplex. If your printer is capable to print in duplex mode, you can put inside the document this command seqence: ESCoV or ESCoH, where ESC is ASCII code 27, o is ASCII code 111, V is ASCII code 86, H is ASCII code 72.
The rule for this ESC sequence is: If an ESCoV or ESCoH command is found at the beginning of the page, it affects the current page (and next pages). If it is not at the beginning of the page, it affects next pages. Beginning of the page is first 20 bytes of the page.
To switch back to simplex mode, use the ESC sequence ESCoS.
ESCoV, ESCoH and ESCoS are a nonstandard ESC commands.



How to control the paper source (change paper bin):
You can set the default printer's paper source in the printer driver properties, or you can use /SEL switch in the DOSPrinter command line to select different paper source before document is printed. These methods are simple, but changes the paper source globally, for all the pages under that job.
With the ESC sequence ESC EM nL nH you can change the paper source at the page level. ESC is ASCII code 27, EM is ASCII code 25, nL and nH are two bytes identifying the paper source. nL is lower byte nH is higher byte. How to find the values for nL and nH? There is a form of this command to help you with that. Put in the document to print this form of command: ESC EM 255 0, where 255 is value for nL, 0 is the value for nH. This form of command shows a message box like the image on the right, displaying all possible paper sources with their ID numbers for the currently selected printer. The formulas are:
nH = INT(ID/256)
nL = MOD(ID/256)
For example, ID for Cut Sheet is 258 (see sample image on the right), nH = 1, nL = 2. This is a standard ESC/P command, but there is a difference from DOSPrinter implementation - the standard requires only one byte for n value. The rule is: If the ESC EM command is found at the beginning of the page, it affects the current page (and next pages). If it is not at the beginning of the page, it affects next pages only. Beginning of the page is first 20 bytes of the page.



How to change DOSPrinter switches during the run time:
You can change the DOSPrinter behaviour in run time. For example, if DOSPrinter has been initially set to send the reports to a printer and you'd like to change that behaviour to send the reports to email. You have two options to do that:
Option 1. Unload a running DOSPrinter instance, then reload it again with a different switches in the command line. Example:
DOSPrinter.exe /TRAY rpt.prn   - this prints the file rpt.prn to the printer
...at some point you decided to print to email instead of the printer. The command line would be:
DOSPrinter.exe /U     - this will unload the currently running instance
DOSPrinter.exe /TRAY /EMLUI rpt.prn  - this will reload DOSPrinter, and make it print to email
In the case you have several different running resident instances, you can selectively unload and reload them by using the switch /IDn. For example:
DOSPrinter.exe /TRAY /ID1 abc.prn   - this is instance ID=1
DOSPrinter.exe /TRAY /ID2 def.prn   - this is instance ID=2
...at some point you decided to print to email instead of printer, but only the file def.prn, ie the instance ID=2
DOSPrinter.exe /U /ID2     - this will unload the instance ID=2 only
DOSPrinter.exe /TRAY /EMLUI /ID2 def.prn  - this will reload instance ID=2, and make it print to email
Option 2. This option is less agressive. It does not load and unload DOSPrinter.exe. To reprogram a running DOSPrinter instance you can put an ESC command in the file to print. The format is ESC"switches", where "switches" is the text that represents the new DOSPrinter command line. The text "switches" must be enclosed in the qouble quotes("). Example:
ESC"DOSPrinter.exe /EMLUI def.prn" (where ESC is ASCII code 27) will redirect the output of file def.prn to the email.
If an ESC"switches" sequence is found at the beginning of the file, it affects the current file (and next ones). If it is not at the beginning of the file it affects next files only.
Note that you don't have to insert this ESC sequence in your existing reports. You can issue ESC"switches" sequence in a separate file that has the same filename as the report file. In that case make sure that you haven't added some extra spaces or line feeds in the file, because DOSPrinter could render this file as an empty page.



Localization and code pages:
By default DOSPrinter interpretes the current DOS OEM character set installed into the Windows. You can check which OEM code page is currently active on your machine by finding the registry key: HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Nls\Codepage\OEMCP. You can also change this value (at your own risk).
You could override this default behavior by including the switch "/CPnnnn" at the DOSPrinter command line, where nnnn is your code page.
If you want the screen UI translated use the switch /LNGxx (see details above). The translations are stored in the editable text file Language.ini.



What if your DOS program cannot print to the file:
Thanks to Tom Schotland for the trick.
- Under Printers and Faxes add a neew printer. The printer type or model is not important! We will use the printer port only, not the driver.
- Right click on the newly created printerr icon. Go into Properties / Ports / Add Port / select LocalPort / click New Port / Enter a port name: "C:\TEST.PRN". Of course, you can input some other filename for the printer port name. After the port (file) is specified, click Close.
- Right click again on the printer icon. CClick Sharing on the menu. Then click on Shared as. Input a network name for the printer, something like "DummyPrn".
- Enter command prompt (run command.com) aand type: NET USE LPT1: \\MyPcName\DummyPrn.
MyPcName is your network computer name. Later, you can insert this line in a batch file, right before calling your program. This will only work if your PC is connected to a network (including dialup). If you have a stand-alone PC you may have troubles with NET USE command, in that case follow this instructions.
- You can start your DOS program now, and every print gets redirected to C:\TEST.PRN.

Another approach would be to use a DOS TSR redirector, which redirects LPT to a file. Try: prn2file, or prindir9 (local: prindir9) ...



Issues and additional info:
 - If DOSPrinter works in UI mode (/TRAY switch), it creates a registry key for saving the settings: HKCU\Software\Alternet\DOSPrinter.
 - Downloadable demo version is exactly the same as the registered one. The only difference is that the demo version sometimes prints a demo message on the first page and it is valid for 30 days. If you find DOSPrinter useful, buy a registered copy.
 - Some printer drivers are behaving strange. That is the case with some drivers produced by HP, or others, especially drivers for cheap ink-jets. The strange behaviour is that they are printing slow, or not rendering some fonts or code pages, or else. The solution is to install another printer driver. The easiest thing to do is to use a compatible driver that already exist in your windows. For example, if you have a HP DeskJet 3820, and is behaving oddly, follow this instructions:
   1.) Click "Start"
   2.) Click "Control Panel"
   3.) Click "Printers and Faxes"
   4.) Click "Add Printer"
   5.) The wizzard will ask for the printer port. Select the same port the existing driver uses.
   6.) From the "Manufacturers" list select "HP".
   7.) From the "Printers" select "HP DeskJet" (without the model number).
   This way we installed a generic DeskJet driver, which works all right in all the circumstances. You can use it together with the existing, original driver from the printer box.
Another solution to this problem would be to use /PDP or /RTP switch with DOSPrinter command line. This uses Acrobat Reader or Word to print the report to the driver in question.



Supported platforms:
Win9x, ME, NT, 2000, XP, 2003, Vista.



Pricing and Licensing:
There are two distinctive types of DOSPrinter license: standard (single user) and unlimited (developer).
The price for one, standard (single user) license is US$ 40.00.
Contact us for further details about prices and purchasing options.





Newest release: 3.4
Download DOSPrinter

History of changes:
ver 3.4:
 - Updated MAPI component for sending emails with /EMLUI and /EMAIL switches.
 - Improved sending emails with /EMLUI and /EMAIL switches by introducing DOSPrinter.ini.
ver 3.3:
 - new /PAGExx switch for selecting the page size.
 - new /LNGxx switch for selecting the UI language.
 - new /CPIAUTO switch for setting the number of characters per inch automatically.
 - new ESC sequences supported: ESC ( -
 - new nonstandard ESC sequences supported: ESC z n. n is a number representing the font size as it would be in Word.
ver 3.2:
 - new /F'font' switch for selecting the font.
 - new /IMAGE'filename' switch for selecting the background image.
 - new /SEL2 switch for bringing up the select destination dialog window.
 - new /IDn switch for identifying the resident instance.
 - new ESC sequences supported: ESC SP, ESC k, ESC p, ESC X.
 - new ESC'switches' sequence for the runtime control of DOSPrinter behaviour.
 - /TRAY settings are saved in the registry under HKCU, instead HKLM.
ver 3.1:
 - new /M switch for selecting the "modern" font style.
 - improved ESCnN command for printing multiple copies of a page. Before this version the printer driver handled this function. Now DOSPrinter copies the pages by itself.
ver 3.0:
 - new /PDF switch - a change important enough to increment the major version number.
 - improved font measures when printing to a printer.
ver 2.7:
 - new /EMLUI, /SMTP and /SMUI switches for sending email
 - fixed a minor bug with /RTF output. Redisegned "Configurator" dialog.
 - improved /SEL'printer' switch.
ver 2.6:
 - new esc command for printing barcodes.
 - new esc command for switching the page orientation (portrait/landscape) within the document. Click here for details.
 - new esc command for setting the number of copies. Click here for details.
 - new esc command for selecting the paper source. Click here for details.
 - embedded graphics (ESC"filename.bmp" command) now can be in BMP, GIF, JPG, ICO format. Before was in BMP only. Click here for details.
ver 2.5.8:
 - internal release.
ver 2.5.7:
 - carriage return (ASCII 13) is now supported with /RTF (which is preety tricky in Word).
ver 2.5.6:
 - new /CP860 switch (for Portuguese).
 - new esc command ESC$ set absolute horizontal print position.
 - new esc command ESC\ set relative horizontal print position.
 - improved font measures.
ver 2.5.5: Internal release.
ver 2.5.4:
 - new /FIT switch. For setting the percent of text width.
 - additional minor improvements.
ver 2.5.3:
 - improved /LAND switch. No restrictions anymore for printing in landscape orientation.
 - improved ESC"file.bmp,nnnDPI", a nonstandard ESC command for printing the images. You can specify the image resolution now. Click here for details.
 - /JOB new switch for setting the spool job name.
ver 2.5.2:
 - improved /FOCUS switch. Added the possibility to set up the time interval to guard over the caller's window focus
 - bug fix: the underline command now underlines the spaces as well as any other character
ver 2.5.1:
 - /CHOP new switch for breaking a large report to several spool jobs for faster startup of slow printers
 - improved /LINES switch
 - ESCj new supported command for reverse paper feed
ver 2.5:
 - /RTF new switch for printing into MS Word
 - ESC S new command for printing superscript/subscript
 - ESC T new command for canceling superscript/subscript
ver 2.4:
 - /LINES new switch for converting the textual lines to the graphical ones
 - /DELAYn new switch for delaying the printout
 - /9PIN new switch for 9pin printer emulation compatibility mode
 - /RAW new switch for directly printing to the printer (acctually, it's directly to the win spooler)
 - /LETTER new switch for selecting the "Letter Gothic" printing font
 - ESCe new command for setting the fixed tab increments
 - ESCf new command for horizontal or vertical skip
ver 2.3.2:
 - /LUCIDA new switch for setting "Lucida Console" printing font
 - new subject separator for /EMAIL switch is '\' (backslash). Old was ':'
ver 2.3.1:
 - /CPInn new switch for setting the vertical character pitch
ver 2.3:
 - "DOSPrinter" is the new name for the program. Old was "DOSPrint".
 - ESCD new supported command for setting the horizontal tabs
 - ESCB new supported command for setting the vertical tabs
ver 2.2:
 - ESC* standard ESC command (bit-image)
 - ESCJ standard ESC command (vertical motion)
 - /LEFT new switch for setting the left margin
 - /TOP new switch for setting the top margin
 - additional optimizations and improvements
ver 2.1:
 - /EMAIL new switch for printing to email
 - /FILE new switch for printing to file
 - ESC"filename.bmp" command doesn't need the "FIX" directive anymore. It is fixed to 200 dpi by default.
ver 2.0:
 - /TRAY new switch for running in UI mode (systray icon)
 - /S new switch for silent mode (doesn't display errors)



Last update: 06.12.2007.
mirror site at netfirms

Bojan Banko
Alternet software
bojan.banko@pu.htnet.hr