Closed acirinelli closed 3 years ago
Well, I tried it using my own fork and it didn't seem to work (bummer): https://github.com/acirinelli/tcpdf-laravel/blob/master/src/TCPDF.php
Done a bunch more testing and cannot find the exact cause of this issue other than it only happens when using implements ShouldQueue
Hey there, Sorry for the delay, was kinda busy lately, I don't know if this is still relevant but, could you provide a trace generating that error?
@elibyy I'm not sure how to do what you're requesting unfortunately. I just had to stop using queues for PDFs.
When you get the error, it should tell you where the error is actually occurring maybe in the logs or maybe in the HTML directly
@elibyy well the issue is that I cannot produce this error on my homestead/vagrant machine. It only gets thrown on a production instance on AWS. The error only occurs when the PDFs are being generated through a queued event listener. The same code runs perfectly fine when fired though a synchronous request, i.e. not queued. I spent hours trying to trace this bug and ultimately it led me to what I described in my first post. No matter what, it throws the $h variable error first. So then I set pdfReset() to solve that and things seem fine until it gets fired through a database queued job, at which point it cannot find the relative font directory (which for the record, it could possibly be unrelated). And even if I locate the fonts at '../public/fonts', it still cant find them. It completely ignores the specified font directory in tcpdf config. In order to come up with an error log that might be helpful, I would have to allow this bug to occur on production and then grab the failed job out of the database.
@elibyy I'm creating multiple PDFs and doing so through event listeners. I'm fighting two bugs that seem to contradict each other. First issue is this one:
Undefined property: Elibyy\TCPDF\TCPDFHelper::$h
I understand the fix is to addPDF::reset()
after the output.However when I do that, I get a different error (that only appears with PDF::reset()) as such
opendir(../public/fonts/): failed to open dir: No such file or directory
. The weird thing is that I cannot create this on homestead and when I checkTCPDF_FONTS::_getfontpath()
it's correctly pointed to this configuration: 'font_directory' => app_path('fonts/'). I'm not even using the directory public/fonts, yet it's somehow reseting to that on the production server. I'm at a complete loss at this point.Thinking maybe PDF::reset() needs to also reset the config for the fonts directory to override
define ('K_PATH_FONTS', K_PATH_MAIN.'fonts/')
? i.e.Config::get('tcpdf.font_directory', '')