Search code examples
magento2html2pdf

HTML2PDF : error (sometimes) when generating, but PDF generated


Let me explain !

I have a magento website. I'm generating custom PDF when my user is making an order.

It works most of the time, but for some reason, sometimes, I have this error :

Undefined property: Spipu\Html2Pdf\MyPdf::$h in ...../vendor/spipu/html2pdf/src/MyPdf.php on line 670"

The line is this :

public function getH()
{
    return $this->h;
}

The class is : class MyPdf extends \TCPDF and in TCPDF, $h is a protected variable

It's weird, knowing that my PDF is saved on my server, and I can open without getting an error..

Do you have any idea of what the problem could be ?


Solution

  • Ah ah got it !

    Forgot to mention, i'm using a loop to make and attach my pdf to a mailer.

    I had to put the declaration of the HTML2PDF inside the loop, not outside (that's make sense).

    Hope this will help !