35 How to Print your Blogger Posts Effectively
Wednesday, May 28, 2008 /

As many of the posts here are tutorials, I thought it would be useful for readers to print off individual blog posts for future reference. Sure, it would be possible for a reader to choose the "print" option from their web browser window, but this would have printed the header, sidebars and other irrelevant sections of the blog, wasting paper and ink and time.

Using a combination of CSS and JavaScript, I've developed a simple yet effective method of printing only the blog post (and comments) from each blog page.

In this post, I'll explain how you can also add effective print functionality to your Blogger posts in just two simple steps.






To get an idea of what this post would appear like when printed, use the "Print Preview" function in your web browser. Whereas the current page appears colorful and includes the header, sidebars and other elements of this template, printed pages from this blog will appear like this instead:

As you can see in this example:

  • The header and sidebar sections do not appear

  • Text is black printed against a plain white background

  • The post spans the width of the printed page

  • The post retains images and formatting

  • Only the necessary areas will be printed!

How to install effective printing format for your Blogger posts

Although it took me a few attempts to ensure my posts would print in this way, I have created this tutorial to make it simple and fast for you to install in your own blogs.

There are only two steps to add this functionality to your own Blogger template:

  1. Add a few lines of CSS code (to make printed pages appear in this way)

  2. Add one line of JavaScript beneath your posts (which creates a link for readers to print the post)

There are a few different options for the style of the print link, as I'll explain below.

Add CSS Style Code to your Blogger Template

To add the print styling code to your Blogger template, simply go to Layout>Edit HTML in your Blogger dashboard, and search for the closing </head> tag.

Immedietly before this line, add the following lines of code (copy and paste this directly to your Blogger template):

<style media='print' type='text/css'>

#header-wrapper, #header, .header, #sidebar-wrapper, .sidebar, #footer-wrapper, #footer, .date-header, .post-meta-data, .comment-link, .comment-footer, #blog-pager, #backlinks-container, #navbar-section, .subscribe_notice, .noprint {display: none;}

#main-wrapper {width: 95%}

</style>

If you like, you can preview your blog before saving. On this preview page, you'll be able to see the print preview displays only your blog posts (not the sidebar or other unwanted areas).

Finally, save your template.

Add a "Print this post" link

To notify your readers that your posts can be printed effectively, you'll probably want to add a "Print" link beneath each of your Blogger posts.

I've created three different styles for the print link, so you can choose the option which works best for your overall design.

To add the print link, go to the "Edit HTML" page again, and this time ensure that you've ticked the "expand widget templates" box.

Now search for this line:

<p><data:post.body/></p>

Immediately after this line, paste one of these three sections of code:

For a simple text link:

<b:if cond='data:blog.pageType == &quot;item&quot;'>
<a href='javascript:window.print()'>Print this post</a>
</b:if>

For a button link


<b:if cond='data:blog.pageType == &quot;item&quot;'>
<form>
<input type="button" value="Print This Page" onClick="window.print()" />
</form>
</b:if>

For a snazzy link with printer icon

<b:if cond='data:blog.pageType == &quot;item&quot;'>
<span style='background: url(http://bloggerbuster.com/images/print.gif) left no-repeat; padding-left: 20px;'><a href='javascript:window.print()'>Print this post</a></span>
</b:if>

Once you have added this code, save your template. These links will only be visible on post pages (to enable visitors to print the full post and any comments which appear beneath the post), so visit one of your post pages to see the link in action.

You can see an example of the print link near the bottom of this post. If you click on this link, you will be prompted to print this entire post (and comments) using your default printer.

Why it may be useful to enable printing for your Blogger posts

If you publish tutorials or lengthy content, your readers may benefit greatly from being able to print and read your posts offline.

Using the methods outlined here, readers can print only the content of your posts, and not the unnecessary distractions of the sidebar, footer and header sections (which saves on paper and printer ink too!).

You may also want to print off your blog posts for your own benefit, such as to back up your posts in print format, or to demonstrate your abilities in a print portfolio.

Unlike other plugins I have come across, this method also allows you to print any comments under your post too. Comments can add a great deal of value to blog posts, and may contain reader insights which are not included in the body of the post itself.

I hope this tutorial has been useful for you! Please feel free to print this off for future reference ;) and as always your comments are most welcomed.


35 comments:

February 18, 2009 at 7:46 PM
Jack B said...

Hey Amanda,

Wanted to say that your blog is so helpful!

I was wondering how do I do this in the old blogger??

Thanks

February 19, 2009 at 5:30 AM bogujoy said...

thanks for amazing code:D
I want to make a exporting of a post in .doc or/and in .pdf format.

February 24, 2009 at 1:12 PM Anali said...

Hi Amanda,

Thank you for this post! I was able to do the first part, but not the second. I'm not finding the "data post body". I tried pasting near something similar, but it didn't work. Any suggestions? Thank you!

March 3, 2009 at 5:44 PM Anali said...

I found it and got it to work. Thank you Amanda!!!

March 8, 2009 at 8:25 AM Sócrates said...

Thank you very much, man! This results very well for my blog. It`s a nice function!!+

Greetings from Venezuela...

March 8, 2009 at 8:27 AM Sócrates Adamantios Tsokonas said...

Thank you very much! Greetings from Venezuela, this results very well for my blog. It`s a nice function.

March 21, 2009 at 8:39 PM tutorialblogmarine said...

hm nice post :D

http://trik-tipsblog.blogspot.com

April 6, 2009 at 12:39 PM Lynette said...

I can't find my html line for the print code that starts with ....
Can someone tell me where to look???

Thank-you, Lynette

April 8, 2009 at 11:21 AM Jess said...

Hi Amanda. I love this fix, however even after adding the overflow bit that C. August came up with, only one page prints in Firefox. (On your blog as well) Any chance of updating this so it will work? Thanks!

April 11, 2009 at 1:39 PM Ben Udell said...

Removing the "overflow:hidden" under "#main-wrapper" lets me print out more than one page of a Blogger blog in Firefox. (I leave "overflow:hidden" in place for "#sidebar-wrapper" which I have set to disappear from printing anyway). The "overflow:hidden" is "fix for long text breaking sidebar float in IE" according to a comment next to it.

April 11, 2009 at 1:49 PM Ben Udell said...

Even better: Instead of removing "overflow:hidden" from under "#main-wrapper",
leave it there, but

under your section
style media='print' type='text/css'

where you already have
#main-wrapper {width: 95%}

make it:
#main-wrapper {width: 95%; overflow: visible;}

April 15, 2009 at 9:40 AM
Anonymous said...

Hi
thnx for this tutorial,i'm a beginner & i have a problem when i click on 'print this post' i get all the blog printed (sidebars in one page), logo in another page, post in another page too
so is it cause in my template used different words for ex: #sidebar-wrapper in my template i have #sidebar1-wrapper,,please help me

April 15, 2009 at 4:29 PM Suzanne said...

I really appreciate your tutorials, Amanda. They have been extremely helpful to me.

April 20, 2009 at 5:04 PM New Kid said...

Still not working with Firefox, I've tried all your fixes. It works 100% on Safari and I'm awaiting feedback on IE

On all browsers the text is coming out as a long column rather than a paragraph. Help?

Blog in Question Thoughts?

May 5, 2009 at 2:39 PM New Kid said...

Anyone checking the comments and helping?

May 19, 2009 at 6:56 AM
Carlisle Daily News said...

Hello, love this and it really has helped some troubled users. My only concern is that my right rail items ads, widgets, etc still are appearing on print preview and print out. How do I remove those two columns in print mode? Thanks!

Carlisle Daily
carlisledaily.com

May 26, 2009 at 6:13 AM Toyota Tacoma Parts said...

Thanks for such a useful post. I was looking for such information.

June 4, 2009 at 6:38 PM Eikelein said...

Well, I don't get it.
I know I did EXACTLY as described here.
Stumbled at Find "data:post.body".
This code just is NOwhere in the default template.
I know I'm too late to the party but needed to vent.

June 7, 2009 at 12:22 AM Babu said...

Hi Eikelein!

First you Check "Expand Widget Templates"

Then you find this code, you will get it

Regards,
Babu A
http://blog-mstechnology.blogspot.com/

June 7, 2009 at 12:23 AM Babu said...

Thanks Amanda!

Regards,
Babu A
http://blog-mstechnology.blogspot.com/

June 14, 2009 at 1:22 AM arevamirpal::laprimavera said...

I use 3-column template, not the blogger default 2-column. Your code doesn't seem to work for my template. I have narrower right column and left column, and the middle column is the post. Can you help?

June 15, 2009 at 7:30 AM Tally said...

Thank you so much!
And also C.August in the comments.

At least I'm able to print out properly my own blog.

June 18, 2009 at 1:14 PM
Anonymous said...

I want to print ALL my posts out to one file -- without the paraphernalia, and without the dates, with a page break forced at the end of each posting. Is there a way to do this? Or even better, import all of them into Word without the extra stuff?

July 6, 2009 at 11:42 AM Jennifer said...

Found you on Google...
thanks for the tip, but any additional tips on how to print post without comments?
Thanks
Jennifer

July 21, 2009 at 11:40 AM
Karagala said...

it did print the post but it printed only up to 3/4 of the post. I'll try to find ways to get around it. Thanks for the tip

July 21, 2009 at 1:47 PM
Karagala said...

my print starts at the middle of the paper. I followed Cs advice. Any ideas?

July 23, 2009 at 9:05 AM JadeLD said...

This is great thanks, just found this by accident. It's working well, but does anyone know how to stop my photos splitting across a page?
Jade

July 29, 2009 at 11:00 AM June Freaking Cleaver said...

Thank you for this! Yours has been the only instructions that told me to put the code AFTER the data:post.body line - the rest have said to replace it - no wonder it never worked!

August 12, 2009 at 10:44 PM Tara said...

Thank you so much. I can now print off our family blog to keep as a record. The only thing I can't do is print posts longer than one page as the second page doesn't show up. How do I fix this? Also I can't read the answers to the above questions. How do I do that. Thank you. Tara

August 20, 2009 at 9:54 AM matematica-na-veia said...

Valeu!Uma dica importantíssima para dar uma "cara" mais profissional para blogs.
Muito bom mesmo! Abraços,
Antonio.

August 21, 2009 at 5:32 AM Adam J. Fein, Ph.D. said...

Amanda,

This solution works well in Firefox, but only works in IE versions 7 and below. For some reason, IE8 does not format properly.

Any ideas? Can you update the post with a fix for IE8?

Implemented on my blog: http://www.drugchannels.net

Thanks,
Adam

August 22, 2009 at 10:32 AM SBA said...

@Tara It works for you in IE but not Firefox --- which needs the overflow setting. Try this, replace:
#main-wrapper {width: 95%} with the following statement covering your main and content wrappers to be safe:

#main-wrapper, content-wrapper {width:95%; overflow:visible !important; float:none; border:0px; margin:0px; padding:0px;}

I have more detailed explanations on my blog, but this should work for you.

September 4, 2009 at 4:56 AM Adam J. Fein, Ph.D. said...

FYI, SBA helped me implement this solution and fix an IE8 problem with Amanda's approach. You should check out his post: http://bpwebnews.blogspot.com/2009/08/how-to-create-print-this-post-button-on.html

Adam

Post a Comment