没有 ghostscript 的 PDF 到图像转换器

Pdf to image converter without ghostscript

我正在寻找一个 dotnet/nodejs 库来将 pdf 转换为图像(用作缩略图)。我知道已经有很多关于这个主题的讨论,但大多数都使用 ghost 脚本,我不能使用它,因为它是许可条款 (GNU GPL)。

也有一些在线服务,但 pdf 是机密文件,所以我无权使用它们。

我正在寻找 MIT 或 Apache 许可证或者不介意 API 的付费版本。有人用过或知道这样的 library/API 吗?

看看这个:

http://code.msdn.microsoft.com/WindowsAPICodePack

您可以调用ShellObject.FromParsingName("C:\somefolder\somefile.pdf").

看看Docotic.Pdf library。它不是免费的,但很好。并且不需要您安装任何带有病毒许可证的命令行工具。

这是缩略图生成器的示例代码。

using (Stream output = new MemoryStream())
{
    using (PdfDocument pdf = new PdfDocument(@"input.pdf"))
    {
        PdfDrawOptions options = PdfDrawOptions.CreateFitSize(new PdfSize(200, 200), false);
        options.BackgroundColor = new PdfGrayColor(100);
        pdf.Pages[0].Save(output, options);
    }
}

我们的网站上提供了 drawing and printing of PDFs 的更多示例。

免责声明:我是该库的开发者之一。

Gnostice PDFOne .NET 有一个 saveAsImage 方法,您可以使用该方法将 PDF 页面内容保存为光栅图像格式,例如 JPEG、BMP、TIFF 或 PNG。

如果您想要矢量输出,请使用获取图元文件对象的 getPageMetafile 方法。但是,.NET 图元文件 class 不会保存到 EMF/WMF。您将需要使用一些非托管调用,如以下所述: http://www.gnostice.com/nl_article.asp?id=201&t=How_To_Convert_PDF_To_Image_Formats_In_NET

免责声明:我为 Gnostice 工作。