FoxInCloud
screen to image
Hi Thierry,
I'm trying to copy the contents of a screen into an image (or better, a PDF)
For that, I of course use the html2canvas library, but I get "canvas.toDataURL is not a function"
Here is my code, in the click() of a button:
IF (Type('m.thisForm.wlHTMLgen') == 'L' AND m.thisForm.wlHTMLgen)
LOCAL lcJS
TEXT TO lcJS TEXTMERGE NOSHOW FLAGS 1 PRETEXT 3
var container = jQuery("#<<THISFORM.wcID>>")
html2canvas(container, { allowTaint: true });
{onrendered: jQuery(function (canvas) {
var link = document.createElement("a");
document.body.appendChild(link);
link.download = "html_image.png";
link.href = canvas.toDataURL("image/png");
link.target = '_blank';
link.click();
})};
ENDTEXT
RETURN m.lcJS
ENDIF
A little help ? Thanks in advance
Hi Vincent,
html2canvas()
accepts 2 arguments:
- the HTML element (not a jQuery object)
- an
options
object
here is a sample code built by modify class awfrmfb of aw method init
html2canvas(jQuery('#Window_modal_scx').get(0) || jQuery('.Window_modal_scx').get(0)
, {onrendered: function(canvas){ /* options object */
jQuery(canvas).css({width:'100%'});
jQuery('#awfrmfb-cntscreenshot').html(canvas);
}
});
Here is the full html2canvas() options documentation
not a jQuery object
Thanks Thierry, I will try to carry on with your lights ...
With jQuery("#<<THISFORM.wcID>>").get(0)
it's fine !
Thanks again