In ancient times it was easy to print: you just sent strings to your printer port. People formatted their paper reports using primitive formatting instructions inserted into the strings. These instructions were called «escape sequences» because they usually started with the ESCAPE character (ASCII 27). With these instructions they selected one of the predefined fonts provided by their printer's hardware, they specified the size and appearance (bold, italic, underline),... and were happy with the result.
Nowadays you have a multitude of possibilities if you want to print something, but this old venerable layout model got thrown out together with the bath water.
Lino TextPrinter brings it back.
- You can use TextPrinter directly from your Python script (see textprinter1.py example). (Note that I am working on gendoc, a more sophisticated module with a more modern document model.)
- You can use the command-line tools prnprint and prn2pdf as a bridge between your old DOS application and your modern printer.
How prnprint and prn2pdf are used in practice
So you have an old DOS application that can print only to text-capable printers that are connected on LPT1: through LPT3:. How TextPrinter can help you:
First you redirect the printer port to a temporary file. If your application doesn't support redirection, there are tools for this. One I remember was called prn2file.
Now the DOS application thinks that it is printing to a normal text printer, but the printer output is redirected to a file.
Then you run either prnprint.exe if you want to print directly to your Windows-compatble printer, or prn2pdf prn2pdf.exe to create and display a PDF file. (prn2pdf will start your Acrobat Reader to display the output).
Your DOS application must offer a possibility to write your own printer driver, because TextPrinter currently «emulates» only one printer, and furthermore this printer is a fictive one. The Printer Control Commands of this fictive printer are documented in a separate article. It is possible to write emulators for existing printers.
- Examples of textprinter input files — Here is a list of some example input files for textprinter. more
- Printer Control Commands — The textprinter module currently «emulates» only one fictive printer. It is possible to write drivers for existing printers. more
- prn2pdf — Prn2pdf renders a textprinter stream to a PDF file. more
- prnprint — prnprint is similar to prn2pdf, except that it prints directly to a Windows printer instead of generating a pdf file. more
- What is a text-capable printer? — Nowadays there are more and more «Windows only» printers on the market. These printers are not text-capable. You cannot even print plain text on them! They don't even know how an «A» looks! more
- Why does TextPrinter emulate only a fictive printer? — My first plan was to emulate a real printer, for example an Epson LQ, an IBM ProPrinter or a HP Laserjet. printer so that prn2pdf and prnprint could be used by old DOS applications without any need for change. more
Refering articles:
- misc (code changes 06.04.05) — Working on TextPrinter and winprn and prnprint use wrong character size after setLpi(). more
- release 0.6.3pre (Releases 29.12.04) — prnprint and lino.textprinter is now possibly usable.