我正在使用TCPDF库在codeigniter中生成PDF。我已经成功地在Codeigniter3中集成了TCPDF版本6.2.8库。一切都很好,但有几个通知。我尝试了很多,但无法捕捉到确切的问题。
我的codeigniter模型方法是:
public function saveToPdf($html, $pdfName, $QRCodeData) {
$this->load->library('Pdf');
$pdf = new Pdf();
$pdf->SetAutoPageBreak(TRUE, 10); //set bottom margin
$pdf->AddPage();
if ($QRCodeData):
$pdf->write2DBarcode($QRCodeData, 'QRCODE,H', 180, 13, 75, 75);
endif;
$pdf->lastPage();
$pdf->writeHTML($html);
return $pdf->Output(APPPATH . "cache" . "/" . $pdfName, 'F');
}一切正常,但是这段代码会在很多地方为未定义的偏移生成通知。
我的错误日志:
ERROR - 2017-07-22 15:16:12 --> Severity: Notice --> Undefined offset: 0 /var/www/html/ts-2016/api/application/libraries/tcpdf/tcpdf.php 20373
ERROR - 2017-07-22 15:16:12 --> Severity: Notice --> Undefined offset: 0 /var/www/html/ts-2016/api/application/libraries/tcpdf/tcpdf.php 18853
ERROR - 2017-07-22 15:16:12 --> Severity: Notice --> Undefined offset: -1 /var/www/html/ts-2016/api/application/libraries/tcpdf/tcpdf.php 20227
ERROR - 2017-07-22 15:16:12 --> Severity: Notice --> Undefined offset: 0 /var/www/html/ts-2016/api/application/libraries/tcpdf/tcpdf.php 20373
ERROR - 2017-07-22 15:16:12 --> Severity: Notice --> Undefined offset: 0 /var/www/html/ts-2016/api/application/libraries/tcpdf/tcpdf.php 18853
ERROR - 2017-07-22 15:16:12 --> Severity: Notice --> Undefined offset: -1 /var/www/html/ts-2016/api/application/libraries/tcpdf/tcpdf.php 20227
ERROR - 2017-07-22 15:16:12 --> Severity: Notice --> Undefined offset: 0 /var/www/html/ts-2016/api/application/libraries/tcpdf/tcpdf.php 20373
ERROR - 2017-07-22 15:16:12 --> Severity: Notice --> Undefined offset: 0 /var/www/html/ts-2016/api/application/libraries/tcpdf/tcpdf.php 18853
ERROR - 2017-07-22 15:16:12 --> Severity: Notice --> Undefined offset: -1 /var/www/html/ts-2016/api/application/libraries/tcpdf/tcpdf.php 20227
ERROR - 2017-07-22 15:16:12 --> Severity: Notice --> Undefined offset: 0 /var/www/html/ts-2016/api/application/libraries/tcpdf/tcpdf.php 20373你可以在https://raw.githubusercontent.com/vsjadeja/tcpdf-codeigniter/master/application/libraries/tcpdf/tcpdf.php的github.com上看到我的tcpdf.php
请帮帮我。
发布于 2017-07-24 13:55:06
TCPDF只支持很少的HTML标签,如果你添加了其他不支持的标签,你也会得到这个严重错误。
请查找支持的标签列表。
+--------------+-------+----------+-------------+
| <marker> | <h1> | <ol> | <i> |
+--------------+-------+----------+-------------+
| <a> | <h2> | <option> | <img> |
+--------------+-------+----------+-------------+
| <b> | <h3> | <p> | <input> |
+--------------+-------+----------+-------------+
| <blockquote> | <h4> | <pre> | <label> |
+--------------+-------+----------+-------------+
| <body> | <h5> | <s> | |
+--------------+-------+----------+-------------+
| <br> | <h6> | <select> | <table> |
+--------------+-------+----------+-------------+
| <br/> | <hr> | <small> | <thead> |
+--------------+-------+----------+-------------+
| <dd> | <hr/> | <span> | <tablehead> |
+--------------+-------+----------+-------------+
| <del> | | <strike> | <th> |
+--------------+-------+----------+-------------+
| <div> | | <strong> | <td> |
+--------------+-------+----------+-------------+
| <dl> | | <sub> | <tr> |
+--------------+-------+----------+-------------+
| <dt> | | <sup> | |
+--------------+-------+----------+-------------+
| <em> | | | |
+--------------+-------+----------+-------------+
| <font> | | | |
+--------------+-------+----------+-------------+
| <form> | | | |
+--------------+-------+----------+-------------+我希望这能对你有所帮助。
发布于 2020-02-15 10:48:31
得到了一个类似的错误,并通过tcpdf.php追踪,试图找出哪里出了问题。对我来说,tcpdf.php似乎需要一个链接。它不需要使用,只要有一个就行了。在AddPage()之后添加了一个虚拟的1(到第1页),错误消失了!
//添加页面$pdf->AddPage();
$pdf->SetLink($dummy_tcpdf_undefined_offset_err,=$pdf-> $dummy_tcpdf_undefined_offset_err ();AddLink 0,'*1');
https://stackoverflow.com/questions/45253377
复制相似问题