Printing and Previewing Web Page using Link Tag

by Rod 4/15/2008 2:08:00 PM

Print Preview.zip (11.73 kb)

Printing and previewing web page is a common requirement for a web application. The tranditional way of launching a printable version of the form is by using a popup window or sometimes a simple redirect to printable version of the page. This allows the user to preview and print a version of the page without the header and footer, ads, company logo, colorfull graphics, and other printing overheads to save resources (printer ink, paper, etc).

One trick to do this without redirecting or launching a pop-up window is through using <link> tag. Just add a link tag and set the media attribute to print, rel attribute to alternate, and set the href to the path of the printable version of the page then you are done. After adding the link tag, try previewing the page using File | Print Preview menu of your IE browser. In preview window you should see the printable verstion page instead of the current page.

Snippets

      <link rel="alternate" media="print" href="Print.aspx?id=1" />  

I added a query string in href to show that it is possible to provide it to dynamically load content and to reuse the template to other pages. 

The major disadvantage of this approach is that it is only supported IE 6.0 or later browser :(.

Attached is the sample code which includes static and dynamic version.

Cheers!

Rod

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , ,

Tips and Tricks

Related posts

Comments

4/15/2008 5:49:09 PM

Chris Ongsuco

Great post, Rod! Very helpful as usual. ;)

Chris Ongsuco ph

4/16/2008 4:21:41 AM

Marvin Trilles

You never cease to amaze us!!!!

Marvin Trilles ph

4/17/2008 4:15:57 AM

Leo Camalig

Nice example sir... Always naman e..

I want to learn about paging, can you write an article and tricks also on it....

Thanks...

Leo Camalig ph

5/25/2008 6:48:52 PM

Joseph De Guzman

Nicely done! I miss working with guys like Rod...you really know the lion by its paw

Joseph De Guzman sg

2/5/2009 9:57:06 PM

Plastic Prototype

Good idea. I usually just set my media to "all" so if someone does print the page, all the dropdowns aren't expanded. This is so much better because it saves on printing all the extra stuff that's not needed. Thanks!

Plastic Prototype us

2/9/2009 7:41:49 AM

Rod

One trick to hide objects you don't want to be printed is to create a css class that hides controls/objects when printed.

<style media="print">
.noPrint { display: none }
</style>

Any data that uses noPrint class will not be printed.

Rod us

3/12/2009 10:46:23 AM

Treasure Islands Bolinao

Thanks for sharing the codes of printing and previewing webpage.

Treasure Islands Bolinao us

5/13/2009 8:40:07 AM

Vinyl Banners

its good know this one from you, good luck

Vinyl Banners us

6/18/2009 7:24:51 AM

Butuan City

thanks for the codes...







http://www.butuanexpats.com

Butuan City ph

7/1/2009 2:01:30 PM

product

Yes, this technique really helps save good money.

product us

7/11/2009 9:00:46 PM

California County Lawyer

Now I knew the different ways in Printing and Previewing Web Page using Link Tags. Thanks for this information

California County Lawyer us

7/16/2009 9:32:00 AM

Social network marketing

Hi,
Search Engine Optimization is a changing field. At any given moment in time, companies that rely on the web for new business or customer communications will consume information about SEO and then rely on that snapshot for months or even years.

Social network marketing us

8/17/2009 5:03:33 PM

Bid Online

Thank you very much for this helpful article! Keep on posting!

Regards

Bid Online us

8/29/2009 2:46:26 PM

latina dating

Great article. Where else could anyone get that kind of information in such a perfect way of presentation.

latina dating us

9/24/2009 8:02:01 PM

Poster Printing

Do you accept guest posts? I would love to write couple articles here.
I was wondering what is up with that weird gravatar??? I know 5am is early and I'm not looking my best at that hour, but I hope I don't look like this! I might however make that face if I'm asked to do 100 pushups. lol

Poster Printing us

10/13/2009 2:00:06 PM

cash loans

I never thought of that this way .. good writing.

cash loans us

10/28/2009 12:32:39 AM

fast cash loans

I just hope to have understood this the way it was meant

fast cash loans us

10/30/2009 11:57:01 AM

online dating sites

That is so great. Now I have found the right tool for me. You really gave me an idea on how to setup those things. Such a great help, thanks for the post and keep it up!

online dating sites us

11/2/2009 10:32:40 PM

scratch and dent

good post Thank for sharing

scratch and dent us

11/10/2009 5:35:44 AM

waggi

Great post.

waggi us

11/10/2009 5:48:42 AM

Miami Search Engine Optimization

In every link and keyword tag is very important because it take if this are click able or not. And it depends to the site if they are open to use a tag like [URL="site"]Keyword[/URL] or <a href="site">Keyword</a>.

Miami Search Engine Optimization us

11/10/2009 5:14:57 PM

cash advance

This my friends is old news - try to update this.

cash advance us

11/13/2009 3:56:43 AM

Registry Cleaners

Do you accept guest posts? I would love to write couple articles here.
I was wondering what is up with that weird gravatar??? I know 5am is early and I'm not looking my best at that hour, but I hope I don't look like this! I might however make that face if I'm asked to do 100 pushups. lol

Registry Cleaners us

11/17/2009 1:13:08 PM

payday loans

I like what I see. keep it going

payday loans us

11/19/2009 10:04:53 AM

Private Labeling

Admiring the time and effort you put into your blog and detailed information you offer! I will bookmark your blog and have my friends also check up here often. Thumbs up!

www.rogenstudio.com

Private Labeling us

11/19/2009 6:14:03 PM

Phil

I'm running on automatic pilot right now. A lot of what you've heard may sound confusing. It's a lot harder to find something to praise in computers. That's what I was thinking. I think the elements I laid out are a great start point for printing. I do use that term loosely as I'm always learning things about web pages and here's an example of how I would go about it. I want to feel optimistic. I want to avoid feeling swamped. All is well that ends well. Computers are highly complex at times. Is it possible that computing is a problem for you? Don't worry.
http://livewrong.net/

Phil gb

11/24/2009 7:35:43 AM

Environmental cleaning services

I am really amazed on how you sincerely share your knowledge you really take time to even provide moresamples and helpfl tools.

Thanks

Environmental cleaning services ca

11/25/2009 7:15:28 PM

slot machines free spins

wow it looks really really nice and interesting, my respect

slot machines free spins us

11/30/2009 2:59:57 PM

faxless payday loans

Thank you for your help!

faxless payday loans us

12/3/2009 7:02:49 AM

Cheap auto insurance quotes

Good idea. I usually just set my media to "all" so if someone does print the page, all the dropdowns aren't expanded. This is so much better because it saves on printing all the extra stuff that's not needed. Thanks!

Cheap auto insurance quotes us

12/6/2009 11:39:48 PM

web application development

Thanks a lot for the great and interesting post man. It was really interesting to read your article about Printing and Previewing Web Page using Link Tag. Reading your post I have found some interesting things which I have not known before. Thanks a lot for sharing it and I will definitely bookmark your blog man.

web application development us

12/9/2009 4:19:03 PM

Spanish Dating

It looks like your topic is interesting. Thank you for the trick and it seems useful to us. Thanks for sharing about printing and previewing page with the use of link tag. Hope you will post another interesting topic just like this.

Spanish Dating us

12/13/2009 8:19:27 PM

pingback

Pingback from wickedblogging.com

¤ Understanding 24 Hour Payday Loan California ¤

wickedblogging.com

12/18/2009 6:01:24 PM

guys dating tips

This is such a great resource that you are providing and you give it away for free. I love seeing websites that understand the value of providing a quality resource for free. It’s the old what goes around comes around routine.

guys dating tips us

12/19/2009 1:29:47 AM

Chris

I had never seen this topic spelled out like this before. Good post.

Chris us

12/19/2009 11:00:37 AM

Sikat ang Pinoy

It's exactly what I've been looking for. I STRONGLY recommend your blog to to my friends. I visit your blog often because it's very informative and am loving it. thanks a lot.

Sikat ang Pinoy us

12/20/2009 7:36:12 AM

bread machine reviews

I just love this BlogEngine platform, it makes a blog look and act like a blog if you ask me. Do you prefer it over WordPress and Blogger?

bread machine reviews us

12/21/2009 11:44:47 AM

mma pound for pound

I wanted to thank you for this great read!! I definitely enjoying every little bit of it.I have you bookmarked to check out new stuff you post.

mma pound for pound us

Add comment


(Will show your Gravatar icon)  

  Country flag

[b][/b] - [i][/i] - [u][/u]- [quote][/quote]



Live preview

3/10/2010 12:36:59 PM

Powered by BlogEngine.NET 1.3.0.0
Theme by Mads Kristensen

About the author

Name of author Rod Cerrada
One way to enrich world's treasure is to share your knowledge to younger generations.

E-mail me Send mail  |  LinkedIn  |  ScrumMaster

Company: www.cerquit.com


Recent posts

Pages

    Calendar

    <<  March 2010  >>
    MoTuWeThFrSaSu
    22232425262728
    1234567
    891011121314
    15161718192021
    22232425262728
    2930311234

    View posts in large calendar

    Authors






    Disclaimer

    The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

    © Copyright 2010

    Sign in