What causes the error **** Error: Invalid 0.0 horizontal text scaling given for Tz when running ghostscript and how do I solve it?

What causes the error **** Error: Invalid 0.0 horizontal text scaling given for Tz when running ghostscript and how do I solve it?

您好,我正在编写一个 java 应用程序,需要在保存为 pdf 的电气图纸上使用 ghostscript。部分绘图导致 ghostscript 打印错误信息:

**** Error: Invalid 0.0 horizontal text scaling given for Tz

我假设用于构建图纸并将其保存为 pdf 的原始应用程序没有正确遵循规范并创建了一些错误 pdf:s。 我使用的命令是:

gswin64c -sDEVICE=pdfwrite -dNOPAUSE -sOutputFile="output.pdf" "test.pdf"

java 应用程序中的命令 I 运行 有更多选项可以通过各种方式更改 pdf。

我曾尝试使用 PDFBox 简单地重新保存文件,希望它能在 运行ning ghostscript 之前自动修复任何问题。

我还尝试使用 ghostscript 使用 GS 设备将 pdf 保存为 ps 文件 ps2write:

gswin64c -sDEVICE=ps2write -dNOPAUSE -sOutputFile="output.ps" "test.pdf"

然后 运行在 ps 文件上使用 ghostscript 命令创建 pdf:

gswin64c -sDEVICE=pdfwrite -dNOPAUSE -sOutputFile="output.pdf" "output.ps"

这会创建一个在 运行ning ghostscript 时不输出错误的 pdf。 所以我可能会 运行ning ghostscript 两次来解决这个问题。但我想在这里了解其他人的想法,以及他们是否有更好的解决方案。

由于错误与文本缩放有关,我认为这可能是由于字体问题所致,因此我尝试在 运行ning ghostscript 时使用 fontmap 文件替换字体以查看它是否有效搭配其他字体效果更好。但这并没有帮助。

首先,我想了解有关错误消息及其抱怨原因的一些信息。 我还想要一些关于如何解决您不知道 pdf:s 格式如何的问题的建议,以及您可以做些什么来尝试解决 pdf 在 运行ning ghostscript 之前存在的任何问题.

谢谢!

在使用 ghostscript 之前,我最终使用 PDFBox 来保存 pdf。 PDFBox 能够修复 ghostscript 对 pdf 的任何问题。