My scenario is this, a user selects a bunch of nodes and selects to print all the nodes. What I'd like to happen is, once the user clicks the print button, the print dialog opens up and all the nodes are printed at once. I'm using the Print module and I'm having a hard time figuring out how to print programmatically and all at once.

1 Answer 1


While the print module doesn't have much of an API, you can look at print_controller_html() to see how it renders printed pages:

$query = $_GET;

$html = theme('print', array('node' => $node, 'query' => $query, 'format' => $link['format']));
drupal_add_http_header('Content-Type', 'text/html; charset=utf-8');
print $html;

For your purposes, you can changes a few arguments to the theme function and wrap it around a loop of nodes you wish to print. Something like

$html = '';
foreach($nodes as $node) {
  $html .= theme('print', array('node' => $node, 'query' => $_GET, 'format' => 'html'));

The theme function makes use of a template that you can override in case you want alter the HTML printed in a significant way.

  • Thanks I'll play around with that code and see what I get. I'm also wondering how we'd automatically send that output to the printer once the user clicks the link?
    – SN_26
    Aug 31, 2015 at 8:25
  • Solve one problem before moving on to the next. The Q&A format on Drupal Answers isn't for answering a chain of questions on one post.
    – Shawn Conn
    Aug 31, 2015 at 8:29

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.