Skip to main content



      Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Programmatic web page image creation using SWT
icon5.gif  Programmatic web page image creation using SWT [message #531705] Wed, 05 May 2010 16:41 Go to next message
Eclipse UserFriend
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 possible?

Thank you
Re: Programmatic web page image creation using SWT [message #532218 is a reply to message #531705] Fri, 07 May 2010 10:45 Go to previous message
Eclipse UserFriend
Hi,

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:

http://www.eclipse.org/swt/faq.php#howusemozilla
http://www.eclipse.org/swt/faq.php#howusejavaxpcom
https://addons.mozilla.org/en-US/firefox/addon/3408

HTH,
Grant


"Brent" <bwenerstrom@gmail.com> wrote in message
news:hrsl6a$kob$1@build.eclipse.org...
> 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
possible?
>
> Thank you
Previous Topic:SWT Table
Next Topic:JavaDoc Typo
Goto Forum:
  


Current Time: Tue Jul 22 18:53:01 EDT 2025

Powered by FUDForum. Page generated in 0.03721 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top