PDF格式转换为图像,而无需使用DLL的Ghostscript [英] Convert PDF to Image without using Ghostscript DLL

查看:827
本文介绍了PDF格式转换为图像,而无需使用DLL的Ghostscript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么办法,我可以HTML文档(文件中未URL)转换为图片或PDF图像?

Is there any way, I can convert HTML Document (file not URL) to Image, or PDF to image?

我能够做到以上使用Ghostscript的DLL,有没有其他办法,我可以做到这一点,而不使用的Ghostscript DLL?

I am able to do the above using Ghostscript DLL , Is there any other way , I can do it, without using the Ghostscript DLL?

我开发一个C#Windows应用程序。

I am developing a C# Windows Application.

推荐答案

使用 LibPdf ,对PDF格式的图像转换

Use LibPdf, for PDF to Image conversion

LibPdf 的库可转换的PDF文件转换为图像。支持的图片格式有PNG和BMP,但你可以很容易地添加更多。

LibPdf library converts converts PDF file to an image. Supported image formats are PNG and BMP, but you can easily add more.

用法示例:

using (FileStream file = File.OpenRead(@"..\path\to\pdf\file.pdf")) // in file
{
    var bytes = new byte[file.Length];
    file.Read(bytes, 0, bytes.Length);
    using (var pdf = new LibPdf(bytes))
    {
        byte[] pngBytes = pdf.GetImage(0,ImageType.PNG); // image type
        using (var outFile = File.Create(@"..\path\to\pdf\file.png")) // out file
        {
            outFile.Write(pngBytes, 0, pngBytes.Length);
        }
    }
}

ImageMagick的 ,你也应该看看这个免费的,功能强大的工具。这是能够做到你想要什么,并且还提供了一些.NET绑定(以及绑定到其他几种语言)。

ImageMagick, you should also look at this freely available and powerful tool. It's capable of doing what you want and also provides some .NET bindings (as well as bindings to several other languages).

在最简单的形式,它就像写一个命令

In its simplest form, it's just like writing a command

convert file.pdf imagefile.png

这篇关于PDF格式转换为图像,而无需使用DLL的Ghostscript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆