55143681 Posted February 4, 2023 Share Posted February 4, 2023 I use html2canvas.min.js to snap the form. 1.Add javaScript\html2canvas.min.js to serverModule's customFiles. 2.Add function "canvasSaveAs" to MainForm's Script. function canvasSaveAs(uri, filename) { var link = document.createElement('a'); if (typeof link.download === 'string') { link.href = uri; link.download = filename; document.body.appendChild(link); link.click(); document.body.removeChild(link); } else { window.open(uri); } } 3. call the function from my form. void __fastcall TUniFormAlterMakePdf2::UniBitBtn1Click(TObject *Sender) { String fName; fName = "111capture" + FormatDateTime("yyyyMMddhhnnss", Now()); UniPanel1->JSInterface->JSCode( "html2canvas(document.querySelector(\"#"+ UniPanel1->JSId +"\")).then(function(canvas) {" +" canvasSaveAs(canvas.toDataURL(), \""+ fName +"\");" + "});" ); } Problem: In my new create project(http),that run normal, but in my another project(https),that run with nothing, why? Quote Link to comment Share on other sites More sharing options...
Sherzod Posted February 5, 2023 Share Posted February 5, 2023 11 hours ago, 55143681 said: 2.Add function "canvasSaveAs" to MainForm's Script. function canvasSaveAs(uri, filename) { var link = document.createElement('a'); if (typeof link.download === 'string') { link.href = uri; link.download = filename; document.body.appendChild(link); link.click(); document.body.removeChild(link); } else { window.open(uri); } } Hello, Then, also try to output this js function to a separate js file and include to the project. Quote Link to comment Share on other sites More sharing options...
55143681 Posted February 6, 2023 Author Share Posted February 6, 2023 On 2/5/2023 at 10:45 AM, Sherzod said: Hello, Then, also try to output this js function to a separate js file and include to the project. thanks. I will try Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.