GhostScript无法正确地将PDF文件打印到真实打印机,但可以与PDFCreator一起使用

时间:2015-03-30 10:52:03

标签: c# pdf printing ghostscript pdfsharp

我正在尝试使用GhostScript打印PDF文件,并使用以下开关和有效的输入文件路径: -dPrinted -dNOPAUSE -dNoCancel -dNOPROMPT -dNOSAFER -sDEVICE=mswinpr2 -dFIXEDMEDIA -dPDFFitPage -sPAPERSIZE=a4 -sOutputFile=%printer%printerName

如果我使用PDFCreator,它可以正常工作并提供另一个输出pdf文件。但是当我使用真正的打印机时,图像全部搞砸了。

这是我正在尝试打印的文件: https://drive.google.com/file/d/0ByL_VDOdxc3MbmpocEo0Vnhhd2c/view?usp=sharing 这是扫描打印机的内容: https://drive.google.com/file/d/0B_KRzl3VVurjaTVIbkhkaUc0Y1E/view?usp=sharing

我正在尝试打印的PDF文件由PDFSharp呈现。 我在GS version 9.15 32-bit上使用Windows 8,而我使用的真正打印机是Brother Printer, model MFC-7840W。 此外,当我尝试打印我在谷歌上找到的真实打印机的通用样本PDF时,它运行正常。

有谁知道造成这种情况的原因是什么? 提前谢谢!

2 个答案:

答案 0 :(得分:1)

事实证明,PDF文件本身的软掩码存在问题。此问题已在GhostScript版本9.16中得到解决。

答案 1 :(得分:0)

我的一位同事刚刚提醒我,几个月前我们遇到了“可能”是一个相关的问题,并提出了一个解决方法,我相信,在这种情况下解决了这个问题。

mswinpr2设备包含注释:

/* This driver uses the printer default size and resolution and
 * ignores page size and resolution set using -gWIDTHxHEIGHT and
 * -rXxY.  You must still set the correct PageSize to get the
 * correct clipping path.
 * The code in win_pr2_getdc() does try to set the printer page
 * size from the PostScript PageSize, but it isn't working
 * reliably at the moment.
 *
 * This driver doesn't work with some Windows printer drivers.
 * The reason is unknown.  All printers to which I have access
 * work.
 *
 * rjl 1997-11-20
 */

重点是您必须设置PageSize(以使剪辑正确)并使用-g开关设置图像的宽度和高度(以像素为单位)并使用以下方法正确设置打印机的分辨率 - 河这可能需要一些实验.....

您还可以考虑使用gsprint,它是当前GSView的一部分。它有一个更新版本的印刷方法(由同一作者),据称是一种改进。