PHP-获取Word文档中的页数
有没有办法使用 PHP 计算现有 Word 文档的页数?
我很感激你的帮助。
谢谢
Is there a way to count number of pages using PHP for existing Word documents?
I appreciate for the help.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您需要一个可以读取 Word 文档的库。 我建议:http://www.phplivedocx.org/ 您还需要 Zend 框架:< a href="http://framework.zend.com/" rel="nofollow noreferrer">http://framework.zend.com/
我确信还有更多可用的库,但我发现这是最新且维护良好的。
You need a library that can read Word docs. I recommend: http://www.phplivedocx.org/ You'll also need the Zend Framework: http://framework.zend.com/
I'm sure there are many more libraries available, but I find this to be the most current and well maintained.
如果您使用的是 Windows 服务器,则需要找到合适的第 3 方库(或编写您自己的库),您可以考虑使用 COM 接口。
这是使用 COM 的方法...(但我还没有测试过)
You will need to find an appropriate 3rd party library (or write your own) if you are using a Windows server you could look into using a COM interface.
Here is how you would do it with COM... (but I haven't tested it yet)
为了从 PHP 获取 doc、docx、ppt 和 pptx 的元数据属性(例如页数、幻灯片数),我遵循了以下过程,它的工作很有趣,我很高兴,下面是我遵循的过程,希望它能帮助某人
一次完成后,您可以尝试执行以下命令,它会提供有关您的文件的所有元数据,
一旦测试,您可以在
PHP 脚本
中执行此命令。 谢谢。To get meta data properties of doc,docx,ppt and pptx like number of pages, number of slides from PHP i followed the following process and it worked liked charm and iam so happy, below is the process i followed , hope it helps someone
once its done you could try executing the following commadn it will give all the meta data about your file
once tested you can execute this comman in
PHP script
. Thanks.我认为这很难可靠地做到,因为 Word 文档中的页数可能取决于用于查看该文档的 Word 应用程序中安装的打印机驱动程序。
I think that this is difficult to do reliably, because the number of pages in a Word document can depend on what printer driver is installed in the Word application used to view it.
看看 microsoft codeplex 的 PhpWord ...“http://phpword.codeplex.com/
它将允许您在 PHP 中打开和读取 word 格式的文件,并执行您需要的任何处理。
Have a look at PhpWord from microsoft codeplex ... "http://phpword.codeplex.com/
It will allow you to open and read the word formatted file in PHP and do whatever processing you require.