Adding a hook to a contrib module
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(&amp;$pdf)