Print module PDF attachment I have a custom module that provides a path that sends an email (mimemail) with a pdf attachment generated from the print_pdf module that comes with the print module.
Here is what my HOOK_mail function looks like.  

function custom_send_email_mail($key, &amp;$message, $params) {
  $node = $params['node'];
  $user = $params['user'];

  $message['subject'] = t($node-&gt;title.' attached');
  $message['body'] = 'Hello '.$user-&gt;name.'&lt;br&gt;&lt;br&gt;Please find '.$node-&gt;title.' attached.';
  //$message['params']['attachments'][] = $attachment;

  module_load_include('inc', 'print_pdf', 'print_pdf.pages');

  $attachment = array(
    'filecontent' =&gt; print_pdf_generate_path($node-&gt;nid),
    'filemime' =&gt; 'application/pdf',
    'filename' =&gt; $node-&gt;title.'.pdf',
  );
  $message['params']['attachments'][] = $attachment;

}


The problem I have is that the pdf versions of pages use a template file, which works fine when navigating to the pdf version url, ie. /printpdf/nid but when getting the pdf file string with the (silly named) print_pdf_generate_path() function, it does not use the template file.
It seems it was a silly mistake on my behalf.  

My module defined a custom path to send the email and the theme files for the pdf were in the admin theme folder, so I had to set my path to use the admin theme for the email theme files to be found.
I did so by implementing HOOK_custom_theme.

function custom_send_email_custom_theme() {
  return variable_get('admin_theme');
} 


I will leave this question up as the code may help someone in the future (and maybe me if I need to send an email with attachments again :) )