Validating Postscript without trying to print it?

Storing data in Postscript in my application leads to a Postscript file that I can view without problems in GhostView, but when I try to print it, the printer cannot print it because it seems to be invalid.

Is there a way to check / find errors in Postscript files without sending them to the printer? Some kind of Java API / library would be preferable, but a program that does the same will be fine too.


Edit # 1 : no I don’t know why it is invalid and not even necessary if it is invalid, but would like to check it outside of ghostview or find out what happens when it cannot print.


Answer : well, using the ps2ps trick, I was able to see the result that Postscript does, and check the difference there. The difference was that I was not allowed to have a decimal number for the width or height of the images in Postscript, but rather only integers. So I still haven't found a way to check, but this way was good enough for my problem. Thanks.

+6
java validation postscript ghostscript
source share
3 answers

If you see it on ghostview, it means that ghostscript can analyze it.

So, one trick you could try to print (but not validate) was to use the ghostscript postscript output mode (there is a wrapper named ps2ps for it that basically adds -sDEVICE=pswrite ; also ps2ps2 , which uses -sDEVICE=ps2write ).

+3
source share

Whenever I need to check a PostScript file using Ghostscript without actually viewing its images with images, I use the "nullpage" device:

 gswin32c ^ -sDEVICE=nullpage ^ -dNOPAUSE ^ -dBATCH ^ c:/path/to/file/to/be/validated.pdf-or-ps ^ 1>validated.stdout ^ 2>validated.stderr 

In the event of a problem, the non-zero set %errorlevel% will be installed, and the validated.stderr log file will contain all the messages that Ghostscript pulls out during rendering.

+7
source share

Do you know why it is not valid?

My suggestion was to pass it to Ghostscript / Ghostvoiew, but given that Ghostview can view it, it would seem that at least some interpreters consider this to be Postscript.

Thus, it can be something specific for your printer - either it is picky about something in PS that allows Ghostscript, or access to something that does not exist on your printer (possibly in the file system) or exceeds some memory limit, or ...

The fact is that this may not be an erroneous PS program, and therefore the library / API for checking it may not help

Edit: print any of these? You tried the printer from another manufacturer (or the Postscript interpreter provider, one way or another). Does Ghostview provide / log any warnings or errors?

Where (which application) comes from the document?

Can you create other instances of the document? (e.g. really plain / empty to see if this also leads to errors)

If there is no API that provides access to a specific interpreter that is used in your printer, I think that you test it on another PS interpreter (Ghostscript).

Since there are not many PS clones in the world, gaining access to a base other than GS will probably not be easy.

Edit2: this link (if the information is pretty old) contains information on how to get additional information from your printer about the error: http://www.quite.com/ps/errors.htm

+4
source share

All Articles