上周,当我在WYSIWYG - cKeditor上工作时。一个问题出现在我的脑海中。有没有办法将doc或docx文件的内容提取或拉出到blogger或wordpress文本区域。例如,我们不需要从doc(x)文件中选择和复制文本或图像。我们需要做的就是把文件交给WYSIWYG,然后doc(x)文件的内容就会被粘贴到帖子中。
任何建议都将不胜感激。谢谢法瓦兹
发布于 2010-12-29 07:13:22
编辑:或者,参见this plugin。
这个插件将处理一个上传的.docx文件,将所有内容提取出来作为帖子。
我认为您可以使用PHPWord来提取.docx文件的内容。
(我可能应该提一下,.docx文件只是具有特定结构的.zip文件;Open Office XML)
然而,它似乎更多地致力于写入.docx文件而不是读取。
在__construct中有一个包含以下内容的类PHPWord_Template
$this->_objZip = new ZipArchive();
$this->_objZip->open($this->_tempFileName);
$this->_documentXML = $this->_objZip->getFromName('word/document.xml');它返回的XML文档如下所示:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<w:document xmlns:ve="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml">
<w:body>
<w:p w:rsidR="005B1098" w:rsidRDefault="005B1098"/>
<w:p w:rsidR="005B1098" w:rsidRDefault="005B1098">
...
<w:r w:rsidRPr="00F15611">
<w:rPr>
<w:rFonts w:ascii="Calibri" w:hAnsi="Calibri" w:cs="Calibri"/>
<w:lang w:val="en-GB"/>
</w:rPr>
<w:t xml:space="preserve">The following table contains a few values that can be edited by the PHPWord_Template class.</w:t>
</w:r>
...
</w:body>
</w:document>其中包含文档的文本。
如果你想进行所有的格式化,使用这种方法看起来会有很大的工作量。比复制和粘贴到文本字段要多得多的工作。
https://stackoverflow.com/questions/4550162
复制相似问题