Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Making a "screenshot" of the current website using HTML or JavaScript?

I have tried html2canvas, but did not work as expected, because I am using Google Maps with custom markers and when it will just make a screenshot of the map without these markers.

I want to make a screenshot so that it looks like:

enter image description here

But the result is:

enter image description here

The chart does also not look that great. Are there any alternatives I can use?

Here is the code I used to create an image using html2canvas (where #downloadPDF is a button):

<script type="text/javascript">
jQuery(document).ready(function ($) {
    $('#downloadPDF').click(function () {
        html2canvas($(".map"), {
            logging: true,
            useCORS: true,
            onrendered: function (canvas) {
                var imgData = canvas.toDataURL('image/png');
                window.open(imgData);
            }
        });
    });
});

like image 955
Kevin S Avatar asked Jan 05 '16 14:01

Kevin S


People also ask

How do I take a screenshot of a HTML page?

Please click on the toolbar button (or press Alt+Shift+D combination) to capture the screenshot. You can adjust the screenshot image format from the options page.

How do I make my website screenshot proof?

There are several ways to protect your pictures: disable right-click protection, apply a watermark to your pictures, register your copyright, add a copyright notice, or enable hotlink protection.


1 Answers

Not sure on your hosting setup, but I have used PhantomJS to create screenshots of web pages, and save them as images or PDFs.

When you download the library, there is a rasterize.js in the example directory which allows you to pass in arguments to save a URL. You could modify this so that it pauses for a few seconds, then saves the page - giving the map enough time to load properly.

http://phantomjs.org

like image 88
Luke P Avatar answered Sep 27 '22 20:09

Luke P