I have a process to convert PDFs to PCL for automatic printing, but the quality is not good. Here's the test code that I have to show the poor quality:
gs -dBATCH -dNOPAUSE -q -sDEVICE=ljetplus -sOutputFile=grayscaletest.pcl -f grayscaletest.pdf
Here's what grayscaletest.pdf looks like before: And what grayscaletest.pcl looks like after:
I realize that it's doing this because of the device ljetplus, but that's the only device that I have found that will work for what I need. So, I want to convert all grays to black. I have tried the solution found here (GitHub) and here (superuser), but it did nothing. I can't even get this solution to work from PDF to PDF, it just stays the same.
GhostScript version is 9.06. Any help either improving the quality using ljetplus, or just converting everything to black and white without grayscale would be appreciated.
Well that's a black and white output, its been halftoned to produce 1-bit output from 8-bit input. No matter what you do, if your device only supports 1-bit output then you're always going to have to apply some kind of screening to represent grayscale or colour.
You don't give any clues as to why ljetplus is the only device you can use. Without knowing why its going to be hard to offer any concrete advice.
However....
First thing is to update your version of Ghostscript. The current version is 9.27, the one you are using is > 6 years old.
The screen looks coarse, the default resolution of the ljetplus is 300 dpi, is that correct for your printer ? If not you will want to set a higher resolution, it'll give you a finer screen. Most PCL devices are 600 dpi or better these days.
Assuming that your PDF file doesn't contain a halftone, the next thing to do is to experiment with the screening options available in Ghostscript. You could try the switches described here:
https://www.ghostscript.com/doc/9.27/Use.htm#Rendering_parameters
You can also use PostScript screening, but that's harder to implement unless you understand PostScript already. There are also stochastic screens available in Ghostscript but not knowing how comfortable you are with PostScript I don't want to go down that route.
Yyou could of course use Ghostscript to render to a high resolution bitmap, dither that to monochrome with image manipulation too of your choice and then output it back to PDF or PostScript, or an image format that Ghostscript has a program to read (eg viewpbm.ps in the ghostpdl/lib directory).
ImageMagick can probably do all the steps above for you, then once you have a monochrome input file you can simply run it through Ghostscript to get a PCL output file.