GhostScript 'PDF to Image' 生成空白图像文件

GhostScript 'PDF to Image' makes blank image file

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

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

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

GhostscriptVersionInfo _lastInstalledVersion = null;
private GhostscriptRasterizer _rasterizer = null;
int dpi = 100;
string inputPdfPath = @"F:\pdf5.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 Icon,Magik.NET报错。(都比GhostScript差。)

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

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

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