Convert html to image in IIS

This article will discuss how to use html snapshot to convert html to image (JPG, TIFF, GIF, PNG and BMP) under IIS (with ASP or ASP.net)

First, we will discuss IIS 5.0 on Windows XP.  

There are two accouts in IIS 5.0. IUSR_MACHINENAME, IWAM_MACHINENAME.

For the default setting, IUSR_MACHINENAME account is used to access files (reading or writing).

IWAM_MACHINENAME is used to run out-of-process ActiveX object such as Html Snapshot.

For normal html page without ActiveX in it,  we just need to give the IUSR_MACHINENAME write access to the folder  for saving images.

But html page may contain ActiveX such as Macromedia flash movies. The flash ActiveX control needs much privilege to run. I think It needs to access sound card resources etc.

If you don’t want flash to be captured, so it is simple to disable it with the call:

 snap.EnableActiveX 0

But if you want flash, then you need to give enough privilege.

You can do following things:

1. Run DCOMCNFG, click to expand the Component Services, Computers, My Computer, and COM+ Applications nodes. Right-click the IIS Out-of-Process Pooled Applications object, and then click Properties.
On the Identity tab, Set the account to your admin account or current interactive logon user instead of the default one (IWAM_MACHINENAME).

Note, after the account changes, you need to restart IIS (or kill the dllhost.exe running under IWAM_MACHINENAME with taskmgr).
2. Call SetLogOnUser(“admin”, “.”, “password”) before calling SnapURL. Then SnapUrl will impersonate with the logon information when converting html to image.
 

If you use Windows 2003, it is a totally different story since Windows 2003 uses IIS 6.0.

To convert html pages with flash movie to image on Win2003 server, you can do following:

1.  In IIS admin UI, Set the Application Pool property, right click the DefaultAppPool, click property->Identity, Set the account of application pool to Local Service or Local System. (Note, you must set the account to Local System if you want to convert html page which contains ActiveX like Flash movies)

Also, remove “internet explorer enhanced security” in the control panel. It may block the action to convert a URL to image.

2. Call SetLogOnUser(“admin”, “.”, “password”) before calling SnapURL. Then SnapUrl will impersonate with the logon information when converting html to image.

See a snapshot of www.macromedia.com below.

 

macromedia