PDA

Click to See Complete Forum and Search --> : print and print preview with api


lumin
Nov 26th, 2000, 05:49 PM
Greetings,

Does anyone know how to Preview a HTML page with api and then eventualy print it ?

Thanks in advance!


-Lumin

Nov 26th, 2000, 07:35 PM
Use the Webbrowser Control.
First create the page:

Open "C:\htmlpage.htm" For Output As #1
Print #1, Text1.text
Close #1

Then, in the Custom Controls list, choose Microsoft Internet Controls.
And then navigate to the file:

Webbrowser1.Navigate "C:\htmlpage.htm"

And then have a print button:

Private Sub CmdPrint_Click()
WebBrowser1.ExecWB OLECMDID_PRINT, _
OLECMDEXECOPT_PROMPTUSER
'If you don't want to prompt the user to print:
'WebBrowser1.ExecWB OLECMDID_PRINT, _
OLECMDEXECOPT_DONTPROMPTUSER
End Sub

lumin
Nov 27th, 2000, 06:14 PM
Thanks, But im trying to avoid using the webbrowser control since its taking space and my program should take as little KB as possible. :)

So I was wondering if windows has any Dll's I can call up instead. since windows usualy has Dll'd loaded for almoust evrything I would expect it to have a dll with these kind of functions. or am I expecting to much of windows now ? :D

Anyway thanks for the help.


-Lumin

lumin
Nov 27th, 2000, 06:16 PM
Oh dang it.. I didn't read your post entierly .. sorry gona try your sugjestion now

Thanks!!


-Lumin

Nov 27th, 2000, 06:28 PM
You can avoid the Webbrowser Control.

What you can do...is reference it instead. So you don't have to use the control on your form, but rather, open IE and preview it from there.

'Form Declarations:

Dim ie As New Internet Explorer

Private Sub cmdPreview_Click()
ie.Navigate "C:\htmlpage.htm"
ie.Visible = True
End Sub


That is probably one of the closest ways that you can get to being able to preview and print it. And the user can just use the IE window's Printing.


Private Sub CmdPrint_Click()
ie.ExecWB OLECMDID_PRINT, _
OLECMDEXECOPT_PROMPTUSER
'If you don't want to prompt the user to print:
ie.ExecWB OLECMDID_PRINT, _
'OLECMDEXECOPT_DONTPROMPTUSER
End Sub

^I assume it'd work the same way as the Webbrowser Control.

It may still take up space, but I don't think your going to find any other way. There are controls out there that can print and have a print preview on them, you may want to look for them if you don't like my way.

But, I'm just giving you suggestions :rolleyes:.