通过代码拍摄网页的屏幕截图

I have a website which generates HTML tags dynamically in a specific div. Now after all the HTML tags are created I save these HTML tags in Database. The problem is that I need to take the Screen Shot of the web page where the HTML Tags are generated. when I am about to save it, but;

  1. I cant Imagine where to begin as far as the screen shot thing goes.
  2. I don't want to use Third party API as what they generally do is ask for a url and then go to the website take a screen shot and then email it to you.

why I cant use them is because when i dynamically create HTML Tags they are just on the browser. if someone else try to access the same link they will get a page without the currently created HTML Tags (even if I refresh the page the tags are gone.).

I dont want a complete solution just a Tip on how to start building the solution for this problem, and by screen shot I mean Images.

Thank you.

My recommendation would be to use PhantomJS, it's sort of a web browser that you can run via command line, and specify the output. You can specify it to be an image, a pdf, or other things.

The bad thing is that you need somewhere to point it, but otherwise it's excellent for these kinds of things. But it doesn't have to be a public url, it could be used internally, or maybe even supply the html from somewhere else.

Use webshot library it is simple and easy to use. you can also use window.print() method to take screen shot of webpage