|
-
Jan 7th, 2009, 04:05 PM
#1
Thread Starter
Fanatic Member
web browser print
this is what i'm using to print a web page opened with the web browser control:
WebBrowser1.ShowPrintDialog()
is there a way to programatically set the document to landscape?
and also remove the head and footer?
and tell the print not to duplex?
-
Jan 7th, 2009, 04:27 PM
#2
Re: web browser print
The web browser printer dialog is a component of the browser itself. You cannot control it. If you want full control of the way the page is printed, you will need to use your own print preview control and print it yourself.
-
Jan 8th, 2009, 10:49 AM
#3
Thread Starter
Fanatic Member
Re: web browser print
i tried this but it still won't work
vb.net Code:
Dim ps As New System.Drawing.Printing.PrinterSettings
ps.DefaultPageSettings.Landscape = True
WebBrowser1.Print()
i'll keep looking, but if anybody has any suggestions, i'm all ears.
-
Jan 8th, 2009, 01:56 PM
#4
Thread Starter
Fanatic Member
Re: web browser print
this is what i have so far.
vb.net Code:
'get registry values
Dim regKey As String = "HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\PageSetup"
Dim keyDuplex As String = My.Computer.Registry.GetValue(regKey, "duplex", "no value")
Dim keyOrientation As String = My.Computer.Registry.GetValue(regKey, "orientation", "no value")
Dim keyHeader As String = My.Computer.Registry.GetValue(regKey, "header", "no value")
Dim keyFooter As String = My.Computer.Registry.GetValue(regKey, "footer", "no value")
Dim keyBottom As String = My.Computer.Registry.GetValue(regKey, "margin_bottom", "no value")
Dim keyLeft As String = My.Computer.Registry.GetValue(regKey, "margin_left", "no value")
Dim keyRight As String = My.Computer.Registry.GetValue(regKey, "margin_right", "no value")
Dim keyTop As String = My.Computer.Registry.GetValue(regKey, "margin_top", "no value")
'set temporary registry values
My.Computer.Registry.SetValue(regKey, "duplex", "1")
My.Computer.Registry.SetValue(regKey, "orientation", "2")
My.Computer.Registry.SetValue(regKey, "header", "")
My.Computer.Registry.SetValue(regKey, "footer", "")
My.Computer.Registry.SetValue(regKey, "margin_bottom", "0.00000")
My.Computer.Registry.SetValue(regKey, "margin_left", "0.00000")
My.Computer.Registry.SetValue(regKey, "margin_right", "0.00000")
My.Computer.Registry.SetValue(regKey, "margin_top", "0.00000")
WebBrowser1.Print()
'set registry values to original state
My.Computer.Registry.SetValue(regKey, "duplex", keyDuplex)
My.Computer.Registry.SetValue(regKey, "orientation", keyOrientation)
My.Computer.Registry.SetValue(regKey, "header", keyHeader)
My.Computer.Registry.SetValue(regKey, "footer", keyFooter)
My.Computer.Registry.SetValue(regKey, "margin_bottom", keyBottom)
My.Computer.Registry.SetValue(regKey, "margin_left", keyLeft)
My.Computer.Registry.SetValue(regKey, "margin_right", keyRight)
My.Computer.Registry.SetValue(regKey, "margin_top", keyTop)
the header, footer and margins all work.
but the orientation and duplex do not.
Last edited by bezaman; Jan 8th, 2009 at 02:03 PM.
-
Jan 8th, 2009, 03:16 PM
#5
Thread Starter
Fanatic Member
Re: web browser print
*** can't get it to work.
is there a way to turn my web page into a printdocument?
-
Jan 9th, 2009, 09:33 AM
#6
Thread Starter
Fanatic Member
Re: web browser print
I looked around and apparently you cannot change the IE explorer registry values for duplex and orientation. Furthermore, I cannot find a way to print my web page using print document. So I guess i'm stuck and i'm about to give up.
Does anybody know of any other way to set the default printer properties?
or
Does anybody know of a way to print the web page to a pdf?
Last edited by bezaman; Jan 9th, 2009 at 09:51 AM.
-
Jan 26th, 2010, 05:24 AM
#7
New Member
Re: web browser print
I've been dealing with this one for a few days, and I think I found the answer.
I've tried with this one, and it works!
http://support.microsoft.com/kb/q198901/
Just follow the instructions.
I skipped the part about printer settings(steps 1-5).
Also I need to change presented code a little bit - I couldn't use DataReport1.PrintReport (from the sample code) for my printing, so I did like this:
when I want to print landscape:
obj = New PageSet.PrinterControl()
obj.ChngOrientationLandscape()
mywebbrowser.Print()
when I want to print portrait:
obj = New PageSet.PrinterControl()
obj.ReSetOrientation() 'change back to portrait orientation
mywebbrowser.Print()
Notice that probably if you do something like this:
obj = New PageSet.PrinterControl()
obj.ChngOrientationLandscape()
mywebbrowser.Print()
obj.ReSetOrientation()
you would reset the orientation to portrait before you print the document, so the document would probably wont be printed landscape..
I hope this one helps!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|