1

我正在尝试将一系列考勤卡(最多 150 张)打印为 pdf。它适用于一条记录,但失败超过 20 条。

以下是示例记录的代码

<div class='container'><h3>Timecard</h3><table style='table-layout: fixed;width:100%;text-align:left;'><tr><td class='infoItem' width='265px'><span class='fieldID'>Employee Name:</span>  Gomez Addams</td><td class='infoItem'><span class='fieldID'>EE#:</span>  9502</td></tr><tr><td class='infoItem'><span class='fieldID'>Dept:</span>  County Board</td><td colspan=2 align='left' class='infoItem'><h4><span class='fieldID'>JobID:</span> 13 <em class='fieldID grey'>(full-time non-exempt Sheriff Union contract with holiday)</em></h4></td></tr><tr><td class='infoItem'><span class='fieldID'>Payperiod:</span> 100 <em class='fieldID grey'>(Mar 10 to Mar 23 2012)</em></td><td class='infoItem'><span class='fieldID'>Pay Date:</span>  Mar 30 2012</td></tr></table><hr />
<table  class='timecard' width='658px'><tr><th class='timeHdr'>day</th><th class='timeHdr'>date</th><th class='timeHdr'>1000<br/>reg<br/>hrs</th><th class='timeHdr'>1004<br/>OT<br/>1x</th><th class='timeHdr'>1005<br/>OT<br/>1.5x</th><th class='timeHdr'>1035<br/>PTO<br/>used</th><th class='timeHdr'>1045<br/>comp<br/>used</th><th class='timeHdr'>1066<br/>comp<br/>1x</th><th class='timeHdr'>1067<br/>comp<br/>1.5x</th><th class='timeHdr'>other<br/>hrs</th><th class='timeHdr'>total<br/>hrs</th><th class='timeHdr'>1003<br/>hol<br/>prem</th><th class='timeHdr'>1007<br/>shift<br/>diff</th><th class='timeHdr'>1010<br/>out of<br/>class</th></tr>
<tr class='even'><td class='timeHdr'>sat</td><td align='center' class='timeHdr'>3/10</td><td class='timeView'></td><td class='timeView'></td><td class='timeView'></td><td class='timeView'></td><td class='timeView'></td><td class='timeView'></td><td class='timeView'></td><td class='timeView'></td><td class='rowTot'><div id='row0'></div></td><td class='timeView'></td><td class='timeView'></td><td class='timeView'></td></tr>
<tr class='odd'><td class='timeHdr'>sun</td><td align='center' class='timeHdr'>3/11</td><td class='timeView'></td><td class='timeView'></td><td class='timeView'></td><td class='timeView'></td><td class='timeView'></td><td class='timeView'></td><td class='timeView'></td><td class='timeView'></td><td class='rowTot'><div id='row1'></div></td><td class='timeView'></td><td class='timeView'></td><td class='timeView'></td></tr>
<tr class='even'><td class='timeHdr'>mon</td><td align='center' class='timeHdr'>3/12</td><td class='timeView'>8</td><td class='timeView'></td><td class='timeView'></td><td class='timeView'></td><td class='timeView'></td><td class='timeView'></td><td class='timeView'></td><td class='timeView'></td><td class='rowTot'><div id='row2'>8</div></td><td class='timeView'></td><td class='timeView'></td><td class='timeView'></td></tr>
<tr class='odd'><td class='timeHdr'>tue</td><td align='center' class='timeHdr'>3/13</td><td class='timeView'>8</td><td class='timeView'></td><td class='timeView'></td><td class='timeView'></td><td class='timeView'></td><td class='timeView'></td><td class='timeView'></td><td class='timeView'></td><td class='rowTot'><div id='row3'>8</div></td><td class='timeView'></td><td class='timeView'></td><td class='timeView'></td></tr>
<tr class='even'><td class='timeHdr'>wed</td><td align='center' class='timeHdr'>3/14</td><td class='timeView'>8</td><td class='timeView'></td><td class='timeView'></td><td class='timeView'></td><td class='timeView'></td><td class='timeView'></td><td class='timeView'></td><td class='timeView'></td><td class='rowTot'><div id='row4'>8</div></td><td class='timeView'></td><td class='timeView'></td><td class='timeView'></td></tr>
<tr class='odd'><td class='timeHdr'>thu</td><td align='center' class='timeHdr'>3/15</td><td class='timeView'>8</td><td class='timeView'></td><td class='timeView'></td><td class='timeView'></td><td class='timeView'></td><td class='timeView'></td><td class='timeView'></td><td class='timeView'></td><td class='rowTot'><div id='row5'>8</div></td><td class='timeView'></td><td class='timeView'></td><td class='timeView'></td></tr>
<tr class='even'><td class='timeHdr'>fri</td><td align='center' class='timeHdr'>3/16</td><td class='timeView'>8</td><td class='timeView'></td><td class='timeView'></td><td class='timeView'></td><td class='timeView'></td><td class='timeView'></td><td class='timeView'></td><td class='timeView'></td><td class='rowTot'><div id='row6'>8</div></td><td class='timeView'></td><td class='timeView'></td><td class='timeView'></td></tr>
<tr class='odd'><td class='timeHdr'>sat</td><td align='center' class='timeHdr'>3/17</td><td class='timeView'></td><td class='timeView'></td><td class='timeView'></td><td class='timeView'></td><td class='timeView'></td><td class='timeView'></td><td class='timeView'></td><td class='timeView'></td><td class='rowTot'><div id='row7'></div></td><td class='timeView'></td><td class='timeView'></td><td class='timeView'></td></tr>
<tr class='even'><td class='timeHdr'>sun</td><td align='center' class='timeHdr'>3/18</td><td class='timeView'></td><td class='timeView'></td><td class='timeView'></td><td class='timeView'></td><td class='timeView'></td><td class='timeView'></td><td class='timeView'></td><td class='timeView'></td><td class='rowTot'><div id='row8'></div></td><td class='timeView'></td><td class='timeView'></td><td class='timeView'></td></tr>
<tr class='odd'><td class='timeHdr'>mon</td><td align='center' class='timeHdr'>3/19</td><td class='timeView'>8</td><td class='timeView'></td><td class='timeView'></td><td class='timeView'></td><td class='timeView'></td><td class='timeView'></td><td class='timeView'></td><td class='timeView'></td><td class='rowTot'><div id='row9'>8</div></td><td class='timeView'></td><td class='timeView'></td><td class='timeView'></td></tr>
<tr class='even'><td class='timeHdr'>tue</td><td align='center' class='timeHdr'>3/20</td><td class='timeView'>4</td><td class='timeView'></td><td class='timeView'></td><td class='timeView'>4</td><td class='timeView'></td><td class='timeView'></td><td class='timeView'></td><td class='timeView'></td><td class='rowTot'><div id='row10'>8</div></td><td class='timeView'></td><td class='timeView'></td><td class='timeView'></td></tr>
<tr class='odd'><td class='timeHdr'>wed</td><td align='center' class='timeHdr'>3/21</td><td class='timeView'>3.5</td><td class='timeView'></td><td class='timeView'></td><td class='timeView'>4.5</td><td class='timeView'></td><td class='timeView'></td><td class='timeView'></td><td class='timeView'></td><td class='rowTot'><div id='row11'>8</div></td><td class='timeView'></td><td class='timeView'></td><td class='timeView'></td></tr>
<tr class='even'><td class='timeHdr'>thu</td><td align='center' class='timeHdr'>3/22</td><td class='timeView'>8</td><td class='timeView'></td><td class='timeView'></td><td class='timeView'></td><td class='timeView'></td><td class='timeView'></td><td class='timeView'></td><td class='timeView'></td><td class='rowTot'><div id='row12'>8</div></td><td class='timeView'></td><td class='timeView'></td><td class='timeView'></td></tr>
<tr class='odd'><td class='timeHdr'>fri</td><td align='center' class='timeHdr'>3/23</td><td class='timeView'>8</td><td class='timeView'></td><td class='timeView'></td><td class='timeView'></td><td class='timeView'></td><td class='timeView'></td><td class='timeView'></td><td class='timeView'></td><td class='rowTot'><div id='row13'>8</div></td><td class='timeView'></td><td class='timeView'></td><td class='timeView'></td></tr>
<tr><td colspan=2 style='background: #e6f4ff;' class='timeHdr'>totals</td><td align='center' class='colTot'><div id='col0'>71.5</div></td><td align='center' class='colTot'><div id='col1'></div></td><td align='center' class='colTot'><div id='col2'></div></td><td align='center' class='colTot'><div id='col3'>8.5</div></td><td align='center' class='colTot'><div id='col4'></div></td><td align='center' class='colTot'><div id='col5'></div></td><td align='center' class='colTot'><div id='col6'></div></td><td align='center' class='colTot'><div id='col7'></div></td><td align='center' class='totTot'>80</td><td align='center' class='colTot'><div id='col9'></div></td><td align='center' class='colTot'><div id='col10'></div></td><td align='center' class='colTot'><div id='col11'></div></td></tr>
<tr><td colspan=2 class='timeHdr' style='vertical-align: top;'>comments</td><td colspan=14 class='comment'> </td></tr>
</table><hr /><table style='table-layout: fixed;width:100%;text-align:left;'><td colspan=2 ><em class='grey'>This form is due in the Auditor/Treasurer's Office by 9:00am on Monday after the end of the pay period.  No overtime without authorization is allowed.&nbsp; I affirm that the information contained herein is true and correct to the best of my knowledge.</em></td></tr><tr><td colspan=2>&nbsp;</td></tr><tr><td class='infoItem' valign='top'><span class='fieldID'>Employee:</span>  Gomez Addams</td><td class='infoItem'><span class='fieldID'>Supervisor:</span>   </td></tr><tr><td class='infoItem'><span class='fieldID'>Employee Approved:</span>  </td><td class='infoItem'><span class='fieldID'>Supervisor Approved:</span>  </td></tr></table><br /></table>

<h4>Payroll Notes:</h4><p>note 4</p></div>

换行符与打印的内容相同,我认为这很重要......

所以基于此,我有这个:

ini_set("memory_limit", "256M"); 
$stylesheet = file_get_contents('../css/timecardPDF.css');
$mpdf=new mPDF();
$mpdf->WriteHTML($stylesheet,1);
<loop>$html=above code;$mpdf->WriteHTML($html,2);</end loop> 
$mpdf->Output('../timecards/file.pdf','F');
exit;

所以在我尝试循环超过 20 次之前,一切都完全正常。我该怎么做才能让套件和 kaboodle(150 条记录)打印到 pdf 文档?

感谢您的善意考虑!

4

1 回答 1

-1

对于遇到类似问题的任何人:原来它只是超时,所以延长了 php 超时(set_time_limit(#ms))并且它有效(只是需要很长时间!)

于 2012-05-15T16:22:02.747 回答