Thread View: comp.lang.postscript
8 messages
8 total messages
Started by Helge O. Aarstein
Tue, 03 Nov 1992 08:35
How do I recognize postscript from a file
Author: Helge O. Aarstein
Date: Tue, 03 Nov 1992 08:35
Date: Tue, 03 Nov 1992 08:35
10 lines
977 bytes
977 bytes
We are trying to make a filter for the lp-command to reject non-postscript files. But, there is a problem: How can I be sure that the file contains postscript- code? -- Helge O Aarstein | | helgeaa at Sverresgt. 8 |---------------------------------| viper.edb.tih.no N-7013 Trondheim | You will still be here tomorrow | Phone: 07-502782 | - but your dreams may not. (CS) |
Re: How do I recognize postscript from a file
Author: Peter Weingartner
Date: Tue, 03 Nov 1992 11:14
Date: Tue, 03 Nov 1992 11:14
27 lines
2013 bytes
2013 bytes
In article <1992Nov3.083527.20756@ugle.unit.no> helgeaa@colargol (Helge O. Aarstein) writes: We are trying to make a filter for the lp-command to reject non-postscript files. But, there is a problem: How can I be sure that the file contains postscript- code? The simplest way is probably to check to see that the first two characters of the file are '%!'. Most programs that generate PostScript code will at least those two characters at the begining. The only time I have seen them left out is in hand-written code that was just to test. This method is used by the lpr I have used to distinquish a PostScript file from another kind it might know how to print. Of course, '%!' is only a comment, so it can be left out without affecting the execution of the program, so this method is not fool-proof. Since most programs include that code, though, it is reasonably good (and simple!). If you wanted to be really sure, I suppose you could write a grammar checker that verified PostScript-ness, but such a thing would be complicated and would need to be updated with future revisions. So, I recommend the '%!'. --Peter -- "The brilliant Cerebron, attacking the problem analytically, discovered three distinct kinds of dragon: the mythical, the chimerical, and the purely hypothetical. They were all, one might say, nonexistent, but each nonexistsed in an entirely different way." -- Standislaw Lem _Cyberiad_
Re: How do I recognize postscript from a file
Author: Vidiot
Date: Wed, 04 Nov 1992 04:01
Date: Wed, 04 Nov 1992 04:01
17 lines
1188 bytes
1188 bytes
In article <1992Nov3.083527.20756@ugle.unit.no> helgeaa@colargol (Helge O. Aarstein) writes:
<We are trying to make a filter for the lp-command to reject
<non-postscript files. But, there is a problem:
< How can I be sure that the file contains postscript-
< code?
The best is to look for these two characters at the beginning of the file:
%!
While that doesn't mean that what follows is PostScript, that is the standard
that all printer filters are looking for.
--
harvard\ spool.cs.wisc.edu!astroatc!vidiot!brown
Vidiot ucbvax!uwvax..........!astroatc!vidiot!brown
rutgers/ INTERNET:vidiot!brown%astroatc.UUCP@spool.cs.wisc.edu
brown@wi.extrel.com
Re: How do I recognize postscript from a file
Author: Arto V. Viitanen
Date: Wed, 04 Nov 1992 07:54
Date: Wed, 04 Nov 1992 07:54
23 lines
1736 bytes
1736 bytes
>>>>> On 3 Nov 92 11:14:48 GMT, eweingar@loanshark.cs.indiana.edu (Peter Weingartner) said: Peter> In article <1992Nov3.083527.20756@ugle.unit.no> helgeaa@colargol (Helge O. Aarstein) writes: Peter> We are trying to make a filter for the lp-command to reject Peter> non-postscript files. But, there is a problem: Peter> How can I be sure that the file contains postscript- Peter> code? Peter> The simplest way is probably to check to see that the first two Peter> characters of the file are '%!'. When printing from MS Windows to Postscript file, the file (if you don't make it not to) starts with characters ^D%! (i.e. control-D, %, !). In a way, this is right way, since ^D means end-of-job to a Postscript printer, so previous job is stopped. I only thought to say this, since lpr-filter on our department checks the %! -pair, and several times Postscript document has been run through Ascii-to-PS filter. -- Arto V. Viitanen email: av@uta.fi University Of Tampere, av@cs.uta.fi Finland
Re: How do I recognize postscript from a file
Author: Paul Gilmartin
Date: Wed, 04 Nov 1992 08:05
Date: Wed, 04 Nov 1992 08:05
12 lines
937 bytes
937 bytes
In article <1992Nov3.083527.20756@ugle.unit.no> helgeaa@colargol (Helge O. Aarstein) writes: >We are trying to make a filter for the lp-command to reject >non-postscript files. But, there is a problem: > How can I be sure that the file contains postscript- > code? Most PostScript files start with the characters "%!". (Your Mileage May Vary), gil
Re: How do I recognize postscript from a file
Author: Chris Lewis
Date: Fri, 06 Nov 1992 02:31
Date: Fri, 06 Nov 1992 02:31
42 lines
2661 bytes
2661 bytes
In article <AV.92Nov4095431@kielo.uta.fi> av@uta.fi (Arto V. Viitanen) writes: >When printing from MS Windows to Postscript file, the file (if you don't >make it not to) starts with characters ^D%! (i.e. control-D, %, !). In a way, >this is right way, since ^D means end-of-job to a Postscript printer, so >previous job is stopped. I only thought to say this, since lpr-filter on our >department checks the %! -pair, and several times Postscript document has >been run through Ascii-to-PS filter. The correct way to handle this is for the application to *not* append or prepend ^D's, and let the spooler handle it. This is because the spooler is the most likely to know whether the printer actually needs it or not. Ie: PostScript printers connected by network protocols (AppleTalk, TCP/IP etc.) do *not* need it. Other non-Adobe PostScript implementations also get indigestion from ^D - ie: imagens (Ultrascript). If the spooler does it, there's no need to emit ^Ds to the printer before the job because it knows that the previous job had one at the end (unless something crashed). If the spooler does emit leading ^D's, you want all applications to have it. If the spooler does it, then this stuff doesn't interfere with anciliary spooler facilities (automatic ascii sensing, font includers, page reversers etc.) - they don't have to be mangled to accept every different application foulup of the Adobe DSC standard. And you don't have to muck around so much to use these package's output as EPS. If you really want this to work properly, you should manually strip all ^Ds from application output, and implement it in the spooler. If I recall correctly, Adobe's heuristic is something like: if you're sending it to a device, and you know the printer needs ^D, append the ^D, otherwise (pipe, file etc.) don't. MS Windows use of ^D is a kludge workaround for somebody else's botch. A bad kludge. Because the output of MS Windows ain't PostScript because of it. -- Chris Lewis; clewis@ferret.ocunix.on.ca; Phone: Canada 613 832-0541 Psroff 3.0 info: psroff-request@ferret.ocunix.on.ca Ferret list: ferret-request@ferret.ocunix.on.ca
Re: How do I recognize postscript from a file
Author: Vidiot
Date: Sat, 07 Nov 1992 03:27
Date: Sat, 07 Nov 1992 03:27
33 lines
2241 bytes
2241 bytes
In article <AV.92Nov4095431@kielo.uta.fi> av@uta.fi (Arto V. Viitanen) writes:
<>>>>> On 3 Nov 92 11:14:48 GMT, eweingar@loanshark.cs.indiana.edu (Peter Weingartner) said:
<
<Peter> In article <1992Nov3.083527.20756@ugle.unit.no> helgeaa@colargol (Helge O. Aarstein) writes:
<
<Peter> We are trying to make a filter for the lp-command to reject
<Peter> non-postscript files. But, there is a problem:
<Peter> How can I be sure that the file contains postscript-
<Peter> code?
<
<Peter> The simplest way is probably to check to see that the first two
<Peter> characters of the file are '%!'.
<
<When printing from MS Windows to Postscript file, the file (if you don't
<make it not to) starts with characters ^D%! (i.e. control-D, %, !). In a way,
<this is right way, since ^D means end-of-job to a Postscript printer, so
<previous job is stopped. I only thought to say this, since lpr-filter on our
<department checks the %! -pair, and several times Postscript document has
<been run through Ascii-to-PS filter.
Starting with a ^D is wrong pure and simple. DOS machines have been doing it
wrong for a long time. Sending a ^D to the printer at the end of the job is
fine, but not before the job.
Makes it rough on printer spoolers looking for the correct %! and it also makes
it tough when trying to cat PostScript files together as one job.
I consider it wrong, plain and simple.
--
harvard\ spool.cs.wisc.edu!astroatc!vidiot!brown
Vidiot ucbvax!uwvax..........!astroatc!vidiot!brown
rutgers/ INTERNET:vidiot!brown%astroatc.UUCP@spool.cs.wisc.edu
brown@wi.extrel.com
Re: How do I recognize postscript from a file
Author: Dick Dunn
Date: Sat, 07 Nov 1992 06:55
Date: Sat, 07 Nov 1992 06:55
31 lines
2027 bytes
2027 bytes
av@uta.fi (Arto V. Viitanen) writes, in answer to suggestion to check for "%!": >When printing from MS Windows to Postscript file, the file (if you don't >make it not to) starts with characters ^D%! (i.e. control-D, %, !)... Yes. This is a bug. A program looking for the beginning of a PostScript file should look for ^D%! - but NOT because it is right; rather, because good program design says "be generous in what you accept, conservative in what you generate". >...In a way, >this is right way, since ^D means end-of-job to a Postscript printer, so >previous job is stopped... No, it is wrong. An application generating PostScript has no business with a "previous job". Job boundaries are simply not the province of applica- tions. It is easy to understand why an application writer might think "well, just to be safe, I'll generate an end-of-job marker at the beginning of the job." But it's not safe; more to the point it's not innocuous. An empty job may not be a "no-op". Adobe has taken some pains to discourage tossing in gratuitous ^D for some time now. In summary: If you're trying to recognize a file containing PostScript, look for %! or ^D%! - but you might want to complain to whoever generates files with end-of-job at beginning-of-file that they are doing you a dis- service and helping almost nobody. -- Dick Dunn rcd@raven.eklektix.com -or- raven!rcd Boulder, Colorado ...Simpler is better.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads