|Re: Programmatic web page image creation using SWT [message #532218 is a reply to message #531705]
||Fri, 07 May 2010 14:45
| Grant Gayed
Registered: July 2009
Unfortunately the Browser cannot compute a "preferred size" like other
controls because HTML's flowing nature doesn't really prescribe a size.
Even if it did, you would still run into a problem with pages with too much
content to fix on your screen in a maximized Shell.
I think your only hope for doing this is to use a SWT.MOZILLA-style Browser
and use JavaXPCOM to invoke some Mozilla functions to save the image for
you. I don't know which calls you need to make, but I see a Firefox
extension that apparently does this, so you should be able to find the calls
that are needed in its source (it's probably only be a few lines).
(Unfortunately you can't just use the extension as-is in a Browser instance,
see https://bugs.eclipse.org/bugs/show_bug.cgi?id=181008 ). If you want to
investigate implementing this then the following links should be helpful:
"Brent" <firstname.lastname@example.org> wrote in message
> I would like to crawl a number of sites using Java and both save the HTML
of the web page and an image of that web page. It appears that that SWT can
help here. The problem is that I would like an image of the entire web page.
I can only figure out how to obtain a fixed size view of the page.
> How do you discover the size of the contents of a browser object? I have
tried getBounds, getSize, getClientArea, and computeSize. All of these
methods only give me the currently displayed size, not the size of the
destination web page. I would like to resize the window to contain the whole
web page and save this to a file with no visible scroll bars. Is it
> Thank you
Powered by FUDForum
. Page generated in 0.01553 seconds