The example in this article describes the method of converting word to HTML in PHP. I share it with you for your reference, the details are as follows:
If you want to perfectly solve the problem of converting office to pdf or html, it is best to use windows office software. Libreoffice cannot convert perfectly, and wps does not have an API.
First confirm whether the com module is enabled. If there is a com_dotnet module in phpinfo, it means it is enabled. If not, modify php.ini,
Copy the code The code is as follows:
com.allow_dcom = true
Previous Remove the comment and restart and it will be OK. The official PHP website says that before PHP5.4.5, the COM module was built-in. In fact, it may not be all the same. In PHP 5.3.39 under the official website, the COM module is not built-in.
If it is not a built-in module, add it to php.ini, provided that you have the extension in your ext folder
Copy the codeThe code is as follows:
extension=php_com_dotnet.dll
Then restart and it will be OK
function word2html($wordname,$htmlname) { $word = new COM("word.application") or die("Unable to instanciate Word"); $word->Visible = 1; $word->Documents->Open($wordname); $word->Documents[1]->SaveAs($htmlname,8); $word->Quit(); $word = null; unset($word); } word2html('D:/www/test/6.docx','D:/www/test/6.html');
Note:
1. Check the source code of the converted HTML, it is quite messy
2. Winword.exe will be called during the conversion process
3. If the page keeps loading, rename the document and then re- change.
Readers who are interested in more content related to PHP operating word can check out this site's special topic: "Summary of PHP operating office document skills (including word, excel, access, ppt)"
I hope that what this article describes will be helpful to everyone's PHP programming design. helped.
The above introduces the method of converting word to HTML in PHP, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

在之前的文章《实用Word技巧分享:详解怎么更改图片颜色和形状》中,我们了解了更改图片颜色和图片形状的方法。而今天我们来聊一聊word表格,讲解美化表格--自定义表格样式的方法,快来看看吧!

在之前的文章《实用Word技巧分享:聊聊你没用过的“行号”功能》中,我们了解了Word中你肯定没用过的"行号”功能。今天继续实用Word技巧分享,看看Excel表格怎么借用Word进行分栏打印,快来收藏使用吧!

在之前的文章《实用Word技巧分享:设置页码的终极方法!》中,我们学习了Word页码的设置方法。而今天我们来一起聊聊Word文本间距设置的几个技巧,快来收藏使用吧!

在之前的文章《实用Word技巧分享:隐藏图片,提升文档浏览和编辑效率!》中,我们学习了隐藏图片的技巧,可提升文档浏览和编辑效率。下面本篇文章再给大家分享一个实用Word技巧,看看怎么让页面自动滚动,快来收藏使用吧!

在之前的文章《实用Word技巧分享:表格自定义样式,美化表格!》中,我们了解了自定义表格样式的方法。而今天我们来聊一聊word脚注和尾注,介绍一下脚注和尾注的设置使用方法,快来看看吧!

在之前的文章《实用Word技巧分享:怎么跨文档快速复制样式》中,我们了解了在文档间快速复制样式的方法。今天我们聊聊Word快捷键,聊聊【F4】键快速统一图片大小,快来看看吧!

在之前的文章《实用Word技巧分享:图、表如何自动编号?》中,我们了解了Word排版-让图、表自动编号的方法。而今天聊聊Word精确控制页面“行数”和“字符个数”的方法,快来看看吧!

在之前的文章《实用Word技巧分享:如何一键删除所有数字》中,我们学习了Word中一键删除所有数字的方法。而今天我们来聊聊Word表格中如何自动添加编号,简单却很实用!


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Dreamweaver CS6
Visual web development tools

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment
