Skip to content

Commit 20799d9

Browse files
OlisaevAGOlisaevAG
OlisaevAG
authored and
OlisaevAG
committed
feat: documentation for addHTML
1 parent 147c27d commit 20799d9

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

docs/usage/shared/html.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# HTML
2+
3+
## HTML
4+
You can generate a Word file from html.
5+
6+
``` php
7+
<?php
8+
9+
$phpWordInstance = new PhpWord();
10+
$phpSectionInstance = $phpWordInstance->addSection([
11+
'orientation' => 'landscape',
12+
'marginLeft' => (int)round(20 * 56.6929133858),
13+
'marginRight' => (int)round(20 * 56.6929133858),
14+
'marginTop' => (int)round(20 * 56.6929133858),
15+
'marginBottom' => (int)round(20 * 56.6929133858),``
16+
]);
17+
18+
$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>
24+
</table>';
25+
26+
$fullHTML = false;
27+
28+
Html::addHtml($phpSectionInstance, $html, $fullHTML, false);
29+
30+
$fqName = new PhpOffice\PhpWord\Writer\Word2007($phpWordInstance);
31+
$fqName->save('./test.docx');
32+
```
33+
34+
$html - $html param must have root node such as "html" if it is full html;
35+
36+
$fullHTML - If $html is not full html, it may not have a root element. In this case $fullHTML should be false.

0 commit comments

Comments
 (0)