Skip to content

Commit ae3767f

Browse files
OlisaevAGOlisaevAG
OlisaevAG
authored and
OlisaevAG
committed
feat: documentation for addHTML 3.
1 parent 0d66d9c commit ae3767f

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

docs/usage/shared/html.md

+22-7
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,31 @@ You can generate a Word file from html.
1212
'marginLeft' => (int)round(20 * 56.6929133858),
1313
'marginRight' => (int)round(20 * 56.6929133858),
1414
'marginTop' => (int)round(20 * 56.6929133858),
15-
'marginBottom' => (int)round(20 * 56.6929133858),``
15+
'marginBottom' => (int)round(20 * 56.6929133858),
1616
]);
1717

1818
$html = '<!-- Any html. Table for example -->
19-
<table>
20-
<tr>
21-
<td style="border-left:solid blue 2px;">border-left:solid blue 2px;</td>
22-
<td style="border-right:solid 2px red;">border-right:solid 2px red;</td>
23-
</tr>
19+
<table>
20+
<tr>
21+
<td style="border-left:solid blue 2px;">border-left:solid blue 2px;</td>
22+
<td style="border-right:solid 2px red;">border-right:solid 2px red;</td>
23+
</tr>
24+
<tr>
25+
<td>
26+
<img src="https://any.domain/path-to-img/name.jpg" />
27+
</td>
28+
<td></td>
29+
</tr>
2430
</table>';
2531

2632
$fullHTML = false;
33+
$preserveWhiteSpace = true;
2734

28-
Html::addHtml($phpSectionInstance, $html, $fullHTML, false);
35+
$options = [];
36+
$options['IMG_SRC_SEARCH'] = 'path-to-img/name.jpg';
37+
$options['IMG_SRC_REPLACE'] = 'another-path-to-img/new-name.jpg';
38+
39+
Html::addHtml($phpSectionInstance, $html, $fullHTML, $preserveWhiteSpace, $options);
2940

3041
$fqName = new PhpOffice\PhpWord\Writer\Word2007($phpWordInstance);
3142
$fqName->save('./test.docx');
@@ -34,3 +45,7 @@ You can generate a Word file from html.
3445
$html - $html param must have root node such as "html" if it is full html;
3546

3647
$fullHTML - If $html is not full html, it may not have a root element. In this case $fullHTML should be false.
48+
49+
$preserveWhiteSpace - Do not remove redundant white space. Default to true.
50+
51+
$options - which could be applied when such an element occurs in the parseNode function.

0 commit comments

Comments
 (0)