2 min read

Automatically generating PDF files for a page

Good Eatin’ Goal: Generate PDF files of our pages so that the users can automatically download the pages for printing, or for offline usage.

Additional modules needed: Printer, email, and PDF (http://drupal.org/project/print).

Basic steps

As you continue to work on your web site, you will find that many users want access to your content, even if they aren’t online. With the Printer, email, and PDF module, you can easily and automatically provide content in various formats for offline usage.

  1. To begin with, download and install the Printer, email, and PDF module.

    Freebies and Downloads in Drupal 6

  2. You can now configure the basic options for the module by selecting Site configuration and then Printer-friendly pages from the Administer menu.
  3. The general settings are accessed by clicking on the Settings tab. These settings are shown below, and include options to style the printable pages, and to determine whether or not URLs and comments are displayed on the page. You can also control how the page is opened, and also which logos are displayed on it.

    Freebies and Downloads in Drupal 6

    By expanding the Source URL section, you can cause the URL of the page to be included on the printed output. You can also optionally add the date and time when the page was generated to the printed output.

  4. The printable page (web page) configuration options include a variety of options to control how the links to the printable versions are displayed, as well as how the printable pages are displayed.

    Freebies and Downloads in Drupal 6

  5. We have modified the Printer-friendly page link to be in the Content corner rather than in the Links area. You can also optionally display the printable page in a new window and automatically call the print function, as needed.
  6. Opening the Advanced link options gives you additional options for how the link is displayed, and what pages it should be displayed on, as shown in the following screenshot:

    Freebies and Downloads in Drupal 6

  7. The Robots META tags section allows you to prevent search engines from indexing your printable version, which will help to ensure that visitors are directed only to your online content. This can also help prevent duplicate content penalties being imposed by search engines.
  8. To create PDFs, we need to install a third-party tool to handle the conversion. You can choose from either TCPDF or dompdf, which are available at the following locations:

    You can install and use either of these. You can also install both of them and switch between the two, while you evaluate which one will meet the needs of your site best.

  9. After you have installed TCPDF and/or dompdf, you can access the PDF tabbed page in the Printer-friendly pages configuration.

Subscribe to the weekly Packt Hub newsletter

* indicates required


Please enter your comment!
Please enter your name here