Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

print image file from page link?

Posted on 2009-07-07
3
Medium Priority
?
1,079 Views
Last Modified: 2012-05-07
This tutorial about printing from javascript:

http://nice-tutorials.blogspot.com/2009/05/print-using-javascript.html

gave me an idea.

He talks about printing a hidden image on a page by creating a print preview window and letting the user print it out.  I don't understand all of it, but I like the idea of sending an image straight to print preview.

I have a small image on my web page, and the user needs to be able to print a full size copy.  

It would be nice to have a set up where the user clicks on the image, and the print preview comes up displaying a different image file (a larger version of what's on the page).

So something like:

<A <!-- javascript here to pop up print preview of full-size.jpg -->><IMG SRC="small-size.jpg"></A>

Is it possible to go straight to print preview like that, and if so, can you write it?

Thank you,   Chris
0
Comment
Question by:St_Aug_Beach_Bum
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 2000 total points
ID: 24800688
Sure
<a href="bigimage.jpg" target="printwin"
onClick="return printIt(this)"><img src="thumbnail.jpg" border="0" /></a>
<script>
function printIt(link) {
  var w=window.open("",link.target,"width=500,height=500");
  if(w) { 
    w.document.write('<body onload="window.focus(); window.print()">'+
      '<a href="#" onClick="window.close(); return false"><img title="Click to close" src="'+link.href+'" /></a>'+
      '</body>');
    w.document.close();
    return false; // cancel link
  }
  return true; /* follow link, user has a popup blocker and needs to print the new window himself */
}
</script>

Open in new window

0
 

Author Closing Comment

by:St_Aug_Beach_Bum
ID: 31600603
mplungjan,

I'm very sorry, I don't know why I didn't get back and get these points to you earlier.  
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 25475099
Np. Thanks
0

Featured Post

The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

704 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question