File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change
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.
You can’t perform that action at this time.
0 commit comments