【发布时间】:2016-04-26 08:02:46
【问题描述】:
我正在使用 GhostPrint 打印一个非常简单的 PDF 文件。它只是一页,有 2 个单词,有两种不同的背景颜色。 PDF 文件为 86KB。 当我尝试使用 GhostScript 打印它时,它会在 17.5MB 或 95MB 上创建一个打印作业,具体取决于我的 BitsPerPixel。因为我希望它是彩色的,所以我尝试了 4 BitsPerPixel 和 24 BitsPerPixel。如果我使用 Adobe Reader 打印相同的文件,打印作业大约为 200KB,并且我发现打印质量没有差异。 我正在使用以下代码通过 C# 控制台应用程序进行打印:
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();
如何在不损失太多质量的情况下减小文件大小?我希望它可能,因为 Adobe Reader 可以做到。
PS。我知道在隐藏窗口等情况下使用 Adobe Reader,但这在我的用例中不起作用,因为我需要能够指定要使用的打印机、双面/单面、颜色/灰色和份数。
【问题讨论】:
标签: c# pdf printing ghostscript