Capture an HTML document as an image

K

kellyhughes777

I need a working example of code to do this or some specific pointers
with the code below. I can provide more of the surrounding code block
if necessary.

I need my Application to be able to create a full page image of a
given web page. This will be used to perform a fax. I have located
several articles about this giving sample code using shdocvw.WebBrowser
to navigate to the target html and then grabbing the render object to
paint onto the device context of our choice.
ex.:
http://dotnetjunkies.com/WebLog/alan.dean/archive/2005/04/25/70496.aspx
http://blogs.msdn.com/rfarber/archive/2004/10/12/240943.aspx

I am currently attempting to use this method, but my problem is that I
can't get a valid IHTMLElementRender object so i can perform the
render.
It gives me an invalidcastexception. The (correctly?) implemented
fixes recommended in the rfarbers article aren't resolving the issue.

Here's the offending line:
Dim render As IHTMLElementRender = CType(elmnt, IHTMLElementRender)

Thanks for your help.

kelly

(Any VB or C# responses are welcome, WinForms or Web.
However, my app is a web app.)

Please pardon the cross post. I posted this question in another forum
but am not getting any
responses and my deadline is quickly approaching.
 
L

Li-fan Chen

Hi Kelly,

IECapt.exe may bypass the whole problem for you. Please look into whether it
will play as an alternative.

Best regards,
-- Li-fan
 
K

kellyhughes777

Thanks for the response Li-fan,

I did look at IECapt, but I have some constraints which make that
solution difficult:
1.) the target web page is behind a login page, which means we cannot
just pass IECapt a url, but will need to pass it raw html.
2.) the application is a web app, which means that the solution needs
to be thread safe.

I would peer into the IECapt code for some techniques, but it is a C++
application, and my final deliverables need to be VB.NET.
 
P

Patrice

Is this the only option ? I used once a fax solution that was able to
convert from several formats including basic HTML...
 
K

kellyhughes777

Thanks for the suggestion, I can Google for 3rd parties. But due to
customer & project constraints I am most likely constrained to thier
current, non thread safe, print driver solution, or the prefered
GDI/GDI+ solution.

Using GDI and GDI+ to natively grab the image is strongly prefered,
especially since others have posted great success getting this to work,
and I seem to only have this one roadblock.

Additionally, most 3rd party solutions appear to be cludging together
print driver solutions which bring other issues to the table.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top