Hi all, Now that the new version (1.2.4-1) of lpr works properly I have been trying to configure the printing commands of programs that can print directly, such as dvips, ghostview or xfig. I have found that this task is not trivial because in general the files to be printed need to be preprocessed; for example in my case they need to be converted from postscript to deskjet. Not even the printing of a text file is trivial.
In order to facilitate this task I have modified lpr including a couple of additional options. I am proposing to include these chages in the new versions of lpr. Follows a description of the modifications. The modified files are attached. 1- In my experience most of the time the CR/LF translation is not needed, so it was flipped the way the raw option works. No option: raw printing, -l option: LF -> CR-LF preprocessing. 2- The -f option was included. It indicates that a FORMFEED character is appended to the file. In most printers (working in line printer mode) this would produce the ejection of the last page of the document. 3- The " -F nameoffilter" to give the name of a filter (or pipe), to be applied to the input file before sending it to the printer. So lpr -l -Ffilter -Pprinter file would be equivalent to filter < file | lpr -l -Pprinter . Follows a description of how to print different kinds of files on different kinds of hardware if lpr had the features I am proposing. --- Printing of text files with line-printers. In a Cygwin environment one has at least three kinds of text files: Unix text files, Windows text files and DOS text files. Unix and Windows text files usually use some iso-8859-* character set, while DOS uses an ibm-cp* character set. On the other hand Windows and DOS text files use CR-LF line terminations, while Unix files use LF line terminations. Most printers have a line-printer mode in which they print each byte of a text file. In many cases, such as in mine, the printer is DOS-compatible, what that means is that it uses an ibm-cp* character set, depending on the language you use, and of course it requires a CR-LF or LF-CR line termination. In my case the printer and DOS use ibm-cp850, while cygwin and Windows use iso-8859-1. In order to print a text file one has to: for a DOS text file: append FF, send raw to lpr; for a Windows text file: translate iso-8859-1 to ibm-cp850, append FF, send raw to lpr; for a Unix text file: translate iso-8859-1 to ibm-cp850, LF->CR-LF, append FF, send raw to lpr. If lpr had the options I proposed (including the change of -l) and an iso2ibm filter were available the commands for printing text files were: lpr -f -Pprinter DOS.txt lpr -f -Fiso2ibm -Pprinter WINDOWS.txt lpr -f -Fiso2ibm -l -Pprinter UNIX.txt Right now I have to use scripts in order to accomplish the same tasks. There are line-printers that use the iso-8859-* character set, in that case WINDOWS and UNIX text files don't need to be preprocessed, but DOS file would require an ibm2iso filter: lpr -f -Fibm2iso -Pprinter DOS.txt lpr -f -Pprinter WINDOWS.txt lpr -f -l -Pprinter UNIX.txt --- Using a postscript printer. To print a postscript file would be trivial lpr -Pprinter file.ps To print a text file you need a formatting filter, that produces a postscript file from the text file. Call it txt2ps. txt2ps can be designed to process both WINDOWS and UNIX files. lpr -Ftxt2ps file.txt For a DOS.TWX file you would need to previously apply an ibm2iso filter lpr -Fibm2iso|txt2ps DOS.txt --- Using other graphic printers. Most modern printers have a graphic mode of operation, which use their own graphic language. The printer I have is a HP color deskjet. The ghostscript which is distributed by cygwin translate a postscript file to any kind of other graphic languages. Using gs one can make a shell script that behaves as a filter from pstscript to deskjet: ps2cdj. Some examples of printing. In order to print the output of a program like Word with the option "print to file" one only needs to send the file raw to the printer lpr -Pprinter file.cdj For printing a postscript file lpr -Fps2cdj -Pprinter file.ps For printing a text file in graphic mode lpr -Ftxt2ps|ps2cdj -Pprinter file.txt lpr -Fibm2iso|txt2ps|ps2cdj -Pprinter DOS.txt ---------------------------------------------------------------------------- ----------- Rodrigo Medina.
Printer.hh
Description: Printer.hh
Printer.cc
Description: Printer.cc
lpr.cc
Description: lpr.cc
lpr.1
Description: lpr.1
-- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/