简体   繁体   English

PDF到图像-Magick ++

[英]PDF to Image - Magick++

I want to convert a pdf to a series of images using magick++. 我想使用magick ++将pdf转换为一系列图像。 I currently have this code: 我目前有以下代码:

Image  * img = new Image();
img->read(Tests+"finance-02-2007-multiples.pdf[0]");

Tests is a variable which contains the folder path. 测试是一个包含文件夹路径的变量。 The "[0]" means that I want the first page to read in an image. “ [0]”表示我要在图像中读取第一页。

However, this code snippet does not work. 但是,此代码段不起作用。 The exception "Magick::ErrorDelegate" appears. 出现异常“ Magick :: ErrorDelegate”。 I know that ImageMagick uses GhostScript to render the page. 我知道ImageMagick使用GhostScript渲染页面。 Can it be that i need to do something to enalbe GhostScript in ImageMagick first? 难道我需要做一些事情才能首先在ImageMagick中启用GhostScript吗?

Or has someone an ide how to get the code to work? 还是有人对如何使代码正常工作有想法?

Thanks so much! 非常感谢!

That error is telling you that cannot find GhostScript on your computer. 该错误告诉您在计算机上找不到GhostScript。

In order to read a PDF using Magick, you must have GhostScript installed. 为了使用Magick读取PDF,您必须安装GhostScript。 Magick++ has a (limited) internal support only for writing a pdf. Magick ++仅在编写pdf时才有(有限)内部支持。 It actually embeds an image in pdf. 它实际上将图像嵌入到pdf中。 The reason is that GhostScript is licenced as GPL and cannot be included in Magick, but fortunately can be used if installed by user :). 原因是GhostScript被许可为GPL,不能包含在Magick中,但幸运的是,如果由用户安装::可以使用。

Magick checks for a GhostScript via registry. Magick通过注册表检查GhostScript。 Make sure you have installed a verion of GhostScript and that installation has created one of the keys below in HKEY_CURRENT_USER or HKEY_LOCAL_MACHINE . 确保已安装GhostScript版本,并且该安装已在HKEY_CURRENT_USERHKEY_LOCAL_MACHINE中创建了以下密钥之一。

"SOFTWARE\\GPL Ghostscript", “ SOFTWARE \\ GPL Ghostscript”,

"SOFTWARE\\GNU Ghostscript", “ SOFTWARE \\ GNU Ghostscript”,

"SOFTWARE\\AFPL Ghostscript", “ SOFTWARE \\ AFPL Ghostscript”,

"SOFTWARE\\Aladdin Ghostscript" “软件\\阿拉丁Ghostscript”

Hope it helps 希望能帮助到你

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM