Link to home
Start Free TrialLog in
Avatar of Thangs
Thangs

asked on

Print HTML Page

Hi,
I need to print the HTML page without displaying the print setup dialog?.
I am using the following lines of code to prin the HTML document.
c:\winnt\system32\MSHTML.dll PrintHTML "MyFile.html"
This works fine but it displays the print dialog box. Can any tell me how to avoid the display of this dialog box?

Avatar of DirkVe
DirkVe

I don't think it's possible to print without that setup dialog.

Please provide some of the code, since I've never used c:\winnt\system32\MSHTML.dll

ASKER CERTIFIED SOLUTION
Avatar of Mark Franz
Mark Franz
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Thangs

ASKER

But I am not printing from GUI. My backend class will print the HTML Document. I am developing a C++ application which prints the HTML document.
Since you've posted your question in the Active Server Pages group we all expected that you wanted to print from an asp-application and not from a C++ application.

So try asking the question in that group, I guess you'll reach the right folks. But I still think that you cannot surpress the print dialog since it's standard windows behaviour. What you can try (if your printer is connected to your local pc) is sending the output to lpt, like you do in dos:

dir * >lpt1
or
put the output in a file called doc.txt and use the dos-command:
type doc.txt >lpt1

You probably have some methods in C++ also that can send the output to lpt1 (= default printer port)
Avatar of Thangs

ASKER

DirkVe,
Since this is related with the HTML pages I asked this Question here. You might have exeperience such a problem.

Since this is not a text file which we can directly direct to the printer using Lpt1 or whatever. This is html page which need formatting before printing.
Avatar of Thangs

ASKER

mgfranz,
I hope "wbp.DefaultPrinterName" is uspported only in win2k. But I am using windows NT4.0.  Any sugegstions

I wanted to do precisely the same thing only in VB. I am giving you the code below. Because we need to do the formatting, i am using WebBrowser control.

I am sure you will be coding under SOME event, which may not be UI. Constants in code were available while using WebBrowser control. To make sure that the document is completely loaded before printing, I have placed print code in even that fires after loading the document. wbPrintHTML is WebBrowser control.

Private Sub cmdPrintHTML_Click()
    With wbPrintHTML
        .Navigate "File://c:/NitinSontakke/VBProjects/PrintHTML/Contact.htm"
    End With
End Sub

Private Sub wbPrintHTML_DocumentComplete(ByVal pDisp As Object, URL As Variant)
    If Len(URL) > 10 Then
        wbPrintHTML.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER
    End If
End Sub

Please do let me know if you need any more info.
Avatar of Thangs

ASKER

NitinSontakke ,
I tried with ExecWB also. This works but it still displays the print dialog.  I understood that OLECMDEXECOPT_DONTPROMPTUSER attribute is disabled in IE 4.0 and above. How do we get around this?

Is it possible to get the lower version of web browser control below version 4.0??
I doubt it... it wasn't until IE4 that a print() control was even available, besides why bother... less than 1% of the browser market is usinng a browser below 4.0 standards anyway, and in my opinion, they don't count... ;-)

Did you read the link I posted thangs?
I doubt it too.

I am not entirely sure, about the WebBrowser control version. If the IE version and WebBrowser control version is same, then i am using IE 5.50.4522.1800 and it works
just fine.

No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
[points to mgfranz]

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

hongjun
EE Cleanup Volunteer
As recommended

Chmod
Community Support Moderator @Experts Exchange