0

I am trying to hook into the Print module after to call a custom function after the pdf is generated. I've got this working by simply patching a call back on the wkhtmltopdf.pages.inc:

 if (!empty($pdf)) {
  _callback_for_pdf();
  return $pdf;
}

This is pretty nasty. So ideally I would like to try and extend this contrib module to have a hook for this functionality.

How do I go about adding a hook to something to then use in a custom module?

1 Answer 1

0

Check out this documentation: https://www.drupal.org/docs/7/creating-custom-modules/creating-drupal-7-hooks

For your case, the simplest may work

So lets say your hook you want to be hook_pdf_generated()

module_invoke_all('pdf_generated');

in your custom module, have a function YOURMODULE_pdf_generated()

If you wanted to be able to alter the $pdf variable, use a _alter() hook

So in that code you posted, add:

drupal_alter('pdf_generated', $pdf);

and in your custom module you'd have YOURMODULE_pdf_generated_alter(&$pdf)

4

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.