To create some sort of user assistance, for example. Sadly, that's not possible for security reasons? You have to ask the user to press PrintScreen in order to do something. ErnestFriedman-Hill not a duplicate: the question you mentioned is specific to java.
Everyone will know it's possible on the server side. Show 1 more comment. Active Oldest Votes. There is a lot of options and they all have their pro and cons. Most of the time they offer a free plan Cons Not free if you plan to use them a lot Option 2: Use one of the many available libraries dom-to-image wkhtmltoimage included in the wkhtmltopdf tool IMGKit for ruby and based on wkhtmltoimage imgkit for python and based on wkhtmltoimage python-webkit2png Sometimes not so easy to install Complicated to scale Option 3: Use PhantomJs and maybe a wrapper library PhantomJs node-webshot javascript wrapper library for PhantomJs Complicated to scale Not so easy to make it work if there is images to be loaded Option 4: Use Chrome Headless and maybe a wrapper library Chrome Headless chrome-devtools-protocol Puppeteer javascript wrapper library for Chrome headless Pros Execute Javascript Near perfect rendering Cons Not so easy to have exactly the wanted result regarding: page load timing viewport dimensions Complicated to scale Quite slow and even slower if the html contains external links Disclosure: I'm the founder of ApiFlash.
You can set a javascript delay or let wkhtml check for a specifc window. PhantomJS supports dynamic stuff like Google Maps. It's really a full web browser, just without a display attached. However you have to wait a bit for Google Map to load the tiles with the geography I wait ms and allow people to change the delay - if it's not enough, running again without increasing the time is fine, because those tiles are cached.
Add a comment. Jerad Rutnam 1, 1 1 gold badge 14 14 silver badges 29 29 bronze badges. It seems interesting but I didn't manage to make it work so I choose John Fisher solution. Thanks for the info, I'll watch this project in the future! If you are dealing with SVGs at all, dom-to-image works much better. This solution is very slow — hamboy Show 2 more comments. This is great! Any way to double the output size? But what exactly do you mean by "doubling the size"? First thing that comes to my mind - try to render your image to SVG using domtoimage.
It's probably possible to implement such feature as some kind of rendering option in the lib itself, so you can pass image dimensions in pixels. If you need it, I'd appreciate you creating an issue on github.
This is MUCH better than html2canvas. Subho it's a String containing the URL with baseencoded data — tsayen.
Show 18 more comments. Sjeiti Sjeiti 2, 1 1 gold badge 29 29 silver badges 32 32 bronze badges. Removing external library dependency is indeed the good way to go. I changed my accepted answer :- — Martin Delille. That article is no longer there.
Great answer, but commenting on the state of art of HTML and Web APIs, which as usual looks like something pulled out someones behind -- all the functionality is technically there but exposed behind an array no pun intended of weird code paths that resemble nothing of the kind of clarity you would expect from a well designed APIs.
In plainspeak: it is most likely trivial for a browser to allow a Document to be rendered into a raster e. This answer stackoverflow. But this would be a good thing to test. Haven't tested rigourously but it's enough for most use cases.
I know this is quite an old question which already has a lot of answers, yet I still spent hours trying to actually do what I wanted: given an html file, generate a png image with transparent background from the command line Using Chrome headless version Very nice! It works with SVG also! I switched to your solution in the end! FYI this also works with chromium even though it doesn't mention the option in the man page.
The svg isn't an svg for me Stoffe 2, 23 23 silver badges 24 24 bronze badges. TheContrarian TheContrarian 1 1 silver badge 3 3 bronze badges. This technique works well. However, 2 years have passed since your comment. Have you come across anything that operates faster than PhantomJS? Width of output in characters, max Use color? Restrict to 16 ANSI colors?
Use retro phosphor colors? Updates September 27, Exit Coinhive in-browser bitcoin mining Thank you for your feedback on our brief test with browser based bitcoin mining. August 10, Who is this person? Finance Compound interest calculator Loan Interest Calculator. Boost your learning with Duolingo Plus Learning a language on Duolingo is completely free, but you can remove ads and make faster progress with Plus.
Try it free for 14 days! Learn anytime, anywhere. Make your breaks and commutes more productive with our iPhone and Android apps. Download them and see why Apple and Google gave us their highest accolades.
0コメント