Open lettertoamit opened 4 years ago
html2canvas is working on chrome and firefox but same thing is not working on safari of ipad.
function runPromise(x) { var canvasnx = ''; var promisex = []; var height = 0; var promise = new Promise(function (resolve, reject) { var div = document.getElementById("ch_dndBoard1"); html2canvas(div, { useCORS: true, allowTaint: true, onrendered: function (canvasn) { var position = 0; var valuesx = []; canvasnx = canvasn; var extra_canvas = document.createElement("canvas"); var element = document.getElementById("paint_1"); var pagecount = element.getElementsByTagName('canvas').length; height = canvasn.height / pagecount; extra_canvas.setAttribute('width', canvasn.width); extra_canvas.setAttribute('height', height); var ctx = extra_canvas.getContext('2d'); console.log("canvasncanvasncanvasncanvasn", canvasn.toDataURL("image/jpeg", 1.0) ); for (var i = 0; i < pagecount; i++) { ctx.drawImage(canvasn, 0, position, canvasn.width, height, 0, 0, canvasn.width, height); // console.log("canvasxxxxxxxxxxx" , position , canvasn.width ,height ); position += (height); //position += (height + 5.125); var myImage = extra_canvas.toDataURL("image/jpeg", 1.0); valuesx.push(myImage); } resolve([valuesx, height]); } }); }); promise.then(function (values) { var orient = x.orientation; console.log(values); var pdf = new jsPDF(orient, 'pt', [canvasnx.width, values[1]]); console.log(values, "values.lengthvalues.length"); for (var i = 0; i < values[0].length; i++) { console.log("condition ", values[0][i]); pdf.addImage(values[0][i], 'JPEG', 0, 0, canvasnx.width, values[1]); pdf.addPage(); } var pageCount = pdf.internal.getNumberOfPages(); pdf.deletePage(pageCount); var pdf_data = btoa(pdf.output()); $.ajax({ type: "post", url: x.siteUrl, data: { pdf_data: pdf_data, login_user_id: x.loginId, project_id:x.projectId, newPdf: x.newPdf, original_pdf_name: x.originalName, client_name: x.clientName, user_name: x.userName, use_icons_json: x.icons_jsonData, use_comments_json: x.comments_jsonData, full_canvas_data_jsonData:x.full_canvas_data_jsonData, restorePoints_jsonData:x.restorePoints_jsonData, chk_ajax:x.chk_ajax, }, success: function (response) { if (response) { x.callBack(); var css = ''; document.head.insertAdjacentHTML('beforeEnd', css); // $('.custom_hide').hide(); if (parseInt(x.newPdf)) { alert('save pdf done'); $('.ajax_loader').hide(); window.location = x.redirectUrl; } } } }); }); } setTimeout(function() { var css = ''; document.head.insertAdjacentHTML( 'beforeEnd', css ); var t = document.getElementById('test'); var tctx = t.getContext("2d"); var x = { "orientation":"<?php echo $size["orientation"] ?>", "siteUrl":"<?php echo site_url('Edit_pdf_ajax')?>", "loginId":'<?php echo $get_user_ID; ?>', "projectId":"<?php echo $_GET['pro']; ?>", "originalName":'<?php echo $filenm; ?>', "clientName":'<?php echo $get_client_nm; ?>', "userName":'<?php echo $get_user_name; ?>', "redirectUrl":"<?php echo site_url('search_project_by_add')?>", "newPdf":"0", "icons_jsonData":icons_jsonData, "comments_jsonData":comments_jsonData, "full_canvas_data_jsonData":full_canvas_data_jsonData, "restorePoints_jsonData":restorePoints_jsonData, "chk_ajax":'chk_ajax', "callBack":function(){ setTimeout(function() { var css = ''; document.head.insertAdjacentHTML( 'beforeEnd', css ); var t = document.getElementById('test'); var tctx = t.getContext("2d"); var x = { "orientation":"<?php echo $size["orientation"] ?>", "siteUrl":"<?php echo site_url('Edit_pdf_ajax')?>", "loginId":'<?php echo $get_user_ID; ?>', "projectId":"<?php echo $_GET['pro']; ?>", "originalName":'<?php echo $filenm; ?>', "clientName":'<?php echo $get_client_nm; ?>', "userName":'<?php echo $get_user_name; ?>', "redirectUrl":"<?php echo site_url('search_project_by_add')?>", "newPdf":"1", "icons_jsonData":icons_jsonData, "comments_jsonData":comments_jsonData, "full_canvas_data_jsonData":full_canvas_data_jsonData, // "restorePoints_jsonData":restorePoints_jsonData, "callBack":function(){ } } runPromise(x); }, 1000); } } runPromise(x); }, 1000);
here is the part of code but when it reaches html2canvas second time it reloads the page , kindly help me here.
Same issue , did you find any solution ?
html2canvas is working on chrome and firefox but same thing is not working on safari of ipad.
here is the part of code but when it reaches html2canvas second time it reloads the page , kindly help me here.