Sherzod Posted April 13, 2020 Share Posted April 13, 2020 54 minutes ago, eduardosuruagy said: Is it possible to leave the image on the server and send it by email? I would not like to download it. Well then, first of all, you need to analyze how to send email... You can find many examples on the forum, please use the search. Link to comment Share on other sites More sharing options...
eduardosuruagy Posted April 13, 2020 Share Posted April 13, 2020 I want to give a print on the screen and send it by email, this function that was placed here it downloads the image. Link to comment Share on other sites More sharing options...
Sherzod Posted April 13, 2020 Share Posted April 13, 2020 3 minutes ago, eduardosuruagy said: this function that was placed here it downloads the image. Ok sorry, then need to send to the server, or send it by email from the client side. We will try... 1 Link to comment Share on other sites More sharing options...
freedowsRoO Posted April 19, 2020 Author Share Posted April 19, 2020 On 4/13/2020 at 1:09 PM, Sherzod said: Ok sorry, then need to send to the server, or send it by email from the client side. We will try... Hello, any ideia about this? How can i retrieve a variable in server side from this code? For example, if i want to get the 'uri' on server side, how i can do that? 2. MainForm.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); } } Link to comment Share on other sites More sharing options...
Sherzod Posted April 20, 2020 Share Posted April 20, 2020 On 4/13/2020 at 10:03 PM, eduardosuruagy said: I want to give a print on the screen and send it by email, this function that was placed here it downloads the image. 11 hours ago, freedowsRoO said: How can i retrieve a variable in server side from this code? For example, if i want to get the 'uri' on server side, how i can do that? One possible solution (for example, a snapshot of the button itself): procedure TMainForm.UniButton1Click(Sender: TObject); begin with UniButton1 do JSInterface.JSCode('html2canvas(document.querySelector("#' + JSId +'")).then(function(canvas) {ajaxRequest('#1', "getData", ["base64Data="+canvas.toDataURL()])});'); end; procedure TMainForm.UniButton1AjaxEvent(Sender: TComponent; EventName: string; Params: TUniStrings); begin if EventName='getData' then begin // Params.Values['base64Data'] // Here you need to decode the Base64 string // data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEsAAAAZ...AAAABJRU5ErkJggg== end; end; 1 Link to comment Share on other sites More sharing options...
freedowsRoO Posted April 20, 2020 Author Share Posted April 20, 2020 6 hours ago, Sherzod said: One possible solution (for example, a snapshot of the button itself): procedure TMainForm.UniButton1Click(Sender: TObject); begin with UniButton1 do JSInterface.JSCode('html2canvas(document.querySelector("#' + JSId +'")).then(function(canvas) {ajaxRequest('#1', "getData", ["base64Data="+canvas.toDataURL()])});'); end; procedure TMainForm.UniButton1AjaxEvent(Sender: TComponent; EventName: string; Params: TUniStrings); begin if EventName='getData' then begin // Params.Values['base64Data'] // Here you need to decode the Base64 string // data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEsAAAAZ...AAAABJRU5ErkJggg== end; end; Nice! Thanks a lot! 1 Link to comment Share on other sites More sharing options...
freedowsRoO Posted April 28, 2020 Author Share Posted April 28, 2020 On 4/13/2020 at 11:41 AM, eduardosuruagy said: Is it possible to leave the image on the server and send it by email? I would not like to download it. How i do that? I save just de base64 string in my database and after that i decode de base64 string to get the img. Link to comment Share on other sites More sharing options...
grupodatasoft Posted October 26, 2021 Share Posted October 26, 2021 On 9/13/2019 at 6:53 AM, Sherzod said: Hi, Can you try these steps? 1. CustomFiles: files/html2canvas.min.js 2. MainForm.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. How to use, for example: procedure TMainForm.UniButton2Click(Sender: TObject); var fName: string; begin fName := 'capture' + FormatDateTime('ddmmyyyyhhnnss', Now); UniPanel1.JSInterface.JSCode( 'html2canvas(document.querySelector("#'+ UniPanel1.JSId +'")).then(function(canvas) {'+ ' canvasSaveAs(canvas.toDataURL(), "'+ fName +'");'+ '});' ); end; Hi, this works great, it's amazing, thank you !!! Just one question: is there a way to automatically save the file to a specific path on the server without user intervention? Link to comment Share on other sites More sharing options...
loQsoft Posted December 28, 2021 Share Posted December 28, 2021 Hello @Sherzod, Hello Is it possible to take a screenshot and save it somewhere on the server? and how we can do it ? Best Regards, Link to comment Share on other sites More sharing options...
Sherzod Posted December 28, 2021 Share Posted December 28, 2021 Hello, 52 minutes ago, loQsoft said: and how we can do it ? Have you tried the approach above? Link to comment Share on other sites More sharing options...
loQsoft Posted December 28, 2021 Share Posted December 28, 2021 1 minute ago, Sherzod said: Merhaba, Yukarıdaki yaklaşımı denediniz mi? Yes of course, But not success maybe there is another way to solve this problem Best regards, Link to comment Share on other sites More sharing options...
loQsoft Posted December 28, 2021 Share Posted December 28, 2021 3 minutes ago, Sherzod said: Hello, Have you tried the approach above? With your way, i can take screenshot and then download the file. I need to save screenshot and then send by email to customer. Thanks for your support, Best Regards Link to comment Share on other sites More sharing options...
Sherzod Posted December 28, 2021 Share Posted December 28, 2021 48 minutes ago, loQsoft said: I need to save screenshot and then send by email to customer. This post may help you: Link to comment Share on other sites More sharing options...
loQsoft Posted December 28, 2021 Share Posted December 28, 2021 7 hours ago, Sherzod said: This post may help you: Thanks for the support, But my problem is not send to email My problem is take screenshot and save to the server. There is a way to save the screenshot to the server ? Thank you again for your support, Best Regards, Link to comment Share on other sites More sharing options...
Sherzod Posted December 28, 2021 Share Posted December 28, 2021 34 minutes ago, loQsoft said: My problem is take screenshot and save to the server. On 4/20/2020 at 1:06 PM, Sherzod said: procedure TMainForm.UniButton1AjaxEvent(Sender: TComponent; EventName: string; Params: TUniStrings); begin if EventName='getData' then begin // Params.Values['base64Data'] // Here you need to decode the Base64 string // data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEsAAAAZ...AAAABJRU5ErkJggg== end; end; Just need to try to implement it. I'll try one of these days... 1 Link to comment Share on other sites More sharing options...
loQsoft Posted December 28, 2021 Share Posted December 28, 2021 2 hours ago, Sherzod said: Just need to try to implement it. I'll try one of these days... Thank you very very much. Link to comment Share on other sites More sharing options...
Sherzod Posted January 10, 2022 Share Posted January 10, 2022 On 12/28/2021 at 3:10 PM, loQsoft said: My problem is take screenshot and save to the server. Hello, You can try this approach: 1. uses ... Soap.EncdDecd; 2. procedure TMainForm.UniButton1Click(Sender: TObject); begin with UniButton1 do JSInterface.JSCode('html2canvas(document.querySelector("#' + JSId +'")).then(function(canvas) {ajaxRequest('#1', "getData", ["base64Data="+canvas.toDataURL()])});'); end; 3. procedure TMainForm.UniButton1AjaxEvent(Sender: TComponent; EventName: string; Params: TUniStrings); var stream: TBytesStream; base64s: string; AUrl: string; begin if EventName = 'getData' then begin base64s := Params.Values['base64Data']; base64s := StringReplace(base64s, 'data:image/png;base64,', '', [rfReplaceAll]); stream := TBytesStream.Create(DecodeBase64(base64s)); try stream.SaveToFile(UniServerModule.NewCacheFileUrl(False, 'png', '', '', AUrl, True)); UniImage1.Url := AUrl; finally stream.Free; end; end; end; 4. CustomFiles: files/html2canvas.min.js 1 Link to comment Share on other sites More sharing options...
loQsoft Posted January 20, 2022 Share Posted January 20, 2022 On 1/10/2022 at 8:55 AM, Sherzod said: Hello, You can try this approach: 1. uses ... Soap.EncdDecd; 2. procedure TMainForm.UniButton1Click(Sender: TObject); begin with UniButton1 do JSInterface.JSCode('html2canvas(document.querySelector("#' + JSId +'")).then(function(canvas) {ajaxRequest('#1', "getData", ["base64Data="+canvas.toDataURL()])});'); end; 3. procedure TMainForm.UniButton1AjaxEvent(Sender: TComponent; EventName: string; Params: TUniStrings); var stream: TBytesStream; base64s: string; AUrl: string; begin if EventName = 'getData' then begin base64s := Params.Values['base64Data']; base64s := StringReplace(base64s, 'data:image/png;base64,', '', [rfReplaceAll]); stream := TBytesStream.Create(DecodeBase64(base64s)); try stream.SaveToFile(UniServerModule.NewCacheFileUrl(False, 'png', '', '', AUrl, True)); UniImage1.Url := AUrl; finally stream.Free; end; end; end; 4. CustomFiles: files/html2canvas.min.js Thank you very much, @Sherzod İ will try weekend your solution proposal and will inform you Best Regards, 1 Link to comment Share on other sites More sharing options...
loQsoft Posted January 27, 2022 Share Posted January 27, 2022 @Sherzod, Thank you very much for your support. it works very well. and you can see test case at the attachement for the print screen save to file. i have a little question, if i want to take screan shoot of all of mainmenu, how i can do it ? Best Regards, Print_Screen.rar Link to comment Share on other sites More sharing options...
Sherzod Posted January 28, 2022 Share Posted January 28, 2022 5 hours ago, loQsoft said: Thank you very much for your support. Thank you. 5 hours ago, loQsoft said: if i want to take screan shoot of all of mainmenu, how i can do it ? Sorry, can you please explain in more details? Link to comment Share on other sites More sharing options...
andyhill Posted August 8, 2022 Share Posted August 8, 2022 I would like to save the GoogleMap Image already rendered inside HtmlFrame, please advise how - thanks Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now