All property & function names are self-explanatory. You’d be able to understand them even without the manual. However, I hate great product with poor documentation. The following type library definitions are written in Delphi, one of my favourite programming languages. OK, let’s go…

  • Properties
  • Functions
  • Events
  • Enumerations
  • Properties

    {<<< Output filename for snapshot image (full-length page)>>>}
    // eg. 'snapshot.gif', 'c:\webshot.jpg'
    // default value : 'snapshot.PNG'
    property OutputImage: WideString read Get_OutputImage write Set_OutputImage;
     
    {<<< Output filename for thumbnail image (created from snapshot image)>>>}
    // eg. 'thumbnail.bmp', 'c:\thumb.png'
    // default value : thumbnail.PNG'
    property OutputThumbnail: WideString read Get_OutputThumbnail write Set_OutputThumbnail;
     
    {<<< Whether to process windows messages or not, set to TRUE 
    only when you're calling from a win form app that has a message loop, 
    which allows the control to fire "OnStatusText" event. Otherwise your UI 
    would be frozen during snapshooting. For server side integration, 
    errors may occur if this property is set to TRUE, so just leave it default >>>}
    // default value : FALSE
    property ProcessWinMsg: WordBool read Get_ProcessWinMsg write Set_ProcessWinMsg;
     
    {<<< Browser window width in pixels >>>}
    // default value : 800
    property BrowserWidth: Integer read Get_BrowserWidth write Set_BrowserWidth;
     
    {<<< While creating thumbnail from original snapshot, 
    Htm2PicX crops height to specified value in pixels. 
    Thus you can pick the part you want and avoid getting a distorted one.
    Set to zero if you do not want to crop. >>>}
    // default value : 600
    property CropHeightTo: Integer read Get_CropHeightTo write Set_CropHeightTo;
     
    {<<< Force to take snapshot if timeout >>>}
    // default value : TRUE
    property ForceCapture: WordBool read Get_ForceCapture write Set_ForceCapture;
     
    {<<< Timeout in milliseconds >>>}
    // default value : 10000 
    property TimeOut: Integer read Get_TimeOut write Set_TimeOut;
     
    {<<< Delay in milliseconds. If set to zero, there would be no delay. >>>}
    // default value : 0
    property Delay: Integer read Get_Delay write Set_Delay;
     
    {<<< Jpeg compression quality control.  0-100, the bigger number the higher quality. >>>}
    // default value : 95
    property JpegQuality: Integer read Get_JpegQuality write Set_JpegQuality;
     
    {<<< You can create thumbnail image in 2 resizing methods, by fixed width&height 
    or by zoom ratio. These 2 properties are valid while "ResizeType" is 
    set to RT_RECT(refer to "Enumeration" section). You can also call the "SetThumbSize" 
    function to set these 2 properties at one time (refer to "Functions" section) >>>}
    // default value : 400
    property ThumbWidth: Integer read Get_ThumbWidth write Set_ThumbWidth;
    // default value : 300
    property ThumbHeight: Integer read Get_ThumbHeight write Set_ThumbHeight;
     
    {<<< Zoom ratio for thumbnail creation. Valid while "ResizeType" is set to RT_ZOOM >>>}
    // default value : 0.50
    property ThumbZoomRatio: Double read Get_ThumbZoomRatio write Set_ThumbZoomRatio;
     
    {<<< Resizing method for thumbnail creation >>> }
    // default value : RT_RECT (refer to "Enumerations" section)
    property ThumbResizeType: ResizeType read Get_ThumbResizeType write Set_ThumbResizeType;
     
    {<<< By default, Htm2PicX send request to the given URL using "GET" method.
    If this property gets set, "POST" method would be used instead, you know the rest >>> }
    // eg. 'username=dennis&password=123456'
    // default value : empty
    property PostData: WideString read Get_PostData write Set_PostData;
     
    ////////////////////////////////////////
    ///  download control properties  ///
    ////////////////////////////////////////
     
    // Disable script
    // default value : FALSE
    property NoScript: WordBool read Get_NoScript write Set_NoScript;
    // Disable activex
    // default value : FALSE
    property NoActiveX: WordBool read Get_NoActiveX write Set_NoActiveX;
    // Disable java applet
    // default value : TRUE
    property NoJava: WordBool read Get_NoJava write Set_NoJava;
    // Disable image
    // default value : FALSE
    property NoImage: WordBool read Get_NoImage write Set_NoImage;
    // Disable video
    // default value : TRUE
    property NoVideo: WordBool read Get_NoVideo write Set_NoVideo;
    // Disable background sound
    // default value : TRUE
    property NoBgSound: WordBool read Get_NoBgSound write Set_NoBgSound;

    Functions

    {<<< Get your user name and registration key set to remove watermarks in generated images>>>}
    procedure SetRegInfo(const AUsr: WideString; const APwd: WideString); safecall;
     
    {<<< Main functions for taking a snapshot of a webpage, the "Url" param could be
     a valid internet URL or a local webpage that may be rendered in common webbrowser. 
    The leading protocal identifier "http://" is not necessary for URLs.
    eg. 'http://www.google.com', 'www.yahoo.com' , 'C:\mypage.html'  
    For return value, refer to "Enumerations" section. >>>}
    function Snapshot(const Url: WideString): SnapshotResult; safecall;
    function SnapshotAs(const AURL: WideString; const AOutput: WideString): SnapshotResult; safecall;
     
    {<<< Now you can turn html source code into image with ease by calling these 2 functions >>>}
    function SnapshotHtml(const AHtml: WideString) : SnapshotResult; safecall;
    function SnapshotHtmlAs(const AHtml: WideString; const AOutput: WideString): SnapshotResult; safecall;
     
    {<<< Call "Stop" to interrupt during snapshooting>>>}
    procedure Stop; safecall;
     
    {<<< Call this to get detailed error message if error occurs >>>}
    function GetLastError: WideString; safecall;
     
    {<<< Create a thumbnail image in memory >>>}
    function MakeThumbnail: SnapshotResult; safecall;
     
    {<<< It calls "MakeThumbnail" first and save the image to disk >>>}
    function SaveThumbnail: SnapshotResult;
     
    {<<< For this one, you can specify the output filename >>>}
    function SaveThumbnailAs(const AFileName: WideString): SnapshotResult; safecall;
     
    {<<< Get the HBITMAP handle of the snapshot image in memory >>>}
    function GetSnapshotHandle: Integer; safecall;
     
    {<<< Get the HBITMAP handle of the thumbnail image in memory >>>}
    function GetThumbnailHandle: Integer; safecall;
     
    {<<< Htm2PicX has a built-in image list from which you can create multi-page TIFF/PDF/DCX documents. >>>}
    // Add current thumbnail to the image list
    procedure AddThumbnailToList; safecall;
    // Add current snapshot to the image list
    procedure AddSnapshotToList; safecall;
    // Clear the image list
    procedure ClearImageList; safecall;
    // Load a local image into the image list
    procedure AddImageToList(const AFileName: WideString); safecall;
     
    // Create multi-page TIFF document
    procedure MakeMultiPageTiffAs(const AFileName: WideString); safecall;
    // Create multi-page PDF document
    procedure MakeMultiPagePdfAs(const AFileName: WideString); safecall;
    // Create multi-page DCX document
    procedure MakeMultiPageDcxAs(const AFileName: WideString); safecall;
     
    ////////////////////////////////////////
    ///   thumbnail effect functions   ///
    ////////////////////////////////////////
     
    {<<< The color param can be RGB Color HEX string with leading '#' (eg: #c0c0c0) or Common Color Name (black,red,blue,yellow,white,Maroon,Green,Olive,Navy,Purple,
    Teal,Gray,Silver,Lime,Fuchsia,Aqua,LtGray,DkGray) >>>}
    // BorderWeight(0-255)
    procedure SetThumbEffectButtonize(const BorderColor: WideString; BorderWidth: Integer;  BorderWeight: Integer); safecall;
    // Head to "Enumerations" section to check out "ShadowType"
    procedure SetThumbEffectDropShadow(Value: ShadowType); safecall;
    // Alpha(0-255) Htm2PicX applies a linear transform from one alpha value to another to the reflection area
    procedure SetThumbEffectReflection(APercent: Integer; const ABgColor: WideString; AAlphaA: Integer; AAlphaB: Integer); safecall;
    procedure SetThumbEffectRoundCorner(const ABgColor: WideString; ARadius: Integer); safecall;
    // "ARWidth" and "ARHeight" determines the final size of output image, Htm2PicX would automatically determine if you set them to zero.
    procedure SetThumbEffectRotate(ARWidth: Integer; ARHeight: Integer; AAngle: Double; const ABgColor: WideString); safecall;
    // "ALenA" and "ALenB" would also be automacally determined if set to zero.
    procedure SetThumbEffectTilt3D(ATiltType: Tilt3DType; ALenA: Integer; ALenB: Integer; ATiltAngle: Double; const ABgColor: WideString); safecall;
    // Cancel any effect setting
    procedure SetThumbEffectNone; safecall;
     
    {<<< This is a util function as it can convert images from one format to another among the supported ones.
    For "OutFormat" param, refer to "Enumerations" section >>>}
    // Htm2Pix currrently supports BMP, PNG, GIF, JPG, PCX, DCX, TGA, EMF, WMF, TIF, PDF
    procedure ConvertImage(const InFile: WideString; const OutFile: WideString; OutFormat: Integer); safecall;

    Events

    procedure OnStatusText(const AText: WideString); 
    // Currently "AErrCode" is reserved, all errors has an error code of zero
    procedure OnError(AErrCode: Integer; const AErrMsg: WideString);
    // "ACode" is one of the values defined in enumeration type : SnapshotResult
    procedure OnComplete(ACode: Integer);

    Enumerations

    // Constants for enum SnapshotResult
    type
      SnapshotResult = TOleEnum;
    const
      HTM2PIC_SUCCESS = $00000000;
      HTM2PIC_FAILURE = $00000001;
      HTM2PIC_TIMEOUT = $00000002;
      HTM2PIC_EXCEPTION = $00000003;
      HTM2PIC_INTERRUPT = $00000004;
     
    // Constants for enum ResizeType
    type
      ResizeType = TOleEnum;
    const
      RT_ZOOM = $00000000;
      RT_RECT = $00000001;
     
    // Constants for enum ShadowType
    type
      ShadowType = TOleEnum;
    const
      ST_RIGHT_TOP = $00000000;
      ST_RIGHT_BOTTOM = $00000001;
      ST_LEFT_TOP = $00000002;
      ST_LEFT_BOTTOM = $00000003;
      ST_RECT = $00000004;
     
    // Constants for enum EffectType
    type
      EffectType = TOleEnum;
    const
      ET_BUTTONIZE = $00000000;
      ET_DROP_SHADOW = $00000001;
      ET_REFLECTION = $00000002;
      ET_ROUND_CORNER = $00000003;
      ET_ROTATE = $00000004;
      ET_TILT_3D = $00000005;
     
    // Constants for enum Tilt3DType
    type
      Tilt3DType = TOleEnum;
    const
      TT_VERT = $00000000;
      TT_HORI = $00000001;
     
    // Constants for enum ImageFormat
    type
      ImageFormat = TOleEnum;
    const
      IF_JPG = $00000000;
      IF_GIF = $00000001;
      IF_BMP = $00000002;
      IF_PNG = $00000003;
      IF_TIF = $00000004;
      IF_PCX = $00000005;
      IF_DCX = $00000006;
      IF_TGA = $00000007;
      IF_WMF = $00000008;
      IF_EMF = $00000009;
      IF_PDF = $0000000A;

    VB

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    
    Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
    Private Declare Function GetExitCodeProcess Lib "kernel32" (ByVal hProcess As Long, lpExitCode As Long) As Long
    Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
     
    Const PROCESS_QUERY_INFORMATION = &H400
    Const STILL_ALIVE = &H103
     
    Private Sub Command1_Click()
    	Dim pid As Long
    	'change to vbHide to disable prompt window
    	pid = Shell("c:\Htm2PicCmdLine.exe /url http://www.google.com", vbNormalFocus)	
    	hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, 0, pid)
    	Do
    		Call GetExitCodeProcess(hProcess, ExitCode)
    		DoEvents
    	Loop While ExitCode = STILL_ALIVE
    	Call CloseHandle(hProcess)
    	MsgBox ("done")
    End Sub

    VC

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    
    SHELLEXECUTEINFO ShExecInfo = {0};
    ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
    ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
    ShExecInfo.hwnd = NULL;
    ShExecInfo.lpVerb = NULL;
    ShExecInfo.lpFile = "c:\\Htm2PicCmdLine.exe"; 
    ShExecInfo.lpParameters = "/url http://www.google.com"; 
    ShExecInfo.lpDirectory = NULL;
    ShExecInfo.nShow = SW_SHOW;
    ShExecInfo.hInstApp = NULL; 
    ShellExecuteEx(&ShExecInfo);
    WaitForSingleObject(ShExecInfo.hProcess,INFINITE);

    Delphi

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    
    var 
      SEI: SHELLEXECUTEINFO;
    begin
      with SEI do
      begin
        cbSize := SizeOf(SEI);
        fMask := SEE_MASK_NOCLOSEPROCESS;
        Wnd := Application.Handle;
        lpVerb := nil;
        lpFile := 'C:\Htm2PicCmdLine.exe';
        lpParameters := '/url http://www.google.com';
        lpDirectory := nil;
        nShow := SW_SHOW;
        hInstApp := 0;
        lpIDList := nil;
      end;
      ShellExecuteEx(@SEI);
      WaitForSingleObject(SEI.hProcess, INFINITE);
    end;

    C#

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    
    using System.Runtime.InteropServices;
     
    public struct ShellExecuteInfo
    {
        public int cbSize;
        public uint fMask;
        public IntPtr hwnd;
        public string lpVerb;
        public string lpFile;
        public string lpParameters;
        public string lpDirectory;
        public int nShow;
        public IntPtr hInstApp;
        public int lpIDList;
        public string lpClass;
        public IntPtr hkeyClass;
        public uint dwHotKey;
        public IntPtr hIcon;
        public IntPtr hProcess;
    }
     
    public const int SW_SHOW = 5;
    public const uint SEE_MASK_NOCLOSEPROCESS = 64;
     
    [DllImport("shell32.dll")]
    public static extern bool ShellExecuteEx(ref ShellExecuteInfo lpExecInfo);
     
    [DllImport("Kernel32.dll")]
    public static extern uint WaitForSingleObject(System.IntPtr hHandle, uint dwMilliseconds);
     
    [DllImport("Kernel32.dll")]
    public static extern bool GetExitCodeProcess(System.IntPtr hProcess, ref uint lpExitCode);
     
    private void button1_Click(object sender, EventArgs e) it55.com 
    {
        ShellExecuteInfo vShellExecuteInfo = new ShellExecuteInfo();
        vShellExecuteInfo.cbSize = Marshal.SizeOf(vShellExecuteInfo);
        vShellExecuteInfo.lpFile = @"C:\Htm2PicCmdLine.exe";
        vShellExecuteInfo.lpParameters = @"/url http://www.google.com";
        vShellExecuteInfo.nShow = SW_SHOW;
        vShellExecuteInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
        ShellExecuteEx(ref vShellExecuteInfo);
        WaitForSingleObject(vShellExecuteInfo.hProcess, int.MaxValue);
        GetExitCodeProcess(vShellExecuteInfo.hProcess, ref i);
    }

    Java

    1
    2
    3
    4
    5
    6
    7
    8
    
    try {
    	Runtime rt = Runtime.getRuntime();
    	Process proc = rt
    			.exec("C:\\Htm2PicCmdLine.exe /url http://www.google.com");
    	int exitVal = proc.waitFor();
    } catch (Throwable t) {
    	t.printStackTrace();
    }

    use the system’s built-in “wscript.shell” activex component to run any program.

    VB Script

    1
    2
    3
    4
    
    set ws=wscript.createobject("wscript.shell")
    ws.run "c:\htm2piccmdline.exe /url http://www.google.com", 0, true 
    ws.popup "done"
    set ws=nothing

    Java Script

    1
    2
    3
    
    var ws = new ActiveXObject("wscript.shell"); 
    ws.run("c:\\htm2piccmdline.exe /url http://www.google.com", 0, true);
    document.write("done!");

    PHP

    1
    2
    3
    4
    5
    
    <?php
    	$ws = new COM("wscript.shell") or die("Can't start wscript.shell!");
    	$ws->run("c:\htm2piccmdline.exe /url http://www.google.com", 0, true);
    	echo "done!";
    ?>

    [TABLE=4]
    [TABLE=5]

    Here “display char” may not be a single charactor, you can specify a string such as “Avril Lavigne”, “Its My Life” etc. The program will ignore any blank space in the string.

    By default, if you do not tick any checkbox(”Random”,”Sequence”,”use double char”), the program will use first char as rendering “pixel”. For example: you input “Image2Html”, the program gets “I” and ignore the rest.

    if you tick “Sequence”, the program will render each char in sequence. And you know how “Random” works.

    if you tick “use double char”, the program will render every 2 char as one “pixel”, thus the final output will look a bit large.

    The recommended width is 130-220 , also tick “compress” and set quality to 5-8.

    April 27th, 2008 Htm2Pic Newbie Quick Start

    Watch the demo videos now and you’ll be a master. Video1 | Video2 | Video3 | Video4

     How to take snapshots of web pages 
     How to resize captured images
     How to convert html to multi-page PDF/TIF documents
     How to add watermarks to existing images

    How to take snapshots of web pages 

        Switch to “Web Page Thumbnailer” tab and type in the URLs you want to capture in the “URL List” memo box, one URL per line. Lines with leading “#” will be treated as comments. You can use the Hotkey: CTRL + ‘/’ to comment/uncomment multiple lines that you selected. This is a very practical function and should be easy to understand especially when you have some programming experiences. You may also press ALT + ‘D’ to delete a whole line. URLs can be loaded from a text file by clicking the ”load list” button. The “grab from IE” button allows you to collect URLs in the address bar  of all existing IE browser windows. A great time saver, isn’t it ?

        In most case, you don’t have to change any of the settings above. Just press CTRL + SHIFT + ‘C’ or click the “Take snapshots!” button and Htm2Pic will get it going. You can view detailed on-going status in the “running logs” group box during capturing.

        Htm2Pic creates both full-length snapshot and thumbnail one, thus you can set the output folder respectively as well as the output format.  If you don’t wanna create thumbnail images upon capturing , just leave the output folder for thumbnails blank. Most web pages are 800 pixels in width which is the default value for “capture width”, set it to a larger value if your page oversteps.

        The “crop height to” value is effective when creating thumbnail images. It would be perfect to crop height to 600 pixels from a 800 pixel wide page if you are creating 400*300 thumbnails. In this case ,you get the part you want and avoid getting a distorted one. If you do not want to crop ( create thumbnails from the whole large image ), set “crop height to” to zero. Htm2Pic has two resizing options while creating thumbnail images, by percent or by fixed width & height. The “delay” option is very useful when some of the elements in your page takes addtional time to render after the HTML document is loaded completely such as FLASH content or web pages using AJAX.

    back to top ^.

    How to resize captured images 

        Let’s stay on the “Web Page Thumbnailer” main tab, but switch to the “Image List” sub tab, here you can add a list of images to be processed. Click the “add file(s)” button and a image file selection dialog box will popup, in which you can select multiple images at one time.(use CTRL and/or SHIFT to do so) . You may have noticed that the resizing option group box on the top of the panel is still activated, thus these settings will be applied to all images you’ve added to the “Image List”. Click on an image file to see thumbnail preview or double click to open it using your default image viewer.

        By clicking on “Make Thumbnails”, Htm2Pic would create thumbnail images on the fly.  Check the output folder when finished , you should see your expected result. (TIP: check “Open output folder for thumbnails when done” in the “Options” tab and the output folder would be opened automatically upon completion)

    back to top ^

    How to convert html to multi-page PDF/TIF documents 

        Htm2Pic’s rendering core is so flexible that you can convert HTML into multi-page PDF/TIF documents with almost no effort while taking snapshots of web pages. Here’s how you can do it: Switch to the “Options” tab, tick the “Convert snapshots to multi-page PDF/TIF when done” checkbox and specify your desired output filename. Easy enough ? Then go back to thumbnailer and try adding some sites, hit the start button, try it out yourself. 

        As an alternative, creating multi-page PDF/TIF documents from your customized local image list is also supported. Just switch to the “Image List” sub tab located in the ”Web Page Thumbnailer”, you’ll two button named “Make multi-page PDF” and “Make multi-page TIF” on the right hand of the tool bar. Well, you know the rest.

    back to top ^

    How to add watermarks to existing images 

         Adding watermarks to images is an often and highly usable demand. But almost none of the other providers offers this feature while Htm2Pic handles the task perfectly. Switch to the “Watermark Generator” tab and you’ll see all that you need, anyone with a brain can understand the settings with little effort I think. Only one thing to explain when it comes to placing an image as watermark, tick the “transparent enabled” check box and set corresponding transparent color if you don’t want the image background to be merged along. For example, set transparent color to black if your image background is black. Since PNG images may have transparent background color, Htm2Pic would first convert it into a 24bpp Bitmap and then place the watermark based on your settings.

        The watermarked image preview area is scrollable as it shows full-size image without resizing. Press the “add watermark(s) !” button and all images would be watermarked into output folder.

    back to top ^


    © 2007 Htm2Pic www.htm2pic.com All rights reserved | Webmasters, make money with Htm2Pic Affiliate Program.