Skip to content

Instantly share code, notes, and snippets.

@jtallant
Last active November 20, 2015 21:25
Show Gist options
  • Save jtallant/59cf7c4d4cff572627b2 to your computer and use it in GitHub Desktop.
Save jtallant/59cf7c4d4cff572627b2 to your computer and use it in GitHub Desktop.
html2canvas
html2canvas($('#content'), {
    onrendered: function(canvas) {
        var dataURL = canvas.toDataURL();
        var posting = $.post(BASE + '/profiles/' + site_id + '/send-report-emails', {
            emails: emails,
            message: message,
            data_uri: dataURL
        });

        posting.done(function() {
            $('#emailReport input').each(function() {
                $(this).val('');
            });

            $('#emailReport .alert').removeClass('hide');
            $('#emailReport .alert strong').text('Emails sent');
        });
    }
});
$path = '/path/to/directory/to/save/png';
$uri = 'some-data-uri-generated-from-js';
$uriPhp = 'data://' . substr($uri, 5);
$binary = file_get_contents($uriPhp);
file_put_contents($path, $binary);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment