Convert HTML to Image in PHP without shell

后端 未结 5 827
暗喜
暗喜 2020-12-03 18:51

I want the option of converting HTML to image and showing the result to the user. I would be creating an $html variable with PHP, and instead of displaying using echo $html,

5条回答
  •  生来不讨喜
    2020-12-03 19:45

    This is not possible in pure PHP.

    What you call "converting" is in fact a huge, non-trivial task: the HTML page has to be rendered. To do this in PHP, you'd have to rewrite an entire web browser.

    You'll either have to use an external tool (which usually taps into a browser's rendering engine) or a web service (which does the same).

提交回复
热议问题