[英]Codeigniter dompdf : Invalid Character Error
When I try to print a pdf I get this error: 当我尝试打印pdf时,出现此错误:
An uncaught Exception was encountered
Type: DOMException
Message: Invalid Character Error
Filename: /home/ireto/domains/ireto.be/public_html/madicbelgium/application/helpers/dompdf/lib/html5lib/TreeBuilder.php
Line Number: 3191
Backtrace:
File: /home/ireto/domains/ireto.be/public_html/madicbelgium/application/helpers/dompdf/lib/html5lib/TreeBuilder.php
Line: 3191
Function: setAttribute
File: /home/ireto/domains/ireto.be/public_html/madicbelgium/application/helpers/dompdf/lib/html5lib/TreeBuilder.php
Line: 1493
Function: insertElement
File: /home/ireto/domains/ireto.be/public_html/madicbelgium/application/helpers/dompdf/lib/html5lib/Tokenizer.php
Line: 2456
Function: emitToken
File: /home/ireto/domains/ireto.be/public_html/madicbelgium/application/helpers/dompdf/lib/html5lib/Tokenizer.php
Line: 1102
Function: emitToken
File: /home/ireto/domains/ireto.be/public_html/madicbelgium/application/helpers/dompdf/src/Dompdf.php
Line: 470
Function: parse
File: /home/ireto/domains/ireto.be/public_html/madicbelgium/application/helpers/dompdf_helper.php
Line: 26
Function: loadHtml
File: /home/ireto/domains/ireto.be/public_html/madicbelgium/application/controllers/admin/Estimates.php
Line: 136
Function: pdf_create
File: /home/ireto/domains/ireto.be/public_html/madicbelgium/index.php
Line: 293
Function: require_once
This is my code on line :3191 -> 这是我的代码行:3191->
private function insertElement($token, $append = true) {
$el = $this->dom->createElementNS(self::NS_HTML, $token['name']);
if (!empty($token['attr'])) {
foreach ($token['attr'] as $attr) {
if (!$el->hasAttribute($attr['name']) && preg_match("/[^A-Za-z0-9]/u", $attr['name'])) {
$el->setAttribute($attr['name'], $attr['value']);
}
}
}
if ($append) {
$this->appendToRealParent($el);
$this->stack[] = $el;
}
return $el;
}
if you face an error like An uncaught Exception was encountered
the best way is, to actually catch the exception, because you get the answer for your error in your Exception
如果遇到像
An uncaught Exception was encountered
类的错误,最好的方法是实际捕获该异常,因为您可以在Exception
获得错误的答案
the following code snippet should do what i mean 下面的代码片段应该做我的意思
private function insertElement($token, $append = true) {
try
{
$el = $this->dom->createElementNS(self::NS_HTML, $token['name']);
if (!empty($token['attr'])) {
foreach ($token['attr'] as $attr) {
if (!$el->hasAttribute($attr['name']) && preg_match("/[^A-Za-z0-9]/u", $attr['name'])) {
$el->setAttribute($attr['name'], $attr['value']);
}
}
}
if ($append) {
$this->appendToRealParent($el);
$this->stack[] = $el;
}
return $el;
}
catch (DOMException $e)
{
echo '<strong>Errormessage:</strong>'.$e->getMessage().'<br />';
echo $e->getTraceAsString();
}
}
if you have an error now, you should see the exact information in order to fix this error, something like the following occurs: 如果您现在遇到错误,则应该查看确切信息以解决此错误,并且会发生类似以下的情况:
Errormessage: Invalid Character Error
#0 [...][...](7): DOMElement->setAttribute('1pro-1', 'someValue')
#1 {main}DOMException Object
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.