search

Home  >  Q&A  >  body text

javascript - To create a snapshot function, how to directly generate images from the html page?

After reading many answers on the Internet, they all said to generate pdf first and then convert it into pictures, but I tried it. Generating pdf from html will mess up the page style, and then use imagick to convert pdf into pictures. I have always installed this extension. Unsuccessful, there is nothing in phpinfo(), so I would like to ask if there is a one-step method to directly convert the html page into an image?

高洛峰高洛峰2844 days ago406

reply all(5)I'll reply

  • 巴扎黑

    巴扎黑2017-05-16 12:04:06

    html2canvas.js

    reply
    0
  • PHP中文网

    PHP中文网2017-05-16 12:04:06

    It should be regarded as a screenshot. phantomjs can simulate the browser kernel. Of course, taking screenshots is not a problem. You can search for usage

    reply
    0
  • 迷茫

    迷茫2017-05-16 12:04:06

    It seems that there is a program called dom-to-image.js, which converts dom nodes into base64 strings. You can check it

    reply
    0
  • 巴扎黑

    巴扎黑2017-05-16 12:04:06

    You can use imagegrabwindow to take screenshots

    reply
    0
  • 黄舟

    黄舟2017-05-16 12:04:06

    rasterizeHTML.js This one is much better than that html2canvas.js, go check it out

    reply
    0
  • Cancelreply