Print: 5. Frequently Asked Questions
Questions
- I have enabled the module, but the PF page link is not showing up!
- The Printer-friendly version in book nodes is not working correctly.
- The book pages still display the text "Printer friendly pages," and no icon
- Can I replace the 'Printer-friendly version' link with an icon?
- I can't see the icon-only option!
- But can I use my own icon?
- Is it possible to place the PF link somewhere else?
- Is it possible to change the styles used in the PF page?
- Is it possible to define a template for a specific content type?
- I don't like the template used. Can I use another?
- I am using a custom template but nothing seems to be working correctly. What's the problem?
- The blocks I have in the 'content' region are not showing up! Why?
- I see a lot of PHP warnings of the type: warning: array_map() [function.array-map]: Argument #2 should be an array in /home/site3/html/sites/all/modules/print/include/abstract_renderer.cls.php on line nnn
- dompdf or TCPDF don't work!
- I am a module author/maintainer. Is there a way to know when a node is being built by the print module so that I can disable my output?
- How can I make the e-mail form show in a pop-up window?
- I have a problem/question not answered here. Where can I go for help?
- Domdpdf doesn't like shorthand css?
- How to add captcha?
Answers
- I have enabled the module, but the PF page link is not showing up!
-
There may be several reasons for this, but try the following in order (you must have appropriate permissions to perform some of these steps - login as user #1 if you don't):
- Make sure that the module is enabled (the check-box next to 'Printer-friendly pages' in admin/build/modules must be ticked).
- In admin/user/access under the print module heading make sure that you have enabled access to the desired groups. In most cases, you will want to tick the 'access print' boxes for all groups, and clear the 'admin print' boxes for all groups except the administrator group (if defined).
- In admin/settings/print, make sure that you have enabled the PF link.
- For each content type x, check in admin/content/types/x that the 'Show printer-friendly version link' is enabled.
- The Printer-friendly version in book nodes is not working correctly.
-
If you're using Drupal 4.7.x, that PF link is managed by the book module and this module has nothing to do with it. If you're using Drupal 5.x or later try to enable the 'Take control of the book module printer-friendly link' in the Printer-friendly settings form and see if you like it better that way.
- The book pages still display the text "Printer friendly pages," and no icon
-
It's not a bug.. The 'take control' is precisely that.. Take control, not replace. The book module's link is still left intact, but instead of generating the page via the book module, some of it is generated by the print module.
It's not easy to solve the problem, as I don't want to hijack core features more than I need to, and in this case, there may be themes/modules that are already handling the PF page link in book nodes in ways that would be broken if I were to completely replace the link.
- Can I replace the 'Printer-friendly version' link with an icon?
-
Yes. In the module's settings, set the page link to 'icon only'.
- I can't see the icon-only option!
-
The advanced link options fieldset is a collapsible fieldset, that is collapsed by default. Click on it to expand it (that's what the arrow on the left means).
- But can I use my own icon?
-
You will have to define a theme_print_format_link function which will replace the module's function with the same name and where you can indicate your custom-defined icon, and set the html element to true so that your image tag is interpreted as HTML. See the following for an example:
<?php
function theme_print_format_link() {
$print_html_settings = variable_get('print_html_settings', print_html_settings_default());
$text = t('Printer-friendly version');
$img = local_path_to_your_img_file;
$title = t('Display a printer-friendly version of this page.');
$class = strip_tags($print_html_settings['link_class']);
$new_window = $print_html_settings['new_window'];
$format = _print_format_link_aux($print_html_settings['show_link'], $text, $img);
return array('text' => $format['text'],
'html' => $format['html'],
'attributes' => print_fill_attributes($title, $class, $new_window),
);
}
?>
- Is it possible to place the PF link somewhere else?
-
Yes, but you have to take care of it. Disable the PF link in admin/settings/print and you're then free to place a link to print/nid or to print/path_alias wherever you want (such as a block or the node content). I recommend the following code to place the link, as it maintains the configurable attributes:
<?php
print print_insert_link();
?>If you're using the Print PDF Module
<?php print print_insert_link(); ?>
won't print the 'PDF version' link, to print it you have to add:
<?php print print_pdf_insert_link(); ?>
- Is it possible to change the styles used in the PF page?
-
You can always change them easily. You can either:
- Edit the print.css in the modules directory, or
- Define your own CSS with the appropriate styles and specify it in the module settings.
- Is it possible to define a template for a specific content type?
-
Yes, the module will try the following locations for the PF page template:
- print_format.node-type.tpl.php in the theme directory
- print_format.node-type.tpl.php in the module directory
- print_format.tpl.php in the theme directory
- print_format.tpl.php in the module directory
- print.node-type.tpl.php in the theme directory
- print.node-type.tpl.php in the module directory
- print.tpl.php in the theme directory
- print.tpl.php in the module directory (supplied by the module)
format is either html, mail or pdf, and type is Drupal's node type (e.g. page, story, etc.)
I recommend that you edit the module's print.tpl.php to suit your tastes instead of creating something from scratch, as it is easier to remember the name of the members of the $print array and the names of the used styles.
Note that since you are creating your own template, if you want to use per-content-type styles, you can simply ignore the $print['css'] setting and hard-code your own per-content-type CSS file in your new template. Or you can define your own per-content-type styles to store in the configurable CSS file. Your choice!
- I don't like the template used. Can I use another?
-
See the above question on how to do it (or you can always simply edit the module's print.tpl.php).
- I am using a custom template but nothing seems to be working correctly. What's the problem?
-
Are you using the $node variable in your template? Be aware that the print module's template is not a normal Drupal template, so access to $node (among others) will not work. To fix this, place the following early in your template:
<?php
$node = $print['node'];
?>
- The blocks I have in the 'content' region are not showing up! Why?
-
First, if it is content, then it should be content.. Stuff placed in blocks is usually not content, and as such, should not appear in the printer-friendly view. That being said, if you really, really want it, add the following to your template:
<?php
print theme('blocks', 'content');
?>
- I see a lot of PHP warnings of the type: warning: array_map() [function.array-map]: Argument #2 should be an array in /home/site3/html/sites/all/modules/print/include/abstract_renderer.cls.php on line nnn
-
This is caused by a bug in domdpf's code. It is not possible to be fixed by this module. You can however edit line 42 of dompdf_config.inc.php to:
error_reporting(0);
- dompdf or TCPDF don't work!
-
I don't maintain those libraries. Please check the libraries websites, and when applicable report the error to the author/maintainer:
- TCPDF: http://tcpdf.org
- dompdf: http://code.google.com/p/dompdf/wiki/FAQ
- I am a module author/maintainer. Is there a way to know when a node is being built by the print module so that I can disable my output?
-
Yes, if
$node->printingevaluates to true, disable any output that is not suitable for a static page.
- How can I make the e-mail form show in a pop-up window?
-
Use the Popups module and set the e-mail link class to popups-form-noreload.
- I have a problem/question not answered here. Where can I go for help?
-
Simply post a new issue in Drupal's issue system: http://drupal.org/project/issues/print
If possible, send me an e-mail with the link to your Drupal system where I can see the problem you are reporting.
- Domdpdf doesn't like shorthand css?
-
Dompdf seems to have the best support for CSS, however it is very picky. It does not like CSS shorthand
font: italic small-caps bold 12px arialIt prefers explicit statements (font-family, font-size, etc). It also seems to prefer class selectors ("class=whatever") over id selectors ("id=whatever"). It does support page breaks via CSS
<div style="page-break-before: always;"></div>
Also, when rendering images, use CSS to correctly set the size.
- How to setup Captcha?
-
This is fortunately easy due to the captcha module
http://drupal.org/project/captcha
Once installed you can click this setti
"Add CAPTCHA administration links to formsngs"
Now visit any send email form and click the link "Add Captcha" to this form.
Now choose the type you want and you are done!

Where in popups?
Thanks for the informative help!
Regarding popups - where exactly to change and to what? Which file?
Cheers!
Not in Drupal 6?
theme_print_format_link() in the example above doesn't seem to work in Drupal 6. Am I missing something? Has this changed?
Adding links in custom node template.
***Drupal 6.12***
I add
<?phpprint print_insert_link();
?>
to my custom node-custom.tpl.php but nothing prints.
I'm using a zen sub-theme. Any help would be appreciated.