PHP imagick出现PDF问题 [英] PHP imagick with PDF issue

查看:196
本文介绍了PHP imagick出现PDF问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将PDF的第一页转换为图像文件.

I am trying to convert the first page of a PDF to an image file.

我有以下代码:

$im = new imagick('/images/test.pdf[0]');

$im->setImageFormat("jpg");
$page=$im->queryFormats();
echo "<pre>";
 print_r ($page);
echo "</pre>";

但是,我收到一条错误消息:

However, I get an error message saying:

Uncaught exception 'ImagickException' with message 'unable to open image

如果我更改:

$im = new imagick('/images/test.pdf[0]');

收件人:

$im = new imagick('/images/test.pdf');

我收到以下错误:

Uncaught exception 'ImagickException' with message 'Unable to read the file

我确定我的PDF路径正确,并且不确定如何解决此问题.谁能帮我这个忙吗?

I am sure the path to my PDF is correct and I'm not sure how to solve this. Can anyone help me out with this?

推荐答案

驱动器的根目录中是否有/images文件夹?请记住-imagick在PHP中运行,并且不知道您网站的URL空间结构是什么.您需要使用本地文件系统路径,例如

Do you have a /images folder in the ROOT of your drive? Remember - imagick is running within PHP and has no clue whatsoever what your site's URL-space structure is. You need to use the local file system path, e.g.

$im = new imagick('/path/to/example.com/html/images/test.pdf[0]');

这篇关于PHP imagick出现PDF问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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