0

I have this long page.

http://prompter.rareapps.org/prompt/prompt-save.php?p=123

I want to be able to save it as jpeg.

I found this while searching which I believe is the closest match to what I need. http://html2canvas.hertzen.com/screenshots.html

The only problem is. It doesn't seem to allow saving the screenshot as jpeg. It takes the screenshot well but it is being appended as "canvas" on the same page.

I need to save my html page in jpeg on click of a button.

Any idea how can this be done?

Thanks

Wayne
  • 763
  • 4
  • 21
  • 43
  • 1
    possible duplicate of [Save canvas as jpg to desktop](http://stackoverflow.com/questions/17397319/save-canvas-as-jpg-to-desktop) – Sumurai8 Mar 21 '14 at 19:02
  • http://stackoverflow.com/questions/60455/take-a-screenshot-of-a-webpage-with-javascript may be helpful for you. – Suman Bogati Mar 21 '14 at 19:03
  • @Sumurai8 Thanks. It's not exact duplicate but seeing the duplicate warning on that link you gave stitch everything together. Thanks – Wayne Mar 21 '14 at 20:35

4 Answers4

2

I would use Pageres you can find it here https://github.com/sindresorhus/pageres

cmorrissey
  • 8,493
  • 2
  • 23
  • 27
  • Great reference. Looks like it does the job pretty well but it seems it is a shell command not web interface. Sorry for missing that out on my question. I need web interface. – Wayne Mar 21 '14 at 19:18
  • @CharlesWayne you could use `shell_exec` to run it – cmorrissey Mar 21 '14 at 19:31
1

If you want a pure client-side solution, you can just save the contents of canvas generated by html2canvas:

var dataURL = document.getElementById("someCanvas").toDataURL("image/jpeg");
document.location.href = dataURL;
Ale
  • 1,998
  • 19
  • 31
  • This is my code that generate the canvas. How can I reference it using your sample code? $('#save-image').click(function () { html2canvas(document.body, { onrendered: function(canvas) { document.body.appendChild(canvas); }, allowTaint: true, taintTest: false }); }); – Wayne Mar 21 '14 at 19:51
  • @CharlesWayne You'd just put it into your `onrendered` callback, using `canvas` parameter instead of getting it from body (i. e. replace `document.getElementById("someCanvas")` in my example with just `canvas` and you should be ready to go :) – Ale Mar 25 '14 at 18:21
-1

i've fiddled around with wkhtmltopdf i'd suggest you'd take a look at it

Bjorn9000
  • 98
  • 9
  • Thanks for your reply. I've seen that but having windows and linux version tells me that it has to be installed on server. (correct me if I am wrong) I have shared host and I cant install anything. Hoping to have something that is standard to most shared host and ready to use. – Wayne Mar 21 '14 at 19:05
-1

While it's not exactly a PHP solution, i've used PhantomJS in the past to take "snapshots" of a website from PHP scripts. You can find more information here: http://phantomjs.org/

bdb.jack
  • 147
  • 1
  • 8