Save html canvas to disk

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
GreenBeing
Newbie
Posts: 5
Joined: Wed Oct 18, 2017 2:18 am

Save html canvas to disk

Post by GreenBeing » Wed Feb 07, 2018 8:51 am

Hello. I am trying to capture and save to disk an image on a web page. The image is displayed in an embedded viewer. Per the picture below, you can see that the DOM element that contains the image is a canvas. In the Chrome browser, the user can simply right-click on the image, and the full size image (not just the cropped visible portion) can be saved to disk. The 'save image' option is not available in IE. It is for the thumbnails though... I could click the 'fit page' button in the viewer and and do a screen capture at specific coordinates, but I am afraid that the resulting imaging would be too low res to read. I am not very experienced with all of this, and I was hoping that someone here had run into a similar situation, or might have some ideas to get me going in the right direction. Thanks.

Image

GreenBeing
Newbie
Posts: 5
Joined: Wed Oct 18, 2017 2:18 am

Re: Save html canvas to disk

Post by GreenBeing » Wed Feb 07, 2018 9:26 am

Continuing research... It appears that the HTML5 method "toDataURL()" does what I want, but:

Code: Select all

The toDataURL() method requires that any images drawn onto the canvas are hosted on a web server with the same domain as the code executing it.  If this condition is not met, a SECURITY_ERR exception is thrown.

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: Save html canvas to disk

Post by Marcus Tettmar » Wed Feb 07, 2018 2:31 pm

I'm not really sure how we could get the image itself. Are you able to share a URL where I can go and try it?
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts