Alex S Posted April 26, 2020 Share Posted April 26, 2020 Hi, I'm trying to export an image from UniMap or UniHTMLFrame (e.g. with Google Maps) to .png to use in a PDF report. only produces a PDF of and empty map and the controls, but not the actual map in the exported .png Using the external app, on a basic javascript map, wkhtmltopdf/wkhtmltoimage also only produces a blank image. Any suggestions to do this in a Delphi UniGUI Web application? Thanks Quote Link to comment Share on other sites More sharing options...
Sherzod Posted April 26, 2020 Share Posted April 26, 2020 Hello, Maybe this demo help you: \FMSoft\Framework\uniGUI\Demos\Desktop\HTML2Image Quote Link to comment Share on other sites More sharing options...
Alex S Posted April 27, 2020 Author Share Posted April 27, 2020 Thanks Sherzod, yes I was looking at this demo and the other Printscreen tagged articles on this forum, but implementing them, none produced an image containing the content of the web maps from the UniMap component. After more research I found a solution. The {useCORS: true} entry needs to be added to the solution of freedowsRoO above, and then it works for me. UniMap1.JSInterface.JSCode( 'html2canvas(document.querySelector("#'+ UniMap1.JSId +'"),{useCORS: true}).then(function(canvas) {'+ 'ajaxRequest('#1',"getData",["base64Data="+canvas.toDataURL()])});'); Here is more information. https://stackoverflow.com/questions/46281261/google-map-is-not-displayed-when-using-html2canvas It might not work on all browsers though. 1 Quote Link to comment Share on other sites More sharing options...
Sherzod Posted April 27, 2020 Share Posted April 27, 2020 7 hours ago, Alex S said: After more research I found a solution. Hello, So does this work? Quote Link to comment Share on other sites More sharing options...
Alex S Posted April 28, 2020 Author Share Posted April 28, 2020 Indeed, it works very well, tested using latest Chrome on Windows and Edge. I wrote some code to convert the base64 data to .png file. One more thing that was not clear in previous threads was to add a relative path reference to html2canvas.js under the CustomFiles property of the UniServerModule 1 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.