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).
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.
- To begin with, download and install the Printer, email, and PDF module.
- You can now configure the basic options for the module by selecting Site configuration and then Printer-friendly pages from the Administer menu.
- 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.
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.
- 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.
- 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.
- 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:
- 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.
- 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.
- After you have installed TCPDF and/or dompdf, you can access the PDF tabbed page in the Printer-friendly pages configuration.