【问题标题】:GhostScript 'PDF to Image' makes blank image fileGhostScript 'PDF to Image' 制作空白图像文件
【发布时间】:2016-10-31 12:05:59
【问题描述】:

现在,我正在创建一个使用 C# WinForm 生成 pdf 缩略图的程序。 所以我选择使用 GhostScript 来获取 PDF Thumbnail。 但是,GhostScript 有时会创建空白图像(一些 pdf 文件)。 (只有部分 Pdf 文件转换为空白图像文件,其他正确转换为图像文件。) 这个空白图片文件的图片大小与pdf相同,但它只是白色图片。

我发现当我用 PDF Reader 打开这些文件时,这些 PDF 文件在短时间内显示为空白页。 所以我希望这些 pdf 文件有一些特殊的选项(比如保护??)并且 GhostScript 也需要一些特殊的选项来正确地隐藏它。

我正在使用 GhostScript.NET(https://ghostscriptnet.codeplex.com),我的代码如下。

GhostscriptVersionInfo _lastInstalledVersion = null;
private GhostscriptRasterizer _rasterizer = null;
int dpi = 100;
string inputPdfPath = @"F:\pdf\155.pdf";
_lastInstalledVersion = GhostscriptVersionInfo.GetLastInstalledVersion(GhostscriptLicense.GPL |  GhostscriptLicense.AFPL, GhostscriptLicense.GPL);
_rasterizer = new GhostscriptRasterizer();
_rasterizer.Open(inputPdfPath, _lastInstalledVersion, false);
Image img = _rasterizer.GetPage(dpi, dpi, 1);
_rasterizer.Close();

请帮我解决这个问题...

另外,我尝试使用 Winapi CodePack,Magik.NET。 但是,Winapi创建PDF图标,Magik.NET出错。(两者都比GhostScript差。)

【问题讨论】:

  • adobe acrobat 对显示为空白的 pdf 文件说了什么?您不能指望我们猜测您的 pdf 是否受到保护?
  • 或者换个说法:你怎么确定 pdf 不只是空白?
  • 尝试直接从命令行使用 Ghostscript,并查看 stdout 反向通道,很可能您的 PDF 文件已损坏。发布一个典型示例会很有帮助,其他消费者也不喜欢这些文件的事实表明 PDF 文件本身就是一个问题。您还应该能够从 Ghostscript.NET 获得反向通道,但我无法帮助您,因为它不是 Ghostscript 的一部分。

标签: pdf thumbnails ghostscript


【解决方案1】:

如果您最近使用 PDF 阅读器打开/查看的 PDF 文件出现空白图像,那么最可能的问题是这些文件只是被 PDF 阅读器应用程序阻止了。并且 Ghostscript 在尝试读取/访问这些 PDF 文件并生成空白图像时静默失败。

我建议避免使用 PDF Reader 软件打开/阅读这些 PDF 文件,以确保它们仅供 Ghostrscript 使用。

【讨论】:

    【解决方案2】:

    谢谢肯斯! 它可能是由 GhostScript.NET 引起的。 我尝试使用原始的 GhostScript,效果很好。

    【讨论】:

      猜你喜欢
      • 2013-12-22
      • 2021-12-17
      • 2019-10-14
      • 1970-01-01
      • 1970-01-01
      • 2021-07-11
      • 2017-08-05
      • 1970-01-01
      • 2017-06-28
      相关资源
      最近更新 更多