As of version 1.6.7c we introduced a new printstyle value ‚external‘ for Print-O-Matic. Now it is possible to create an external button to trigger a print in a less-hacky way. Here is an example of this works: To print the following div with an id of ‚print_me_please‘:
<div id="print_me_please">This is our target print element</div>
First we create a kind of roll-your-own print trigger. The details that must be included are:
- a unique id
- a print-o-matic class such as
<button id="my_print_button" class="printomatic" data-print_target="#print_me_please">Print Trigger</button>
Which will output:
The final thing we need to do is include a hidden print trigger using a print-me shortcode with the same id as our external trigger and the new external printstyle attribute. This shortcode must be placed someplace on the same page, and will load in all the required scripts and settings to make the print trigger work correctly.
This shortcode will not output anything to the page.
[print-me id="my_print_button" printstyle="external"/]
That’s it. You are done! Let us know on the WordPress Support Forum if you require any further assistance.