PSPRINT is a small utility for helping printing PostScript files, especially if you want to print them both-sided. It allows you to select the pages to be printed, and to print them in reverse order. In addition, a Tcl/Tk user interface is provided.
psprint.htm | This documentation file. |
psprint.gif | a picture of the user interface. |
psprint.adb | The program. It consists of a single Ada procedure. |
psprint.tcl | A Tcl/Tk script that provides a convenient interface to PSPRINT. |
PSPRINT and its documentation are Copyright © Adalog, 1999.
This software is distributed under Adalog's "advertiseware" license. The goal of this license is to make this product widely available as an advertisement for Adalog activities and a demonstration of Adalog's know-how in Ada development, without imposing any constraint on the user, except that code not made by Adalog should not be confused with original code (we cannot accept responsability for your bugs). Therefore:
Rights to use, distribute or modify in any way this software and its documentation are hereby granted, provided:
This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Although we do not require it, you are very welcome, if you find this software useful, to send us a note at rosen@adalog.fr. We also welcome critics, suggestions for improvement, etc.
Compile the file psprint.adb with your favorite Ada compiler. There is nothing that could create the slightest dependance on any particular compiler or environment. Note that you need Tcl/Tk installed if you want to use the nicer user interface.
We have tried PSPRINT without problem both on Linux and Windows. Thanks to the portability of Ada and Tcl/Tk, it should be working on any system.
psprint [<In-file>|'-' [<Out-file>]] [Options]
If no argument is provided, PSPRINT reads from standard_input and writes to standard_output. If only one argument is given, it is taken as the input file, and output goes to standard_output. If you need to read standard_input and output to a file, use "-" as the name of the input file.
Without options, PSPRINT will simply copy the input file to the output file, which is not very exciting... So generally, you'll need one or more of the following options:
-f<first-page> | Page number of first page to copy (default: 1) |
-l<last-page> | Page number of last page to copy (default: end of file) |
-a<page> | Always print this page, irrespectively of other options. This can be useful if you know that some page contains PostScript definitions that are required later in the document. |
-o | Print odd pages |
-e | Print even pages. |
-r | Print pages in reverse order (last page first). |
-h | Help. Prints a usage summary and quits. (all other options are discarded) |
-v | Verbose |
Options can be grouped in the usual way, as long as only the last one requires an argument, i.e. "-ref 4 -l6" will work.
All page numbers are counted from the start of the file. They do not necessarily correspond to the logical number printed on each page. If no "-o" or "-e" option is given, both odd and even pages will be printed (you can also specify "-oe").
PSPRINT recognizes the various parts of the document by special tags, which are postcript comments embedded in the document. The default values used by PSPRINT worked with almost every PostScript file we have encountered so far, but in the unlikely case that you get some non-standard PostScript, you can specify the tags to be used with the following options:
-tp<tag> | Use <tag> as the mark for a new page (default: %%Page:) |
-tb<tag> | Use <tag> as the mark for the beginning of an embedded document (default: %%BeginDocument) |
-te<tag> | Use <tag> as the mark for the end of document (default: %%EndDocument) |
The only case where we needed this option is for one file that used "%%Trailer" as the end tag, instead of "%%EndDocument". A symptom of an incorrect end tag is that the printer stays busy after printing the last page, and, after a while, complains that the document timed-out.
If you have Tcl/Tk installed and don't like command lines, the psprint.tcl script can be used to provide a more user-friendly interface. Here is what it looks like:
You can start the script with the name of the PostScript file to print, in which case it will appear in the "File" input window. This makes it great to define PSPRINT as the default printing utility for .ps files! Note the presence of the "view" button, wich allows you to run your favorite editor(s) (or even GhostScript) on the input file. If you provide several viewers, you'll get a list to select from.
Depending on where you installed PSPRINT, the viewer(s) you want to access, your path, and your system, you may have to edit the values of some variables in the script. The corresponding assignements are located as the first statements in the script, and there are comments to provide you with the necessary information.
The "tags" button allows you to chose the tags used by PSPRINT to recognize the parts of the document for this file only.
If you found this program useful...
If you think that getting it from us saved you some time...
If it showed you some usages of Ada that you didn't think about...
Maybe you should consider using Adalog's consulting and training services !