I use a script to send a PDF by mail, with a custom print.tpl.php in theme directory.

the script used is:

<?php
  module_load_include('inc', 'print_pdf', 'print_pdf.pages');  // require print_pdf.pages.inc

  // set up email
  $recipients[] = email@example.com;
  $subject = "Your PDF is attached";
  $body = '<p>Your PDF is attached</p>';
  $path = 'node/' . $node->nid;
  $attachments[] = array(   // attach ticket
    'filecontent' => print_pdf_generate_path($path),  // call the print_pdf function to generate PDF content string
    'filemime' => 'application/pdf',
    'filename' => $filename,
  );

  // send email
  mimemail( $settings['from'], $recipients, $subject, $body, FALSE, array(), drupal_html_to_text(decode_entities($body)), $attachments );
?>

Now, if I echo $print['node'] variable i have 2 different results:
1 - if I open the printable version, or download the pdf version through the browser at /printpdf/nid, I get the full node variable printed, with all cck fields, path alias, taxonomies, etc.
2 - if I send the pdf by mail, using the script, i get only these 3 vars:
$print['node']->body (full themed node using node.tpl.php)
$print['node']->title
$print['node']->path (node path NOT using path alias)

Comments

feo’s picture

I have similar case on Drupal 7 with PDF generation.

jcnventura’s picture

Category: bug » feature
Status: Active » Fixed

@FeBus982: sorry for taking so long to reply to this.. I don't usually support other people's code, and I was hoping you'd solve it yourself, and close this.

However, since it might be useful for others, the reason your code is behaving like it is is because you've prepended your path variable with 'node'.. By doing so, you're using the alternate Drupal rendering scheme which asks Drupal to render the whole page and to return the HTML. This mode doesn't use the configured build modes nor any of the module templates.

Simply remove the 'node' from line 8 in your code, and the behavior should be the same as you get in printpdf/nid. The way you're doing it now you're getting the result of calling printpdf/node/nid.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.