How can I programatically print HTML docs?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

....not from a form, but from a class, with given a file location.

....if there is a way to create an html Document from a string, then print
from memory, (ie no disk IO) that would be even better...

Thanks, Dave
 
Hi Dave...

I don't know exactly what kind of HTML manipulation you are providing, but
I've tested a good ActiveX Control named "DHTMLEdit for IE".
With the DHTMLEdit control you can let the user to edit text like a
traditional text box does, but it has a method named ExecCommand for
applying format (for example, bold, italic, insert images, and so on).
Besides, it has a method named PrintDocument which gives you a result
similar to that you get when you print Web Pages from the Print button in
the Internet Explorer tool bar.

Hope it helps...

Bye...
 
Thanks for the pointer...but I am having some problem getting past 1st
base...I am hoping you have some insights. I am unable to find the MSDN
online sample code, looks like it has been archived...

The following C# code is raising an exception (on line 5) whose message is
the ever popular, "The parameter is incorrect."

01: DHTMLEDLib.DHTMLEditClass dhtml = new DHTMLEDLib.DHTMLEditClass();
02: string head = "<HTML><HEAD><TITLE></TITLE></HEAD>";
03: string body = "<BODY><H1>Heading!</H1>This is a new document.";
04: string finish = "</BODY></HTML>";
05: dhtml.DocumentHTML = head + body + finish;

Of course I am getting the same exception (line 2)with:
01: DHTMLEDLib.DHTMLEditClass dhtml = new DHTMLEDLib.DHTMLEditClass();
02: dhtml.NewDocument();
 
Hello again, Dave...

You are right, I've tested your code in a C# project and found the same
Exceptions.
I don't know the reason why, the only difference I've found is that you're
using the DHTMLEDLib.DHTMLEditClass class (in the 'interop.dhtmledlib'
assembly), and I'm using the AxDHTMLEDLib.AxDHTMLEdit class (in the
'axinerop.dhtmledlib assembly') that is some kind of wrapper for the ActiveX
Control.
If you want to provide the DHTMLEdit Activex Control functionallity behind
the scenes, you can set its Visible property to false, and manipulate its
properties and call its methods.
By doing so, the user will never see the control on the form's surface.
I had no problems with the DocumentHTML (get/set) property and the
NewDocument method of the AxDHTMLEdit control.

Hope it'll help...
 
Back
Top