Mar 032014
 

DOSBox is a DOS-emulator that was originally developed to run old DOS games that had problems with the standard DOS emulations of Windows. It does have some additional uses though.

We have got an old DOS program that still hasn’t been fully ported from Borland Pascal to Delphi. Since Windows 7 64 Bit does no longer run DOS programs, we now run this program in DOSBox. One of the main functions of this programs is printing some curves on a dot matrix printer on fan-fold paper (Just learned a new word, thanks dict.leo.org.) Getting printing to work takes some configuration.

First, you need DOSBox Megabuild 6 since apparently printing is not fully implemented in the official version.

Then you must decide how you want to print:

  • Print to a printer attached to your computer (this includes a pdf printer provided by e.g. PDFCreator)
  • Print to png (or even bmp) files
  • Print to a file that contains the data sent to the printer
  • Print directly to a dot matrix printer

Whatever you want to do, you need to modify the .conf file (or start DOSBox with the -conf parameter pointing to a modified .conf file).

The .conf file is in INI format, so editing it can be done with any text editor. The installer also creates a menu item in the DOSBox start menu folder, subfolder config called “Edit Configuration” which you can use to edit the configuration with notepad.

Printing to a local printer

If you want to print to a local printer, do the following:

[parallel]
parallel1=printer

[printer]
printoutput=printer
multipage=false

You might want to adjust the other configuration options in the [printer] section, in particular multipage must be set to true, if you want to print to a PDF file and don’t want to create a new PDF for each page.

If you print from a DOS program within DOSBox, you will get the Windows printer select dialog. This won’t happen immediately but after a while (when enough data has been printed) or only after exiting the program or even DOSBox. There is a shortcut for “Eject Page” which is mapped to F2 by default. It might also help to get this dialog (I haven’t tried that because it probably has some side effects.)

Printing to a png/bmp file

If instead you want to print to a png or bmp file, one per page, you change the entries under [printer] like this:

[printer]
printoutput=png
docpath=c:\some\directory

Don’t forget to set the docpath to some suitable location otherwise you will hunt for the files all the time.

Other possible values for printoutput are bmp for generating bitmap files and ps for generating PostScript output. I haven’t tested them.

Printing to a file that contains the data sent to the printer

To write the data that is sent to a printer to a file, configure DOSBox like this:

[parallel]
parallel1=file

This will create files in the capture folder, the filename will be the name of the program that printed them, followed by _<3digitnumber>.prt. If you want to append everything to one file, specify the filename like this:

[parallel]
parallel1=file append:c:\outputfile.prt

The files created with this method can be copied to the printer without changes to print them. But note that this is raw output containing control codes for the printer that is printer dependent. So if your program knows how to print to an Epson ESC/P dot matrix printer, you can copy the file to such a printer and it will work. If you copy it to a different printer you will most likely get garbage.

Printing directly to a dot matrix printer

To directly print to a dot matrix printer, you configure DOSBox like this:

[parallel]
parallel1=file dev:lpt1

If the printer is directly connected to the host’s first parallel port, this should already work (I haven’t tried it though). If not, you need to mount it using

net use lpt1 \\server\SharedPrinter

This will directly print to a network printer. Again, be warned that this only works if your DOS program knows how to print to this particular printer type.

Alternatively you can specify the printer share directly in the [parallel1] section like this:

[parallel]
parallel1=file append:\\server\SharedPrinter

Sorry, the comment form is closed at this time.

%d bloggers like this: