[英]Is it possible to convert doc file to HTML using PHP?
I am creating a website in which authors can create EPUB files. 我正在创建一个网站,作者可以在其中创建EPUB文件。 Users will be uploading their books in the
.doc
format. 用户将以
.doc
格式上传他们的图书。 I need to create EPUB file out of that. 我需要创建EPUB文件。 One single doc file will be having multiple chapters.
一个单独的doc文件将包含多个章节。 So I need to parse the
doc
file and split it into chapters. 所以我需要解析
doc
文件并将其拆分为章节。 Authors will be using Heading 1
for their chapter titles. 作者将使用
Heading 1
作为章节标题。
So in PHP
, is there any way to parse doc
files to HTML
and split it into chapters using Heading 1
, so that I can create EPUB file. 那么在
PHP
,有没有办法将doc
文件解析为HTML
并使用Heading 1
将其拆分为章节,以便我可以创建EPUB文件。
After some research, I got one linux app . 经过一番研究,我得到了一个linux应用程序 。 But I think, it will convert doc to plain text.
但我认为,它会将doc转换为纯文本。 So I will not be able to split the chapters.
所以我将无法拆分章节。
Please suggest me the a solution if you have. 如果你有,请建议我一个解决方案。 Thanks in advance.
提前致谢。
You can achieve this using PHPDOCX API . 您可以使用PHPDOCX API实现此目的 。
First try to generate the XHTML from your Word document using this function reference 首先尝试使用此函数引用从Word文档生成XHTML
Something like this.. 像这样的东西......
require_once '../../classes/TransformDoc.inc';
$document = new TransformDoc();
$document->setStrFile('../files/Text.docx');
$document->generateXHTML();
$document->validatorXHTML();
echo $document->getStrXHTML();
After getting the XHTML content you can do various processings like removing chapter ,etc. 获取XHTML内容后,您可以执行各种处理,例如删除章节等。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.