Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!mips!apple!motcsd!starnet!mzellers From: mzellers@starnet.uucp (Mark Zellers) Newsgroups: comp.lang.postscript Subject: Re: "Take out" a postion of a PS file? Keywords: Postscript Message-ID: <1991Jun6.164938.24218@starnet.uucp> Date: 6 Jun 91 16:49:38 GMT References: <.675678144@dutepp1> <1991Jun2.051004.11517@chinacat.unicom.com> Reply-To: mzellers@starnet.UUCP (Mark Zellers) Organization: Starnet-Public Access UNIX-Los Altos,CA 415-949-3133, login:info Lines: 33 In article <1991Jun2.051004.11517@chinacat.unicom.com> woody@chinacat.unicom.com (Woody Baker @ Eagle Signal) writes: >In article <.675678144@dutepp1> luo@dutepp1.et.tudelft.nl (Jian Luo) writes: >> >>Somebody has developed such a utility? For example, this should work like: >>ps2ps -f5 -t10 input.file, output.file >>which will put the pages 5 to 10 to the output file (Postscript too). > >As has been pointed out numerous times, this is more than just a trivial >problem. Since keywords can be redefined, and aliases created for them, >it becomes almost impossible to determine where a page ends. The best solution >to this problem, is an analysis of the output file, looking through the prolog >for the end of page command that it uses. (create a couple of single line >pages) and then once you have found that, find the start of the page code >the same way. Then write a routine to scan the file, locating the start of >page and end of page to isolate each page. There is another alternative, which might be a bit simpler. What you could do is redefine the "showpage" operator such that it would be disabled except when printing certain pages. Of course, you might have problems if the file contained the showpage command within the scope of a bind operator. One solution to that would be a simple SED script that would change all the showpages -> newshowpage and define newshowpage appropriately. As for keeping track of the current page number (without getting hosed by the file's saves and restores, you could perhaps keep it at the very bottom of the stack (provided the PostScript file you are printing does not do evil things like clear the stack and whatnot). Of course, things are even easier if the file is EPS, since there should be page markers embedded in the file in the form of structuring comments. Mark H. Zellers marc.com!bwayne!mark