我有一个 PHP 脚本,它使用 PHP Imagick 从 PDF 页面生成图像。在其中我使用 annotateImage 函数在图像顶部写入一条数据并将其作为输出。这最近在一些被选中的 PDF 图像上失败了。我的意思是,当一个特定的 PDF 作为该程序的输入时,annotateImage 函数无法在许多其他 PDF 文件上表现良好的地方写入数据......
这是以下代码,它在循环上运行以生成此图像...
$imagick->setResolution(200,200);
$imagick->readImage('files/pdffile.pdf[1]');
$imagick->annotateImage($draw_small, 1250, 100, 10, 'Hello header');
$imagick = $imagick->flattenImages();
$file = fopen("/outputfile.jpg", 'w+');
chmod($folder_in_action."/outputfile.jpg", 0755);
fclose($file);
$imagick->writeImage('/outputfile.jpg');
$imagick->clear();
该代码运行良好,并在文件夹中获取确切的 PDF 页面作为图像,但 annotateImage 不适用于特定的 PDF 文件,因此输出没有“Hello header”消息。
相同的代码在大多数 PDF 上都能完美运行,我得到特定的 PDF 页面,上面写着“Hello header”消息作为图像......
所以无法猜测可能是什么问题......
不允许 annotateImage 写入文本的 PDF 文件在这里:
http://wikisend.com/download/143652/notworking.pdf
正在工作的PDF(通常大多数pdf文件都可以正常工作......)