Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/41.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php mdpf无法创建带有或标记的pdf_Php_Css_Html Table_Pdf Generation - Fatal编程技术网

Php mdpf无法创建带有或标记的pdf

Php mdpf无法创建带有或标记的pdf,php,css,html-table,pdf-generation,Php,Css,Html Table,Pdf Generation,我正在尝试从通过php创建的html表中创建pdf。 我使用php版本5.4.7和mdpf版本5.7.3 此代码不起作用: <?php include('../../mpdf/mpdf.php'); $mpdf=new mPDF('utf-8', 'A4-L'); $test2 = "<table class='timon' border='1'> <thead> <tr>

我正在尝试从通过php创建的html表中创建pdf。 我使用php版本5.4.7和mdpf版本5.7.3

此代码不起作用:

<?php

 include('../../mpdf/mpdf.php');


$mpdf=new mPDF('utf-8', 'A4-L');
$test2 = "<table class='timon' border='1'>
              <thead>
                  <tr>
                    <th></th>
                    <th>Montag</th>
                    <th>Dienstag</th>
                    <th>Mittwoch</th>
                    <th>Donnerstag</th>
                    <th>Freitag</th>
                    <th>Avg. Tag</th>
                  </tr>
              </thead>
              <tbody>
              <tr>
              <td>Morgen (0.3) </td>
              <td><s>test user 0.36</s><br /></td>
              <td></td>
              <td><s>test user 0.26</s><br /></td>
              <td></td>
              <td></td>
              <td> </td>
              </tr>
              <tr>
              <td>Mittag (0.5) </td>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
              <td> </td>
              </tr>
              <tr>
              <td>Nachmittag (0.5) </td>
              <td><s>test user 0.16</s><br /></td>
              <td></td>
              <td></td>
              <td></td>
              <td><s>test user 0.46</s><br /></td>
              <td> </td>
              </tr>
              <tr>
              <td>Ganzer Tag (1) </td>
              <td></td>
              <td></td>
              <td><s>test user 1.2</s><br /></td>
              <td></td>
              <td></td>
              <td> </td>
              </tr>
              <tr>
              <td>Total Auslastung</td>
              <td>0</td>
              <td>0</td>
              <td>0</td>
              <td>0</td>
              <td>0</td>
              <td>0</td>
              </tr>
              <tr>
              <td>Total Gruppe</td>
              <td>7.5</td>
              <td>7.5</td>
              <td>7.5</td>
              <td>7.5</td>
              <td>7.5</td>
              <td>7.5</td>
              </tr><tr>
              <td>Freie Plätze</td>
              <td style='background-color:#c6efce;'>7.5</td>
              <td style='background-color:#c6efce;'>7.5</td>
              <td style='background-color:#c6efce;'>7.5</td>
              <td style='background-color:#c6efce;'>7.5</td>
              <td style='background-color:#c6efce;'>7.5</td>
              <td style='background-color:#c6efce;'>7.5</td>
              </tr>
              </tbody>
              </table>";



$mpdf->WriteHTML($test2,2);

$filename = "test.pdf";

$mpdf->Output($filename,'I');
exit;

?>
如果我只删除一个标记,PDF就会创建得很好。例如:

              <td><s>test user 0.36</s><br /></td>
              <td>test user 0.36<br /></td>
它还存在标记的问题。 有什么想法吗?

您必须关闭标签。mPDF对开始和结束标记非常严格。并不是所有的开始标签都关闭了

f、 一,


未正确关闭。

我发现了错误。我有一个附加的php include,这个php有一个body和html标记。我刚把它取下来,现在它可以正常工作了。BR

Ops我在测试中犯了一个错误,只是添加了缺少的/而结果仍然是一样的。@Timon Strange,我已经处理了你问题中的html,它工作正常,但这对你没有帮助。。。我使用版本5.7.3。
         <td><s>test user 0.36<s><br /></td>