Reputation: 6852
I am using PHPWord for generating word document using PHP. Actually I need to add content in the below format:
Title
Description
Image1
Image1 Description(HTML CONTENT)
Image2
Image2 Description(HTML CONTENT)
So actually I am adding a section and ->addText()/->addImage()
for this.. but in section how can i add ->addHtml()
instead of ->addText()
Upvotes: 4
Views: 18064
Reputation: 1567
You can do this using the example in the repository: 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);
....
But as said in this stackoverflow question you can only use tags like <p>,<h1>,<h2>,<h3>,<h4>,<h5>,<h6>,<strong>,<em>,<sup>,<sub>,<table>,<tr>,<td>,<ul>,<ol>,<li>
Upvotes: 5