0

上周我在 WYSIWYG - cKeditor 上工作。我想到了一个问题。有什么方法可以将doc或docx文件的内容提取或提取到博客或wordpress文本区域中。例如,我们不需要从 doc(x) 文件中选择和复制文本或图像。我们需要做的就是将文件交给所见即所得,然后将 doc(x) 文件的内容粘贴到帖子中。

任何建议将不胜感激。谢谢法瓦兹

4

1 回答 1

1

编辑:或者,看到这个插件

该插件将处理上传的 .docx 文件,将所有内容提取为帖子。


认为您可以使用PHPWord来提取 .docx 文件的内容。

(我可能应该提到 .docx 文件只是具有特定结构的 .zip 文件;Open Office XML

但是,它似乎更专注于编写 .docx 文件而不是阅读。

有一个PHPWord_Template包含这个的类__construct

$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>

其中确实包含文档的文本。

如果您想继承所有格式,使用此方法似乎需要做很多工作。比复制和粘贴到文本字段要多得多的工作。

于 2010-12-28T23:13:22.287 回答