Reputation: 138
I'm using GhostPrint to print a very simple PDF file. It's just one page with 2 words, with two different background colours. The PDF file is 86KB. When I try to print it using GhostScript it creates a printjob on 17.5MB or 95MB, depending on my BitsPerPixel. Since I want it to be in color, I've tried 4 BitsPerPixel and 24 BitsPerPixel. If I print the same file using Adobe Reader, the printjob is around 200KB, and I see no difference in the quality of the print. I'm printing through a C# Console Application using the following code:
string printerName = "Konica Minolta PS Color Laser Class Driver";
string ghostScriptPath = "C:\\Program Files (x86)\\gs\\gs9.19\\bin\\gswin32c.exe";
string pdfFilePath = "C:\\Users\\TestUser\\Documents\\ColorTest.pdf";
arguments += " -dPrinted -dBATCH -dNOPAUSE -dNOSAFER -q -BitsPerPixel=24 -dNumCopies=1 -sDEVICE=mswinpr2 -sOutputFile=\"\\\\spool\\" + printerName + "\" \"" + pdfFilePath + "\" ";
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.Arguments = arguments;
startInfo.FileName = ghostScriptPath;
startInfo.UseShellExecute = false;
startInfo.RedirectStandardError = true;
startInfo.RedirectStandardOutput = true;
Process process = Process.Start(startInfo);
Console.WriteLine(process.StandardError.ReadToEnd() + process.StandardOutput.ReadToEnd());
process.WaitForExit(30000);
if (process.HasExited == false)
{
process.Kill();
}
Console.WriteLine("Exitcode: " + process.ExitCode);
Console.ReadLine();
How can I reduce the filesize without losing too much quality? I hope its possible since Adobe Reader can do it.
PS. I know about using Adobe Reader in with the window hidden etc. but that will not work in my use-case, since i need to be able to specify which printer to use, duplex/simplex, color/grey and number of copies.
Upvotes: 1
Views: 1502
Reputation: 31199
The mswinpr2 device works by rendering the input to a bitmap at the resolution and colour depth of the selected printer. PDF of course is (at least potentially) a vector format and so can hold a much more compact representation.
There is no way in the general case to print from Ghostscript to a Windows printer and not have the content rendered, so there is no way to create a smaller file. Of course, since you are printing to a PostScript printer (guessing from your printer name) you could use the ps2write device instead of mswinpr2. Since PostScript is also a vector format it is more compact. But then you won't be using the mswinpr2 device and you will have to dispatch the resulting PostScript file to the printer yourself.
I'm slightly surprised you find the size of an intermediate spool file to be a problem. You could always send the output directly to the printer instead of spooling it using the %printer% syntax.
Upvotes: 2