【问题标题】:ghostscript convert pdf to pcl with wrong orientationGhostscript将pdf转换为方向错误的pcl
【发布时间】:2014-06-03 10:08:55
【问题描述】:

我在尝试使用 Ghostscript 将 pdf 文档转换为 pcl 文档时遇到问题。

原始 pdf 文档是横向的,因此 pcl 也应该是横向的。尽管如此,在 Windows 中使用 Ghostscript 9.14 并具有以下命令功能:

gswin32 -dNOPAUSE -dBATCH -sDEVICE=ljet4 -dSAFER -dAutoRotatePages=/NONE -sPAPERSIZE=a4 -sOutputFile=./convert_windows.pcl ./duplicate_windows.pdf

Ubuntu Linux 内核版本 3.2.0-40-generic 64 位(但使用 Ghostscript 9.05)中的相同命令会导致大小为 A3 而不是 A4 的错误定向 pcl 文件作为原始文件。

原始 pdf 文件包含 windows 字体“arial”,在 linux 中也应该可用。软件包“msttorcefonts”安装在 linux 上。这是 Ghostscript 字体图的简短摘录:

cat /usr/share/ghostscript/9.05/Resource/Init/Fontmap.GS

给予:

% This font, and only this font among the Hershey fonts, uses
% the SymbolEncoding.

/Hershey-Symbol                         (hrsyr.gsf)     ;       % 5066567

/Arial                                  /ArialMT                ;
/Arial,Bold                             /Arial-BoldMT           ;
/Arial,Italic                           /Arial-ItalicMT         ;
/Arial,BoldItalic                       /Arial-BoldItalicMT     ;

以下清单显示了 linux 命令行的输出,与 windows Ghostscript 控制台的输出相同!

GPL Ghostscript 9.05 (2012-02-08)
Copyright (C) 2010 Artifex Software, Inc.  All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Processing pages 1 through 2.
Page 1
Loading NimbusMonL-Bold font from /usr/share/fonts/type1/gsfonts/n022004l.pfb... 3627296 2211468 1767360 473754 3 done.
Loading NimbusSanL-Bold font from /usr/share/fonts/type1/gsfonts/n019004l.pfb... 3668288 2319461 1807728 497748 3 done.
Loading NimbusSanL-Regu font from /usr/share/fonts/type1/gsfonts/n019003l.pfb... 3800176 2466391 1827912 512832 3 done.
Loading NimbusMonL-Regu font from /usr/share/fonts/type1/gsfonts/n022003l.pfb... 3964224 2617715 1969200 654805 3 done.
Page 2

我已经尝试了几个 Ghostscript 的选项,比如

-dFIXEDMEDIA
-dNORAGEPAGESIZE

和其他人。

将 pdf 文档转换为 ps 时,两种环境的结果是相同的。

有没有人遇到过这个问题或想法?

在此先感谢您的问候

【问题讨论】:

    标签: windows orientation ghostscript printer-control-language


    【解决方案1】:

    如果没有看到原始 PDF 文件,任何人都不太可能提供帮助,因此我建议您打开错误报告并将 PDF 文件附在此处。

    一些观察:

    -dAutoRotatePages 仅在创建 PDF 文件时有效,在解释文件时无效。

    开关 -dFIXMEDIA 应该是 -dFIXEDMEDIA,同样 NORAGEPAGESIZE 应该是 NORANGEPAGESIZE

    【讨论】:

    • 您好,感谢您的回答!是的,它是 -dFIXEDMEDIA,这是我的描述中的错误。
    【解决方案2】:

    这可能是一个可能的解决方案,适用于我的情况。 前提条件:Ghostscript 8.6.0 或更高版本!

    不是使用 gs 命令,而是使用 gs 包装器 pdf2ps 将 pdf 转换为 ps,它是 ghostscript 包的一部分:

    pdf2ps input.pdf output.ps
    

    但是:对于横向 pdf 文档,这仅适用于 8.60 或更高版本!否则横向文档将以纵向打印。

    使用以下命令将 pdf 转换为 pcl 对我有用:

    gs -q -dNOPAUSE -dBATCH -dSAFER -sDEVICE=ljet4 -sPAPERSIZE=a4 -sOutputFile=output.pcl -c "<< /InputAttributes << currentpagedevice /InputAttributes get { pop null } forall >> dup 0 << /PageSize [ 595 842 ] >> put >> setpagedevice" save pop -f input.pdf
    

    但是: 此命令基于 ghostscript 的 Bug 错误 689919 的文档(请参阅 http://bugs.ghostscript.com/show_bug.cgi?id=689919),仅当您安装了 8.60 或更高版本时才适用于纵向文档。因为我可以批准三种不同的环境,所以这个命令从 8.60 版开始有效。我使用了 8.16、8.62 和 9.05 版本。

    对于版本 8.62 和 9.05 的 ghostscript,这两个命令都适用于 pdf --> ps 和 pdf --> pcl 用于横向和纵向。

    【讨论】:

      猜你喜欢
      • 2011-07-03
      • 1970-01-01
      • 2015-05-20
      • 1970-01-01
      • 2011-07-09
      • 2019-11-08
      • 1970-01-01
      • 1970-01-01
      • 2010-10-14
      相关资源
      最近更新 更多