如何将整个html页面保存为jpeg

时间:2021-11-25 17:02:19

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.

我希望能够将其保存为jpeg。

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

我在搜索时发现了这一点,我认为它与我需要的最接近。 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.

唯一的问题是。它似乎不允许将屏幕截图保存为jpeg。它可以很好地截取屏幕截图,但它会在同一页面上作为“画布”附加。

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

我需要在点击按钮时将我的html页面保存在jpeg中。

Any idea how can this be done?

知道如何做到这一点?

Thanks

4 个解决方案

#1


1  

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

如果您想要一个纯客户端解决方案,您只需保存由html2canvas生成的canvas的内容:

var dataURL = document.getElementById("someCanvas").toDataURL("image/jpeg");
document.location.href = dataURL;

#2


2  

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

我会使用Pageres你可以在这里找到它https://github.com/sindresorhus/pageres

#3


-1  

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

我已经摆弄了wkhtmltopdf,我建议你去看看它

#4


-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/

虽然它不完全是一个PHP解决方案,但我过去曾使用PhantomJS从PHP脚本中获取网站的“快照”。您可以在这里找到更多信息:http://phantomjs.org/

#1


1  

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

如果您想要一个纯客户端解决方案,您只需保存由html2canvas生成的canvas的内容:

var dataURL = document.getElementById("someCanvas").toDataURL("image/jpeg");
document.location.href = dataURL;

#2


2  

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

我会使用Pageres你可以在这里找到它https://github.com/sindresorhus/pageres

#3


-1  

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

我已经摆弄了wkhtmltopdf,我建议你去看看它

#4


-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/

虽然它不完全是一个PHP解决方案,但我过去曾使用PhantomJS从PHP脚本中获取网站的“快照”。您可以在这里找到更多信息:http://phantomjs.org/