tcpdf-laravel: Undefined property: Elibyy\TCPDF\TCPDFHelper::$h
Hi @elibyy (and others),
I’m recieving structural errors when calling the function below from a queue. When I’m calling the exact same function (with the same content, etc) to render it in my browser, it’s going great. The content is simple plain html, no magic.
The error is:
ErrorException: Undefined property: Elibyy\TCPDF\TCPDFHelper::$h in ../vendor/tecnickcom/tcpdf/tcpdf.php:2793
This is the function; regarding other issues I tried the reset(); method, but no success.
PDF::reset();
PDF::SetTitle('Foobar');
PDF::SetMargins(15,30,15);
PDF::AddPage();
PDF::writeHTML($this->content);
$this->content = PDF::Output('Foobar.pdf','S');
Storage::put($this->archive_file, $this->content);
Do you have an idea what might go wrong? Thank you for your time.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 17 (6 by maintainers)
Hi @elibyy
I’m happy to share what I can with you.
However, after reading your comments on issue 22 I just tried adding
PDF::Reset();to the beginning of my pdf building function.With this, it processes a queue fine; I haven’t had any fails yet.
When I remove that function again, all jobs apart from from the first one, fail.
Luke
This solution works for me. Thx. @lukio3
I’m having the same issue but with the error
Undefined property: Elibyy\TCPDF\TCPDFHelper::$inxobjwhen generating a PDF in a queued mail running from the commandline. Like others already noticed, the error occurs the 2nd time try to use the PDF facade after you already created a PDF. The 2nd time laravel resolves the same TCPDF instance and somehow it’s broken. I started digging into the TCPDF code, but it’s so messy it’s giving me a headache so i chose the quick way out by adding the following code after each PDF::Output() call. This clears the cached instance so when you call the PDF facade again you’re getting a fresh instance.Do note, since we are no longer reusing the TCPDF instance this could lead to memory issues. In production i have a daemon checking the mail:queue command that restart is if it fails.