Print Specific Area of the content

Print Specific Area of the content

Posted byvarghese.t,30th Nov 2016

Area Print

Area Print is a simple module that lets you add the print button or link that sends any given element(with id) to the printer. All Drupal-CSS is applied and you can append your own on top of that. In its current form, the module provides only API-like functionality, no UI at all, though this may change in the future. USAGE: Where ever you can add the  php code(php-field, text-area with php input format, custom module, template, etc.), you can call the button like this: print area_print_form($options); where $options is an associative array containing: - target_id: Id of the element you want to print (optional, defaults to 'content'), - button_id: Id that will be given to the print link or button (optional, defaults to 'area_print_button'), - value: The text for the link/button (optional, defaults to t('print')), - type: either 'link' or 'button' (optional, defaults to 'button'), - custom_css: path to a css file that will get added to the page before printing (optional). Example: In your custom template, or the PHP-node, or somewhere:

1. First, define your printable area like this:

I want to print this!

2. Then print the button:

KNOWN PROBLEMS: As always, Internet Explorer acts unlike all the other browsers, and this module is no exception. There is a problem where IE cannot "catch-up" with the changes made to the page with javascript before printing and closing the page. As a temporary solution, when you print with IE, you will see an alert box saying "Press OK to print". This gives the browser enough time to complete its tasks. I will try to come up with a better solution, but in the meanwhile, this works(and patches are welcome).