我真的不知道如何解决这个问题。我正在使用html2pdf库将我的html转换为pdf。好的,我有一个下载按钮,用户可以在其中将html下载为pdf。但是我遇到了这些错误:我还检查了html中的结束标记。谢谢大家。
Spipu \ Html2Pdf \ Exception \ HtmlParsingException:对于C:\ xampp \ htdocs \ DTR \ vendor \ spipu \ html2pdf \ src \ Parsing \ Html.php:262中的[div],标签以错误的顺序关闭了[div] #0 C:\ xampp \ htdocs \ DTR \ vendor \ spipu \ html2pdf \ src \ Parsing \ Html.php(94):Spipu \ Html2Pdf \ Parsing \ Html-> getTagAction(Object(Spipu \ Html2Pdf \ Parsing \ Token),数组)#1 C:\ xampp \ htdocs \ DTR \ vendor \ spipu \ html2pdf \ src \ Html2Pdf.php(594):Spipu \ Html2Pdf \ Parsing \ Html-> parse(Array)#2 C:\ xampp \ htdocs \ DTR \ pages \ download.php(18):Spipu \ Html2Pdf \ Html2Pdf-> writeHTML('\ n \ n \ n \ n \ n \ n \ n \ n \ n \ n \ n \ n \ n \ n \ n \ n \ n ...')#3 {main}
<page style="font-family: Arial, Helvetica, sans-serif; font-size: 14px">
<div class="container">
<div class="row-one-half">
<div class="top-left-text">
<h4>CHRD - 001 - 0</h4>
<h4>(Civil Service Form No. 48)</h4>
</div>
<div class="text-center-text">
<h2>Daily Time Record</h2>
<div class="line">-----o0o-----</div>
<h4 class="name">Sample Name<h4>
<h4 class="category">(Name)</h4>
</div>
<div class="text-center--info-text">
<p>For the month of September 16 - September 30, 2018<p>
<p>Official hours for arrival Regular days Monday - Friday</p>
<p>and departure 8 AM - 5 PM Saturdays None</p>
</div>
<div class="table-dtr">
<table>
<tr>
<th rowspan="2">Day</th>
<th colspan="2">A.M.</th>
<th colspan="2">P.M.</th>
<th colspan="2">Undertime</th>
</tr>
<tr>
<th>Arrival</th>
<th>Departure</th>
<th>Arrival</th>
<th>Departure</th>
<th>Hours</th>
<th>Minutes</th>
</tr>
<tr>
<th>16</th>
<td></td>
<td></td>
<td></td>
<td></td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<th>17</th>
<td>07:35 AM</td>
<td>12:01 PM</td>
<td>12:54 PM</td>
<td>05:03 PM</td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<th>18</th>
<td>07:58 AM</td>
<td>12:07 PM</td>
<td>12:53 PM</td>
<td>05:05 PM</td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<th>19</th>
<td></td>
<td></td>
<td></td>
<td></td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<th>20</th>
<td></td>
<td></td>
<td></td>
<td></td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<th>21</th>
<td></td>
<td></td>
<td></td>
<td></td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<th>22</th>
<td></td>
<td></td>
<td></td>
<td></td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<th>23</th>
<td></td>
<td></td>
<td></td>
<td></td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<th>24</th>
<td>08:05 AM</td>
<td>12:04 PM</td>
<td>12:54 PM</td>
<td>05:03 PM</td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<th>25</th>
<td>07:37 AM</td>
<td>12:05 PM</td>
<td>12:50 PM</td>
<td>05:03 PM</td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<th>26</th>
<td>07:50 AM</td>
<td>12:05 PM</td>
<td>12:53 PM</td>
<td>05:02 PM</td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<th>27</th>
<td>07:31 AM</td>
<td>12:00 PM</td>
<td>12:54 PM</td>
<td>05:05 PM</td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<th>28</th>
<td>07:26 AM</td>
<td>12:06 PM</td>
<td>12:53 PM</td>
<td>05:05 PM</td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<th>29</th>
<td></td>
<td></td>
<td></td>
<td></td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<th>30</th>
<td></td>
<td></td>
<td></td>
<td></td>
<td>0</td>
<td>0</td>
</tr>
<?php
for($i = 1; $i <= 14; $i++) {
?>
<tr>
<th></th>
<td></td>
<td></td>
<td></td>
<td></td>
<td> </td>
<td> </td>
</tr>
<?php
}
?>
<tr>
<th colspan="5" style="text-align: right; padding-right: 20px;">Total</th>
<td>0</td>
<td>0</td>
</tr>
</table>
<div class="text-center--info-text t-bottom">
<p> I certify on my honor that the above is a true and correct report of the hours of work performed, record of which was made daily at the time of arrival and departure from office.</p>
</div>
<p class="underline">___________________________________________</p>
<p>VERIFIED as to the prescribed office hours:</p>
<p class="underline">___________________________________________</p>
<div class="t-center">
<p>In Charge:</p>
<p>(SEE INSTRUCTION ON BACK)</p>
</div>
</div>
</div>
<div class="row-one-half">
<div class="top-left-text">
<h4>CHRD - 001 - 0</h4>
<h4>(Civil Service Form No. 48)</h4>
</div>
<div class="text-center-text">
<h2>Daily Time Record</h2>
<div class="line">-----o0o-----</div>
<h4 class="name">Sample Name<h4>
<h4 class="category">(Name)</h4>
</div>
<div class="text-center--info-text">
<p>For the month of September 16 - September 30, 2018<p>
<p>Official hours for arrival Regular days Monday - Friday</p>
<p>and departure 8 AM - 5 PM Saturdays None</p>
</div>
<div class="table-dtr">
<table>
<tr>
<th rowspan="2">Day</th>
<th colspan="2">A.M.</th>
<th colspan="2">P.M.</th>
<th colspan="2">Undertime</th>
</tr>
<tr>
<th>Arrival</th>
<th>Departure</th>
<th>Arrival</th>
<th>Departure</th>
<th>Hours</th>
<th>Minutes</th>
</tr>
<tr>
<th>16</th>
<td></td>
<td></td>
<td></td>
<td></td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<th>17</th>
<td>07:35 AM</td>
<td>12:01 PM</td>
<td>12:54 PM</td>
<td>05:03 PM</td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<th>18</th>
<td>07:58 AM</td>
<td>12:07 PM</td>
<td>12:53 PM</td>
<td>05:05 PM</td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<th>19</th>
<td></td>
<td></td>
<td></td>
<td></td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<th>20</th>
<td></td>
<td></td>
<td></td>
<td></td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<th>21</th>
<td></td>
<td></td>
<td></td>
<td></td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<th>22</th>
<td></td>
<td></td>
<td></td>
<td></td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<th>23</th>
<td></td>
<td></td>
<td></td>
<td></td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<th>24</th>
<td>08:05 AM</td>
<td>12:04 PM</td>
<td>12:54 PM</td>
<td>05:03 PM</td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<th>25</th>
<td>07:37 AM</td>
<td>12:05 PM</td>
<td>12:50 PM</td>
<td>05:03 PM</td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<th>26</th>
<td>07:50 AM</td>
<td>12:05 PM</td>
<td>12:53 PM</td>
<td>05:02 PM</td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<th>27</th>
<td>07:31 AM</td>
<td>12:00 PM</td>
<td>12:54 PM</td>
<td>05:05 PM</td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<th>28</th>
<td>07:26 AM</td>
<td>12:06 PM</td>
<td>12:53 PM</td>
<td>05:05 PM</td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<th>29</th>
<td></td>
<td></td>
<td></td>
<td></td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<th>30</th>
<td></td>
<td></td>
<td></td>
<td></td>
<td>0</td>
<td>0</td>
</tr>
<?php
for($i = 1; $i <= 14; $i++) {
?>
<tr>
<th></th>
<td></td>
<td></td>
<td></td>
<td></td>
<td> </td>
<td> </td>
</tr>
<?php
}
?>
<tr>
<th colspan="5" style="text-align: right; padding-right: 20px;">Total</th>
<td>0</td>
<td>0</td>
</tr>
</table>
<div class="text-center--info-text t-bottom">
<p> I certify on my honor that the above is a true and correct report of the hours of work performed, record of which was made daily at the time of arrival and departure from office.</p>
</div>
<p class="underline">___________________________________________</p>
<p>VERIFIED as to the prescribed office hours:</p>
<p class="underline">___________________________________________</p>
<div class="t-center">
<p>In Charge:</p>
<p>(SEE INSTRUCTION ON BACK)</p>
</div>
</div>
</div>
</div>
</page>
答案 0 :(得分:1)
替换此
<p>For the month of September 16 - September 30, 2018<p>
至
<p>For the month of September 16 - September 30, 2018</p>
答案 1 :(得分:0)
请关闭所有打开的标签。必须使用HTML2PDF库。
根据您的代码,我为您启动了<h4>
的{{1}}标签,但未关闭该标签,请关闭该标签,而不是新的Sample Name
标签。
例如: 替换以下
<h4>
收件人
<h4 class="name">Sample Name<h4>
您需要在两个位置更改此代码。因为这在两个地方都可以使用。
答案 2 :(得分:0)
替换以下内容(两次相同的错误):
<h4 class="name">Sample Name<h4> (l.11)
<h4 class="name">Sample Name</h4> (closing tag)
<p>For the month of September 16 - September 30, 2018<p> (l.15)
<p>For the month of September 16 - September 30, 2018</p> (closing tag)
<h4 class="name">Sample Name<h4> (l.207)
<h4 class="name">Sample Name</h4> (closing tag)
<p>For the month of September 16 - September 30, 2018<p> (l.211)
<p>For the month of September 16 - September 30, 2018</p> (closing tag)
提示:您可以使用在线 XML 验证工具快速找到那些 (example here),但您必须首先删除所有 和 php 标签。