【问题标题】:Add Text, Html, Embed Image To PHPWord向 PHPWord 添加文本、Html、嵌入图像
【发布时间】:2015-01-23 10:21:34
【问题描述】:

我正在使用PHPWord 使用 PHP 生成 word 文档。实际上我需要添加以下格式的内容:

Title
Description

Image1
Image1 Description(HTML CONTENT)

Image2 
Image2 Description(HTML CONTENT)

所以实际上我为此添加了一个部分和->addText()/->addImage()。但是在部分中我如何添加->addHtml()而不是->addText()

【问题讨论】:

    标签: php html


    【解决方案1】:

    您可以使用存储库中的示例执行此操作:https://github.com/PHPOffice/PHPWord/blob/master/samples/Sample_26_Html.php

     ....
     $section = $phpWord->addSection();
     $html = '<h1>The Description</h1><p>Some description here!';
     \PhpOffice\PhpWord\Shared\Html::addHtml($section, $html);
     ....
    

    但正如stackoverflow question 中所说,您只能使用&lt;p&gt;,&lt;h1&gt;,&lt;h2&gt;,&lt;h3&gt;,&lt;h4&gt;,&lt;h5&gt;,&lt;h6&gt;,&lt;strong&gt;,&lt;em&gt;,&lt;sup&gt;,&lt;sub&gt;,&lt;table&gt;,&lt;tr&gt;,&lt;td&gt;,&lt;ul&gt;,&lt;ol&gt;,&lt;li&gt; 之类的标签

    【讨论】:

    • 我已经看过了。但它并不完全是我想要的。我们无法在其中添加图像和文本...
    猜你喜欢
    • 1970-01-01
    • 2021-11-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-03
    • 2021-08-23
    • 2011-01-05
    相关资源
    最近更新 更多