I need to determine document page information from a postscript or a pcl file. Preferably in Java, but Ghostscript/Ghostpcl is as good as well.
What I tried to get the following info:
Page color
This can be achieved with ghostscript/ghostpcl using the device called inkcov.
PostScript
gswin64c.exe -dNOPAUSE -dBATCH -sDEVICE=inkcov -o- input.ps
PCL6
gpcl6win64 -dNOPAUSE -dBATCH -sDEVICE=inkcov -o- input.pcl
Page size
There is a device called bbox which gives me the boundary box per page for PostScript or PCL6 documents
PostScript
gswin64c.exe -dNOPAUSE -dBATCH -sDEVICE=bbox -o- input.ps
PCL6
gpcl6win64 -dNOPAUSE -dBATCH -sDEVICE=bbox -o- input.pcl
But in the end the boundary box is an inaccurate approximation for the page size. I checked the following post, but the solution seems not to work with my ghostscript version 9.5 Getting the page sizes of a PostScript document