Print Raw Text to PDF (e.g. from DOS applications)
This is a short guide on how you can send raw text to the virtual PDF printer using LPT1. This is required in connection with printing/creating PDF files from pure DOS applications, among other things. Some of the basic settings of the printer will be changed to accomplish this. Therefore, a separate printer with a different name is installed. Using a separate printer, we can preserve the normal PDF printer for printing PDF file from other (Windows) programs.
Install the text printer
The new virtual printer for this example is installed with the command line shown below. It will install a virtual printer named Text to PDF which is automatically shared on the network with /SHARE.
Setup_7PDF_10_25_0_2559_PRO.exe /SHARE /PRINTERNAME="Text to PDF"
Important: Be sure to check whether the correct printer driver "7-PDF Printer" has been set by the system for the printer instance! If this is not the case, temporarily uncheck the printer release box so that you can then switch the driver to "7-PDF Printer". Then check the printer release box again and save!
Change the print processor
In order to be able to print text files, we need to change the print processor for the installed printer. That way Windows knows that the printer should process raw text.
Go to the Advanced tab in the printer properties and click the Print Processor button. Set the print processor to winprint and TEXT.
Map the printer to LPT1
Mapping LPT1 can be done from the command line with the following command:
NET USE LPT1 "\\localhost\Text to PDF"
Set the margins
By default, the printer will print to the edge of the paper. You will most likely want to have some kind of margin. On the advanced tab in the printer properties dialog, click the Printing Defaults button. Then click the advanced button.
Select the custom paper size and set the margins.
The margins are the top and left margin. It will print to the right paper edge if your lines are long enough. It will also print to the bottom edge if your file has many lines. You can use normal line breaks to start new lines in the output document. The form feed character is also supported and will continue the output on a new page.
If you want to test it, you can download the example.txt. It is a short text file that contains a few lines and a formfeed character. Save it to your hard drive and run this command line:
COPY example.txt LPT1
The PDF Printer will print the text file. You can disable the dialogs and automatically create the file names using the options dialog for the installed printer.