An interesting thing you might not know is that you can dynamically control the print preview UI on your site. By default the browser will choose what to print (most likely the whole window itself), however there are several jQuery plugins out there that will give you control over what is printed.
While print plugins might not be the most exciting plugins out there, here are some you might want to look into. We'll also touch on how you can build this functionality yourself if you're adventurous.
Note: Ancient browsers (I'm looking at you IE8) might behave strangely when using some of these plugins. However all modern browsers handle print previewing in a consistent way so keep that in mind if you need full comparability.
jQuery Print Preview
This small jQuery plugin lets you open a new browser window to display specific parts of your site for printing. Unlike some of the other plugins on this list, this plugin doesn't directly trigger the browser's print functionality, it simply opens up a minimal window (which is perfect as you can now print it directly).
The plugin's usefulness is for when you have sections of data you want to print e.g a card of information or a row in a table. You can open it up in a new window (providing configuration options to the plugin) and then print from there. This ensures that you're only printing the content you need.
Its browser support seems pretty comprehensive and worked well across my modern browsers.
It's unfortunately not on GitHub so it's hard to know if this is being actively supported. However that shouldn't deter you, You should see if it works for you and then use it 'as is'.
jQuery Print Plugin
Don't let the ugly demo fool you. The jQuery Print Plugin works well and offers a range of settings for you to customize your printing needs. For example, you can set if the popup will take place in the current widow (via an iFrame), set the time to wait before the print display renders and place content before / after the popup.
To get up and running just pass it a jQuery object or selector and off you go, the plugin does the rest.
The author has pushed out a few commits in 2016 to improve the plugin. While there aren't many commits, it still looks like it will continue to grow.
Continue reading %5 jQuery Print Page Options%
by Simon Codrington via SitePoint
No comments:
Post a Comment