用 PHP 生成带有动态图像的 ODT 文档

发布于 2024-08-11 16:22:49 字数 855 浏览 3 评论 0原文

我在共享托管包上维护几个基于 PHP 和 mySQL 的 Web 数据库。 数据库有一个机制供用户上传带有占位符的 OpenOffice 文档:

[person.name] [person.address] [person.postcode]

然后我使用这个很棒的 PHP 工具 运行 OpenOffice 文档并将数据库中的值插入其中。结果又是一个 OpenOffice 文档。

它不能做的是动态图像

有谁知道一个(最好是仅 PHP)将图像插入 OpenOffice 文档的解决方案?

  • 我知道PUNO。无法在这种情况下使用它,因为它是共享托管。
  • 我知道 OpenOffice 可以作为守护进程运行 - 同上。
  • 我知道 phpDocWriter。它对于 SXW 文件来说非常有用,但现在已经死了。
  • 我知道 OpenDocument 是 ZIP 文件中 XML 文件的集合。我曾经尝试以编程方式为 ODT 文档中的每个图像添加标题。这让我快疯了。我对使用这种格式的开发人员表示钦佩,但它不适合我。

我真的很感激任何有关现有解决方案的提示。

I maintain a couple of web databases based on PHP and mySQL on a shared hosting package.
The databases have a mechanism for the user to upload OpenOffice documents with placeholders:

[person.name] [person.address] [person.postcode]

I then use this great PHP tool to run through the OpenOffice document and insert values from the database into it. The result is again, an OpenOffice document.

What it can't do is dynamic images.

Does anybody know a - preferably PHP-only - solution to insert images into OpenOffice documents?

  • I know PUNO. Can't use it in this context because it's shared hosting.
  • I know OpenOffice can be run as a daemon - ditto.
  • I know phpDocWriter. It was great for SXW files but is dead now.
  • I know OpenDocument is a collection of XML files in a ZIP file. I once tried to programmatically add a caption to every image in a ODT document. It drove me fricking crazy. I look with admiration upon developers who work with the format, but it's not for me.

I would really appreciate any hints on existing solutions.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

夜无邪 2024-08-18 16:22:49

我认为 odtPHP 可能就是您正在寻找的,

它似乎能够在占位符上插入图像文档并简单地从数组中读取以查看要放置哪个图像。

http://www.odtphp.com/index.php?i=教程&p=tutorial5

现在,如果您在当前代码之后将其作为后处理,或者只是使用它而不是 TBS,那么您将获得所需的一切,恕我直言,或者

,您可以包含具有特定属性的默认图像。文件名,只需替换存档中的该图像文件即可。

I think odtPHP might be what you're looking for

is seems to be able to insert images on a placeholder in the document and reads simply from an array to see which image to place.

http://www.odtphp.com/index.php?i=tutorials&p=tutorial5

Now, if you do this as a post-process after your current code, or simply use it instead of TBS, you got everything you need IMHO

Alternatively, you can include a default image with a certain filename in your document, and simply replace that imagefile in the archive.

删除会话 2024-08-18 16:22:49

TbsOOo 有一个新版本,它是 OpenTBS,它具有插入/更改图片的功能在文件中。

http://www.tinybutstrong.com/opentbs.php

There is a new version of TbsOOo, it's OpenTBS and it has a feature for inserting/changing a picture in the file.

http://www.tinybutstrong.com/opentbs.php

云仙小弟 2024-08-18 16:22:49

您是否尝试使用 AddFileToDoc 方法将图像添加到文档中?

有关此方法的文档位于:

http://www.tinybutstrong.com/tbsooo.php#添加文件到文档

Did you try to use the AddFileToDoc method to add an image to the document?

The documentation on this method is here:

http://www.tinybutstrong.com/tbsooo.php#AddFileToDoc

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文