How to access Explorer...Print function from code?

  • Thread starter Thread starter Andrew Meador
  • Start date Start date
A

Andrew Meador

I have a button on my form to "Print". I would like to create an
HTML file, of the output, and call the Explorer...Print function when
this "Print" button is clicked. How can I do this - the
Explorer...Print part? I can create the HTML file, just need help with
calling the Explorer...Print function - supplying the path to the file
so that only the Print Dialog pops up once they click on "Print"

Thanks!
 
Printing in windows forms is not normally performed like that. Printing is
normally done with a PrintDocument class which has an event which you handle
to do the printing which is done by GDI type drawing.
The easiest/cheapest/dirtiest way of doing what you want would be with a
Browser control. You could load the HTML into the browser control and call
the print function on that. That would then work just like internet explorer.
 
Hello,

look at this:http://www.codeproject.com/KB/printing/printhml.aspx

Hope it helps.

Leo







- Show quoted text -

Thanks Leo - this was what I was looking for. Got it done and it
works perfectly. I HATE windows printing. I have been looking at
ASP.NET programming a bit lately and didn't see why I shouldn't just
have my app create an HTML file/report and use this method to print
the html file. I seems to me that this is a lot easier than dealing
with the whole GDI/drawing approach. I get tables, borders, fonts,
etc... without having to deal with the font size calculations, line
spacing/tracking, etc...

If there is any other way that you guys recommend, I'm all ears,
but until then - I like this method! :)

Andrew
 
Back
Top