I have googled how to create web page thumbnail.
Hope this post helps anyone who are trying to create web page image.
So the strategy above looks only the way to detect loading web page is completed.
I don't have to write much.
You should simply prepare javascript given to PhantomJS.
Please refer this
Hope this post helps anyone who are trying to create web page image.
Java
- Lunch a native browser from Desktop class and capture active window by Robot class I think this isn't smart way however it should work. Please read this.
- Using SWT Browser Please read this. The biggest disadvantage is again you cannot do it on off screen.
- Pure Java Solution If you are seeking pure java solution, maybe Cobra or Css Box will help you.
- Using QT-Jambi I'm not familiar with Qt library but this post explains how to create web page image by Qt Jambi, which is java wrapper of Qt Library.
The disadvantage of this method is you cannot achieve it on off screen.
Unfortunately Cobra is not updated recently, and Css Box is still very new on the other hand.
I hope I can post example of code on this blog in near future....
The post provides code example, too!!
C#
- Using System.Windows.Forms.WebBrowser this article in www.codeproject.com is really good example.
I have tried the code provided on the above article a bit and confirmed it worked quite well.
What I would not prefer is using while loop and Application.DoEvents().
while (webBrowser.ReadyState != WebBrowserReadyState.Complete) { Application.DoEvents(); }However if WebBrowser component is not visible, webBrowser.DocumentCompleted is not fired.
So the strategy above looks only the way to detect loading web page is completed.
PhantomJS
I think using PhantomJS is the smartest and easiest way to achieve if you can use it on your environment.I don't have to write much.
You should simply prepare javascript given to PhantomJS.
Please refer this
コメント