我正在使用以下代码从jpg图像创建pdf:
I'm using the following code to create a pdf from a jpg image:
$im = new Imagick(); $im->readImage('./image.jpg'); $im->setImageFormat('pdf'); $im->writeImage('../images/pdf/image.pdf');现在,我最近看到Google索引了image.pdf文件,但由于它在Google搜索页上的标题为"Untitled"而不是"Image",因此名称为image.pdf.
Now I recently Saw that google indexed the image.pdf file but as the title on the google search page it says "Untitled" instead of "Image" cause the name was image.pdf.
在我看来,PDF似乎拥有自己的命名,而我的代码中却没有. 如何使用Imagemagick将无标题"更改为实际标题?
So to me it appears as if PDF had it's own naming which has been left out in my code. How can I change that "Untitled" to the actual title using Imagemagick?
推荐答案这似乎与ImageMagick无关.您还有其他选择:
This doesn't appear possible to do with ImageMagick. You have a few other options:
- 购买并使用PDFLib库: php/manual/zh/book.pdf.php
- 使用Zend PHP框架;用法示例如下:通过PHP将元数据添加到PDF 此处提供更多信息: framework.zend/about/faq/
- 使用PHP exec()函数调用可以设置标题的外部程序
- 在评论中提到的OP也有FPDF: www.fpdf/似乎很合适,因为它能够编写PDF文件并使用其SetTitle()设置标题.自2011年以来和2008年之前,FPDF都没有进行过更新.但是,再次,它似乎是合适的.
- Purchase and use the PDFLib library: php/manual/en/book.pdf.php
- Use the Zend PHP framework; example of how to use it is here: Adding metadata to PDF via PHP with more information here: framework.zend/about/faq/
- Use the PHP exec() function to call an external program that can set the title
- OP mentioned in a comment there is FPDF as well: www.fpdf/ which appears it could be suitable as it has the ability to write a PDF file and set the title using its SetTitle(). FPDF hasn't been updated since 2011 and before that 2008. But, again, it appears that it would be suitable.
对于它的价值,Zend PHP Framework可能是我的选择.尽管如果这不是您要做的事,那么exec()函数可能更有意义.
For what it is worth, the Zend PHP Framework would probably be my choice. Although if this isn't something you'll be doing a lot of, then the exec() function might make more sense.
更多推荐
从图像创建PDF时设置文档名称
发布评论