从图像创建PDF时设置文档名称

编程入门 行业动态 更新时间:2024-10-26 22:25:45
本文介绍了从图像创建PDF时设置文档名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在使用以下代码从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时设置文档名称

本文发布于:2023-10-23 22:28:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1522182.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:图像   名称   文档   PDF

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!