如何在PHP中将PDF文档转换为预览图像? [英] How do I convert a PDF document to a preview image in PHP?
本文介绍了如何在PHP中将PDF文档转换为预览图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
将PDF文档的一部分呈现给图像文件需要哪些库,扩展等?
What libraries, extensions etc. would be required to render a portion of a PDF document to an image file?
我找到的大多数PHP PDF库都集中在创建PDF文档,但是有一种简单的方法可以将文档呈现为适合Web使用的图像格式吗?
Most PHP PDF libraries that I have found center around creating PDF documents, but is there a simple way to render a document to an image format suitable for web use?
我们的环境是LAMP堆栈。
Our environment is a LAMP stack.
推荐答案
您需要 ImageMagick
和 GhostScript
<?php
$im = new imagick('file.pdf[0]');
$im->setImageFormat('jpg');
header('Content-Type: image/jpeg');
echo $im;
?>
[0]
表示第1页
。
这篇关于如何在PHP中将PDF文档转换为预览图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文