0

Here's what I want to do:

  1. Load a web page from a specific location
  2. Print that web page into a jpeg, png, or other graphic file format
  3. Upload that image to another site, or save it to a location on my local network

I know about window.print(), but that always seems to open up a print window, and I'd like to do as much of this operation silently as possible.

Essentially, I want to be able to take a snap shot of the web page so it can be put in a directory that is accessed by one of those electronic picture frames. They can either access a web-based service, or a directory on the local network.

Thanks in advance for your help, Rben

Rben
  • 489
  • 1
  • 7
  • 18
  • You can't do it through javascript. You can do this with a server side script using PHP/.Net etc – Chandu Dec 31 '10 at 02:41
  • @Cybernate: You'd need an HTML renderer, and you wouldn't get the client's cookies. – SLaks Dec 31 '10 at 02:43
  • Why do you want to do this in Javascript? – SLaks Dec 31 '10 at 02:43
  • Doesn't have to be javascript. I do need an HtML renderer, but am not sure which is best choice. I originally hoped to just use the browser for that. – Rben Dec 31 '10 at 16:31

3 Answers3

1

Browsers will not let you print "silently", because if they did websites all over the place would use them to overload your printer with spam. There's no way around it (and if you found one, they'd close it as quickly as they could).

So, you could either a) create a browser plugin or something similar that gets you outside the broswer's "sandbox", OR, b) write a web crawler app that obtains the web page, and find some other technique to render it into an image (drive a browser programmatically perhaps).

If either of those sounds promising, let me know and I can fill in more detail on how to go about them.

Charlie Flowers
  • 17,338
  • 10
  • 71
  • 88
  • It doesn't have to be a browser plugin. I was just looking for a shortcut when it came to rendering the page. I'm pretty handy with Java and scripting languages, so a crawler might be better. – Rben Dec 31 '10 at 12:54
  • Charlie, if you could tell me more about your crawler suggestion, I'd appreciate it. What would you use for rendering the page? – Rben Jan 01 '11 at 14:17
0

I put together a script i think might be just what your looking for... Screenshot Demo.

It uses printElement and Feedback.js(Can't remember the source) and it allows you to screenshot the whole webpage and either send it as an email or to a printer.

Let me know if this helps and sorry i have no put more detail about it on the page but I am at work at the moment lol

jampez77
  • 5,012
  • 7
  • 32
  • 52
0

You can't do that using javascript. wkhtmltopdf can help you. Here are the list of tools available to do it in this SO discussion.

Community
  • 1
  • 1
Teja Kantamneni
  • 17,402
  • 12
  • 56
  • 86
  • Once it's a pdf, I still need to convert it into an image file. So this is close, but not quite what I need. Should I be looking at webkit? – Rben Dec 31 '10 at 13:05