Html To Image: GetImageBytes method

Some times you may not want to write the image converted from html page to an image file. You may want to write the image data to another place like a network stream or a database, etc.

GetImageBytes is designed for this kind of scenerio. It is used to do in memory compression of the bitmap from html. It has one string parameter, which can be .jpg, .tiff or .png etc. to represent the image coding format. Then html snapshot will do compression and return an OLE byte array (1 dimension) that holds the compressed data.

Then you are free to write the data to anywhere. We have provided a VBScript demo in the blob.vbs. Here is another C# demo.

After you call SnapUrl and it returns, you can do the following:

                    byte[] data = (byte[])snap.GetImageBytes(“.tiff”);
                    FileStream  fs = File.OpenWrite(@”c:1.tiff”);   
                    BinaryWriter br = new BinaryWriter(fs);