Is it possible to invoke PhantomJS through the browser?

倖福魔咒の 提交于 2019-12-25 08:37:14

问题


I'm trying to generate server-side images of a portion of my DOM, and then serve those images up to users from my server once they're created.

I'm curious as to the implementation possibilities of PhantomJS, as I don't entirely understand its purpose beyond exploring and testing. I get that it is a self-contained binary, and I've got it running basic apps like in their tutorials. But is there a way to do something along the lines of the following?

<html>
    <body>
        <h1>This is a test.</h1>
        <button>Rasterize!</button>
    </body>
    <script>
        $('button').click(function() {
            // invoke PhantomJS here to generate PNG of this page
        });
    </script>
<html>

Specifically, I'm looking at doing something along the lines of:

phantomjs rasterize.js https://localhost:9999/test.html test.png

Someone, please, school me!

来源:https://stackoverflow.com/questions/44815652/is-it-possible-to-invoke-phantomjs-through-the-browser

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!