[Chapter 43] 43.23 psselect: Print Some Pages from a PostScript file
Author: Jerry Peek, Tim O'Reilly & Mike Loukides
Date: 1998-10-23T15:52:09Z

#

| Chapter 43 Printing |

## 43.23 psselect: Print Some Pages from a PostScript file

The psselect program allows you to take a PostScript file and select individual pages for printing. It's part of Angus Duggan's PSUtils collection, a group of utilities for working with PostScript files. psselect produces a second PostScript file, which you can print using lpr or lp (43.2) (if your printer handles PostScript). It's easy to use; in the simplest form, just type:

>     % psselect -p page-spec input output

where the page-spec is a comma-separated string of page numbers and/or ranges of page numbers separated by a dash. Pages are counted from 1 (the first page of the document), or prepend an underscore (`_`) to make a page number relative to the end of the document, counting backwards. psselect doesn't try to detect and decode any "page numbers" that may be part of your document. For example, to select pages 1 through 16 of the file book.ps, type:

>     % psselect -p1-16 book.ps first16.ps

Use -e to print only the even-numbered pages or -o to print the odd-numbered pages. (If you use -e or -o, -p is also required.) Add the -r option if you want to reverse the order in which pages are printed.

psselect only works on PostScript files that conform to the Adobe Document Structuring Conventions. I won't elaborate on those conventions, but I will say that PostScript files that obey these conventions are the exception, rather than the rule. Unfortunately, the PostScript language is entirely too flexible; it's impossible to write fully general programs for extracting pages (and the like) without processing the entire language.

Fortunately, Angus has written a few scripts that convert PostScript files generated by various word processors into a form that he can deal with. These filters are all written in the perl language (37.1); here's a quick summary of what's available:

Name | Function
--- | ---
fixdlsrps | Fix DviLaser/PS files
fixfmps | Fix FrameMaker files
fixmacps | Fix Macintosh files
fixpsditps | Fix TranScript psdit files
fixpspps | Fix PSPrint files
fixscribeps | Fix Scribe files
fixtpps | Fix Tpscript files
fixwfwps | Fix Word for Windows files
fixwpps | Fix WordPerfect files
fixwwps | Fix Windows Write files

So to get the odd-numbered pages of a document called fmdoc.ps, which was generated with FrameMaker, give this command:

>     % fixfmps < fmdoc.ps | psselect -o -p1- > oddpages.ps

- ML, JP, AD

43.22 Converting Text Files to PostScript |  | 43.24 Other PostScript Utilities