Drupal is a registered trademark of Dries Buytaert

partial_page_print

60 sites Security covered
View on drupal.org

Add a button to your page to allow visitors to print part of the current page.

The printed page would use the same theme but without any of the regions, blocks, or other parts of the page that are not desired on the printed page.

Requirements

This module requires no modules outside of Drupal core.

Installation

Install with composer: composer require drupal/partial_page_print then enable the module.

Using

To add the print button to a page, add the following element to the render array in your custom module or with a preprocess hook in your theme. Be sure that the #element_id is populated with the HTML ID of the thing you want to be printed on the page.

 $build['print_link'] = [
   '#value' => $this->t('Print the Content'),
   '#type' => 'partial_page_print_button',
   '#element_id' => 'my_div_id',
 ];

Example

Example of adding the partial page print button to a node template in your site's theme:

In your theme's .theme file:

function function MYTHEME_preprocess_node(&$variables) {
 $variables['nodeSummaryPrintButton'] = [
   '#value' => $this->t('Print Summary'),
   '#type' => 'partial_page_print_button',
   '#element_id' => 'node-summary',
 ];
}

In your theme's node template:

<article>
  {# ... #}
  {{ nodeSummaryPrintButton }}
  <div>
    {# Node summary here #}
  </div>
  {# ... #}
</article>

Activity

Total releases
1
First release
Jul 2025
Latest release
7 months ago
Release cadence
Stability
100% stable

Releases

Version Type Release date
1.2.0 Stable Jul 10, 2025