If you are a Java developer and want to add conerting HTML to image feature to your Java application, ACA WebThumb ActiveX may be one of the best choice for you. It helps you convert the HTML to images in Java with a few Java API calls, it takes the snapshots of given URLs as JPG, GIF, PNG, BMP, TIFF, WMF and EMF image, capture full length website screenshots, generate thumbnail image previews of web pages.
Free Trial ACA WebThumb ActiveX Now
Java Code for Converting HTML to image:
Code File: snap.java
import sun.awt.*; import java.awt.*; import javax.swing.*; import java.awt.event.*; import java.awt.*; import java.awt.peer.*; public class Snap { static { System.loadLibrary("Snap"); } public static void main( String[] argv ) { Snap t_xSnap = new Snap(); t_xSnap.Start("http://www.google.com", "snapshot-google.png"); } public native void Start(String pi_strURL, String pi_strImageName); }
Code File: snap.cpp
#include <windows.h> #include <atlbase.h> #include "snap.h" #pragma comment(lib,"atl.lib") #import "./../../acawebthumb.dll" no_namespace JNIEXPORT void JNICALL Java_Snap_Start(JNIEnv *pEnv, jobject, jstring pi_strUrl, jstring pi_strFileName) { CoInitialize(0); _bstr_t t_strUrl = pEnv->GetStringUTFChars(pi_strUrl, 0); _bstr_t t_strFileName = pEnv->GetStringUTFChars(pi_strFileName, 0); IThumbMakerPtr HTML_Converter = NULL; HRESULT hr = HTML_Converter.CreateInstance(L"ACAWebThumb.ThumbMaker"); if (SUCCEEDED(hr)) { HTML_Converter->SetURL(t_strUrl); if ( 0 == HTML_Converter->StartSnap() ) HTML_Converter->SaveImage(t_strFileName); } if (HTML_Converter) HTML_Converter.Release(); CoUninitialize(); }
Code File: Build.bat
@echo off REM ====================================================== REM To build this Java sample code, REM Please set your VCBIN and JDKFOLDER folder first REM ====================================================== echo Setting Environment... SET VCBIN=D:\Dev\Tool\Microsoft Visual Studio 8\VC\bin SET JDKFOLDER=D:\apps\Java\jdk1.6.0_11 call "%VCBIN%\VCVARS32.BAT" cd /D "%~dp0" echo Compiling Java script... "%JDKFOLDER%\bin\javac" Snap.java "%JDKFOLDER%\bin\javah" -classpath . Snap echo Building DLL... cl Snap.cpp -I"%JDKFOLDER%\include\Win32" -I"%JDKFOLDER%\Include" -FeSnap.dll -MT -LD /link user32.lib gdi32.lib echo Running Sample... "%JDKFOLDER%\bin\java" Snap
Free Trial ACA WebThumb ActiveX Now