如何使用 PHP 从图像文件创建 PDF 文档
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6865651/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to create PDF documents from image files, using PHP
提问by user198003
With PHP application, I have to generate single PDF documents, from set of images.
使用 PHP 应用程序,我必须从一组图像生成单个 PDF 文档。
Which is best way to achieve this? Can I use TCPDF library, and can you give me some example?
实现这一目标的最佳方法是什么?我可以使用TCPDF库吗,你能给我举个例子吗?
回答by Nicola Asuni
The easiest way is to use TCPDF (http://www.tcpdf.org) and set the images as full background as on the example n. 51.
最简单的方法是使用 TCPDF (http://www.tcpdf.org) 并将图像设置为示例 n 中的全背景。51.
For example:
例如:
// disable auto-page-break
$pdf->SetAutoPageBreak(false, 0);
// set image 1
$pdf->AddPage();
$this->Image('image_demo1.jpg', 0, 0, 210, 297, '', '', '', false, 300, '', false, false, 0);
$this->setPageMark();
// set image 2
$pdf->AddPage();
$this->Image('image_demo2.jpg', 0, 0, 210, 297, '', '', '', false, 300, '', false, false, 0);
$this->setPageMark();
// ...
回答by jay
回答by Damp
I don't know your requirements but ImageMagick could probably do the trick. I believe that they also have a php wrapper available for all the image manipulation/conversion functions.
我不知道您的要求,但 ImageMagick 可能可以解决问题。我相信他们还有一个可用于所有图像操作/转换功能的 php 包装器。