Search code examples
javavalidationpostscriptghostscript

Validating a Postscript without trying to print it?


Saving data to Postscript in my app results in a Postscript file which I can view without issues in GhostView, but when I try to print it, the printer isn't able to print it because it seems to be invalid.

Is there a way to validate / find errors in Postscript files without actually sending it to a printer? Preferred would be some kind of Java API/library, but a program which does the same would be fine as well.


Edit #1 : no I don't know why it's invalid, nor even necessarily if it's invalid, but would like to be able to validate it outside of ghostview, or figure out what's going on when it can't print.


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


Solution

  • If you can see it on ghostview, it means ghostscript can parse it.

    So, one trick you could try using to print (but not to actually validate) your file would be to use ghostscript's postscript output mode (there is a wrapper called ps2ps for it, which mainly adds -sDEVICE=pswrite; there is also ps2ps2 which uses -sDEVICE=ps2write).