How to convert long HTML to several separate image files?

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.");

Leave a Reply

You must be logged in to post a comment.