4

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()

1 Answer 1

7

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>

Sign up to request clarification or add additional context in comments.

1 Comment

I already saw this.. But its not exact what i want. we cannot add image and after text to this...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.