Jump to content

Can't add image to PDF in event hook (ready.php)


DanielD
 Share

Recommended Posts

Hello. 

I can't add my image logo to the pdf when I generate the pdf in a hook.

$pdf = $modules->get('RockPdf');

$forms->addHook('FormBuilderProcessor::emailFormReady',
  function($e) use ($pdf) {
    $pdf->write('<img style="width: 250px;" src="' . '/var/www/clients/client1/......./img.png' . '">');
    $pdf->save('./generated_pdfs/' . date('yy-m-d_H_i') . '.pdf');
  }
);

This same thing works without a problem and adds the image to the pdf when it's generated outside of an event hook (in the admin I have the same pdf generator). But because I need to generate this pdf on form submit and send it with the mail. I need to generate it in the event hook.

I tried absolute path, relative path, even base64 code (that too works in the admin pdf generator), but nothing seems to work when I try to use it here in the ready.php Hook.

Link to comment
Share on other sites

How does the output look like? Are you sure that the image exists? Well, it should, if it is a static image and in other areas it works as expected... Not sure if $pdf->save() using a relative path for the pdf is a good idea ?  Are you sure that the hook is executed?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...