从所见即所得中提取 doc 文件

发布于 2024-10-09 11:59:53 字数 203 浏览 0 评论 0原文

上周我正在研究 WYSIWYG - cKeditor。我的脑海中浮现出一个问题。有什么方法可以将 doc 或 docx 文件的内容提取或拉出到 blogger 或 wordpress 文本区域中。例如,我们不需要从 doc(x) 文件中选择和复制文本或图像。我们需要做的就是将文件交给所见即所得,并将 doc(x) 文件的内容粘贴到帖子中。

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

Last week while i was working on WYSIWYG - cKeditor. a question came in my mind. Is there any way to extract or pull out the content of doc or docx file into the blogger or wordpress text area. For instance, we need not to select and copy the text or images from doc(x) file. All we need to do is hand over the file to WYSIWYG and content of doc(x) file is pasted in the post.

Any suggestion would be appreciated.
Thanks
Fawaz

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

纸短情长 2024-10-16 11:59:53

编辑:或者,请参阅此插件

此插件将处理上传的
.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>

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

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

Edit: Or alternatively, see this plugin.

This plugin will process an uploaded
.docx file, extracting all the content
as a post.


I think you can use PHPWord to extract the contents of .docx files.

(I should probably mention that .docx files are just .zip files with a specific structure; Open Office XML)

However, it seems to be more dedicated to writing .docx files instead of reading.

There is class PHPWord_Template containing this in the __construct:

$this->_objZip = new ZipArchive();
$this->_objZip->open($this->_tempFileName);

$this->_documentXML = $this->_objZip->getFromName('word/document.xml');

Which returns an XML document like this:

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

Which does have the text of the document in it.

It looks like it will be a lot of work using this method if you want to carry over all the formatting. A lot more work than copying and pasting to a textfield.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文