Archive for November, 2007

How to convert long HTML to several separate image files?

Friday, November 30th, 2007

We can do this using HtmlCapture V2.0 by the following steps: First, take snapshot of the whole web page, Then use the SetClipRect() function to select each parts and use the SaveImage() function to save them. The following codes in JScript show the details.

//create HtmlCapture
var snap = new ActiveXObject("HtmlCapture.SnapShooter");
snap.SetRegInfo("username", "regcode"); //set your reg code here
//change this value to change the height of each separate image
var pageHeight = 400; 
//snap it
snap.SnapUrl("http://www.yahoo.com/“);
var totalWidth = snap.GetAttributeValue("image.width");
var totalHeight = snap.GetAttributeValue("image.height");
var numPages = Math.floor(totalHeight / pageHeight); //number of pages
var mod = totalHeight % pageHeight;          //the reminder
if(mod != 0)
 numPages++;
 
for(var i=0; i<numPages; i++)
{
 snap.SetClipRect(
  0,
  i*pageHeight,
  totalWidth,
  (i+1)*pageHeight > totalHeight ? mod : pageHeight);
 snap.SaveImage("snap_page_" + (i+1) + ".png");
}

var shell = new ActiveXObject('wscript.shell');
shell.Popup("Done.");

Is there any way to get rid of the white area of the captured image?

Wednesday, November 28th, 2007

We can do  this by calling the SetMinBrowserSize() function before calling SnapUrl(). The default MinBrowserSize is 800×600, so the minimum size of the output image is 800×600. The sample codes are listed as follows

SnapShooter snap;
snap.SetMinBrowserSize(300, 200);     //set minimum browser size to 300x200
snap.SnapUrl("xxx.com");