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?
- How to add a gmap to a pdf?
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_link_class = variable_get('print_html_link_class', 'print-page');
$print_html_new_window = variable_get('print_html_new_window', 0);
$print_html_show_link = variable_get('print_html_show_link', 1);
$print_html_link_text = filter_xss(variable_get('print_html_link_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_link_class);
$new_window = $print_html_new_window;
$format = _print_format_link_aux($print_html_show_link, $print_html_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();
?>
To insert a link to the send by email version:
<?php
print print_mail_insert_link();
?>
To insert a link to the PDF version:
<?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 print.tpl.php 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!
/* Get your gmap_key from the gmap module variable */
$gmap_key = variable_get('googlemap_api_key', "insert_default_key_here");
/* Get a static image */
$staticmap_image = "<p align=center><img border='0' class='gmapimg' alt='Map'
src='http://maps.google.com/staticmap?center=" .
$node->location['lat'] . "," . $node->location['lon'] .
"&zoom=14&size=500x300&markers=" . $node->location['lat'] . "," .
$node->location['lon'] . ",blue&sensor=false&key=" . $gmap_key .
"' width=500px height=300px/></p>";This example uses the location modules lat & lon to set the center and marker for the map. Google defines several variables to manipulate the map. The static map function will return a source image for you to use. Simply print it out in your print_pdf.node-mynodetype.tpl.php file.

Where in popups?
Thanks for the informative help!
Regarding popups - where exactly to change and to what? Which file?
Cheers!
As the answer says: set the
As the answer says: set the e-mail link class to popups-form-noreload
The e-mail link class is an option in the e-mail settings (admin/settings/print/email) and you have to set it to popups-form-noreload. It's all in the Drupal UI.
João Ventura
Venturas.org
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?
also cannot print the link using print_format_link
I have the same issue but cannot see why putting it in my page.tpl would work for me.
this is why:
1) this link should only be present in my custom content type nodes
I worked around this by doing the following:
In my node-[custom_content_type].tpl file in my theme directory, I added (new lines and spaces inserted for clarity in this post):
<wrapper div>
<a
href = "<?php print $node->links['print_html']['href']; ?>"
class = "<?php print $node->links['print_html']['attributes']['class']; ?>"
title = "<?php print $node->links['print_html']['attributes']['title']; ?>"
rel = "<?php print $node->links['print_html']['attributes']['html']; ?>"
> //end of anchor tag
//print the title
<?php #print $node->links['print_html']['title'];?>
</a>
</wrapper>
//THIS DID NOT WORK
//NOTE THAT MY VARIABLE $nodeID is correct
</wrapper><?php print_insert_link("print/".$nodeId);?>
</wrapper>
It was using an obsolete
It was using an obsolete function. The example has now been updated.. In any case, refer to the 'parent' function in the module's source code for the most up-to-date implementation of that example.
João Ventura
Venturas.org
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.
did the same but had to add
did the same but had to add the code to page.tpl.php for my desired display next to the title
Geoff Palin
Permission settings for 'access print' in 5.x-4.7?
Hi,
I just updated my print-module to latest version (from 5.x-3.2 to 5.x-4.7, Drupal is 5.19) but no anonymous user can see the links to print or mail function. The source of the delivered html says
<span class='print-link'></span>where the links should be.
The equivalent part of the same page delivered to user #1 says
<span class='print-link'><span class="print_html"><a href="http://HOSTNAME/..." title="Zeige die Druckversion dieses Inhaltes an." class="print-page" onclick="window.open(this.href); return false" rel="nofollow"><img src="/sites/all/modules/print/icons/print_icon.gif" alt="Druckversion" title="Druckversion" width="16" height="16" class="print-icon" /></a></span><span class="print_mail"><a href="http://HOSTNAME/..." title="Send this page by e-mail." class="print-mail" rel="nofollow"><img src="/sites/all/modules/print/icons/mail_icon.gif" alt="Send to friend" title="Send to friend" width="16" height="16" class="print-icon" /></a></span></span>There is no entry "access print" in the permissions. All available permissions shown are "administer access", "administer settings", "node-specific print configuration" and "use PHP for link visibility".
So, how do I enable PF for anonymous users?
Thanks for help
XL
UPDATE: seems like this was a problem with a faulty translation. I use german interface and somehow the setting items originally called "access print" and "administer print" were translated to "Zugriffskontrolle verwalten" and "Einstellungen verwalten", what translated back to english means what I wrote above. The other two options where still in english.
I don't know, why the translation was not imported correctly and where the wrong parts came from. Maybe a result of the upgrade from 3.2 to 4.7? I'll try to spot that out.
node data not shown in print page
Hi drupal expert am newbie for drupal. i have installed print module in drupal 6.13. It installation and configuration done successfully. But if i click print link In print page not contail form data.
if i use form with static data its work fine instead of data fill by like
<?phpecho $name;
?>
following code work:
<?php
echo '<td>Thiru</td>';
?>
following not work:
<?php$name=$_POST['name'];
echo '<td>'. $name.'</td>';
?>
can anyone help for this....
thanks in advance...
issue using theme_print_manager_print_format_link() in a module
I have a few issues I am dealing with since enabling the (very nicely constructed) print module to do a simple "print this page" (not a pdf)
Note that I have placed these issues is separate posts.
Preface: I have a correctly configured and enabled a "helper module" for dealing with these issues. I also have a .tpl file print_html.node-activity.tpl.php in the same directory that (at the moment) is the same as the print.tpl file.
This post concerns the following:
I cannot seem to get the MYMODULE_print_manager_print_format_link() to work with my module that controls this functionality. At the moment, all I want to do is add a custom wrapper to the link using '#prefix' and '#suffix' .
Here is the code I inserted to wrap the links - - using the theme_print_manager_print_format_link()
function MYMODULE_print_manager_print_format_link() {
//Note that this section is included "as-is" in the print.module
$print_html_link_class = variable_get('print_html_link_class', PRINT_HTML_LINK_CLASS_DEFAULT);
$print_html_new_window = variable_get('print_html_new_window', PRINT_HTML_NEW_WINDOW_DEFAULT);
$print_html_show_link = variable_get('print_html_show_link', PRINT_HTML_SHOW_LINK_DEFAULT);
$print_html_link_text = filter_xss(variable_get('print_html_link_text', t('Printer-friendly version')));
$img = drupal_get_path('module', 'print') .'/icons/print_icon.gif';
$title = 'print this activity';
$class = strip_tags($print_html_link_class);
$new_window = $print_html_new_window;
$format = _print_format_link_aux($print_html_show_link, $print_html_link_text, $img);
//Note that I added the prefix/suffix
return array(
'text' => $format['text'],
'html' => $format['html'],
'attributes' => print_fill_attributes($title, $class, $new_window),
'#prefix' => '<span class = "print-link-wrapper">',
'#suffix' => '</span>'
);
}
It is not seeing the wrapper called for by the prefix/suffix- - is this n
Note that my hook_perm and hook_init work correctly but this function does not seem to matter
This is what is returned via dpr($node->links['print_html'])):
Array
(
[href] => print/8
[title] => print this activity
[attributes] => Array
(
[title] => Display a printer-friendly version of this page.
[class] => print-page node-text-orange
[rel] => nofollow
)
[html] =>
[query] =>
)
So - - 2 questions:
1) why cannot I not seem to use the print_insert_link() function (pre my comment below)
2) why can I not insert the prefix and suffix to this link?
Thanks to all
Anyone help for this ...
Please reply this post...............
update on this issue
I made a silly mistake in the naming of the function - - and also also mis-wrote it in the above - - I think this is correct
- - but it still does not insert the wrapper I want:
function theme_MYMODULE_format_link() {
}
Of course, I realized that all I needed to do was wrap the outputted link - - which I have done - -
I have other issues that are actually real, though
Sorry for the trouble and I will more careful next time.
But can I use my own icon? issnt uptodate
"But can I use my own icon?"
issn't up to date. The function print_html_settings_default() doesn't exist anymore.
Solved the problem by copying theme_print_format_link() from print.module and changing the image path.
Print, PDF, Send by e-mail and MolloM
Is it possible to use MolloM with this module?
regards
Big
values from databse are not printing
all the pages are printing fine.but the parts fetching from databses are ommited from the printing pages.can anyone help me out
PF Link Somewhere Else
Thanks for this great module. I have a question about FAQ #7 above. I have used the "print print_insert_link();" code from above and it works perfectly, creating the link exactly where I want it for several views on my site. The only problem is that when I do this, the link itself also appears in the generated "printer-friendly" page (something that doesn't happen with the module-generate link). Is there a simple "if" statement I could wrap around the code for the link I added that would check whether or not I'm actually in a printer-friendly view so I can skip over the generation of the link? Thanks.
EDIT: As a hack, I can make it work by using this:
if (strpos($_SERVER["REQUEST_URI"], "print") === false){print print_insert_link();
}
which doesn't place the link if the url contains "print" in it, but it's rather inelegant and I'm hoping for a more-robust solution, if someone has one.