@@ -12,20 +12,31 @@ You can generate a Word file from html.
12
12
'marginLeft' => (int)round(20 * 56.6929133858),
13
13
'marginRight' => (int)round(20 * 56.6929133858),
14
14
'marginTop' => (int)round(20 * 56.6929133858),
15
- 'marginBottom' => (int)round(20 * 56.6929133858),``
15
+ 'marginBottom' => (int)round(20 * 56.6929133858),
16
16
]);
17
17
18
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 >
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 >
24
30
</table >';
25
31
26
32
$fullHTML = false;
33
+ $preserveWhiteSpace = true;
27
34
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);
29
40
30
41
$fqName = new PhpOffice\PhpWord\Writer\Word2007($phpWordInstance);
31
42
$fqName->save('./test.docx');
@@ -34,3 +45,7 @@ You can generate a Word file from html.
34
45
$html - $html param must have root node such as "html" if it is full html;
35
46
36
47
$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