473,794 Members | 2,765 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Printing in landscape mode

I tried posting earlier and it never showed up..

I have a simple program to print a text file. I need to know how to change the page settings to landscape if it is not already in ladnscape mode. I do not want to use a dialog to do it and this appears the only way you can do it. I just need it to spit out the print in landscape orientation. Why is this so hard to do for something that should be easy.
Nov 20 '05 #1
5 6873
* "=?Utf-8?B?Y3BvcGhhbQ= =?=" <an*******@disc ussions.microso ft.com> scripsit:
I have a simple program to print a text file. I need to know how to
change the page settings to landscape if it is not already in ladnscape
mode. I do not want to use a dialog to do it and this appears the only
way you can do it. I just need it to spit out the print in landscape
orientation. Why is this so hard to do for something that should be
easy.


Sample taken from MSDN documentation:

\\\
Public Sub Printing()
Try
streamToPrint = New StreamReader(fi lePath)
Try
printFont = New Font("Arial", 10)
Dim pd As New PrintDocument()
AddHandler pd.PrintPage, AddressOf pd_PrintPage
pd.PrinterSetti ngs.PrinterName = printer
' Set the page orientation to landscape.
pd.DefaultPageS ettings.Landsca pe = True
pd.Print()
Finally
streamToPrint.C lose()
End Try
Catch ex As Exception
MessageBox.Show (ex.Message)
End Try
End Sub
///

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #2
Try this line

PrintDoc.Defaul tPageSettings.L andscape = True

HTH

Les Smith

http://www.KnowDotNet.com

Articles, add-ins, free code.

"cpopham" <an*******@disc ussions.microso ft.com> wrote in message
news:E1******** *************** ***********@mic rosoft.com...
I tried posting earlier and it never showed up...

I have a simple program to print a text file. I need to know how to

change the page settings to landscape if it is not already in ladnscape
mode. I do not want to use a dialog to do it and this appears the only way
you can do it. I just need it to spit out the print in landscape
orientation. Why is this so hard to do for something that should be easy.
Nov 20 '05 #3
* "=?Utf-8?B?Y3BvcGhhbQ= =?=" <an*******@disc ussions.microso ft.com> scripsit:
PrintDocument.D efaultPageSetti ngs.Landscape = True

I have tried that in several different ways and it compiles fine, but
it does not change the page settings from portrait to landscape. It is
as if the DefaultPageSett ings are just there for you to check the page
settings.


I have not tested it, but try to set the orientation before the
'PrintPage' handler is called for the page.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #4
You need to call this code before you start the printing process. i.e.,
before the PrintPage event gets called.
Les]

"cpopham" <an*******@disc ussions.microso ft.com> wrote in message
news:90******** *************** ***********@mic rosoft.com...
That one part:

PrintDocument.D efaultPageSetti ngs.Landscape = True

I have tried that in several different ways and it compiles fine, but it does not change the page settings from portrait to landscape. It is as if
the DefaultPageSett ings are just there for you to check the page settings.
I am using version 2003, I do not know if that makes a difference.

This is my code so far:

Private Sub AuditorPrintDoc ument_PrintPage (ByVal sender As Object, _
ByVal e As System.Drawing. Printing.PrintP ageEventArgs) _ Handles AuditorPrintDoc ument.PrintPage

Dim R As Rectangle
Dim PicW, PicH, PicL, PicT As Integer

With AuditorPrintDoc ument.DefaultPa geSettings
.Landscape = True
End With

PicW = Me.SizePictureB ox.Width
PicH = Me.SizePictureB ox.Height

With AuditorPrintDoc ument.DefaultPa geSettings.Pape rSize
PicL = (.Width - PicW) / 2 - 30
End With

PicT = 20

R = New Rectangle(PicL, PicT, PicW, PicH)
e.Graphics.Draw Image(SizePictu reBox.Image, R)

End Sub

Nov 20 '05 #5
Add a handler for OnQueryPageSett ings and set the Landscape property there.
Quick ex.
Private Sub
AuditorPrintDoc ument_OnQueryPa geSettings(Quer yPageSettingsEv entArgs e)
base.OnQueryPag eSettings(e)
e.PageSettings. Landscape = True
End Sub

Ron Allen
"cpopham" <an*******@disc ussions.microso ft.com> wrote in message
news:90******** *************** ***********@mic rosoft.com...
That one part:

PrintDocument.D efaultPageSetti ngs.Landscape = True

I have tried that in several different ways and it compiles fine, but it does not change the page settings from portrait to landscape. It is as if
the DefaultPageSett ings are just there for you to check the page settings.
I am using version 2003, I do not know if that makes a difference.

This is my code so far:

Private Sub AuditorPrintDoc ument_PrintPage (ByVal sender As Object, _
ByVal e As System.Drawing. Printing.PrintP ageEventArgs) _ Handles AuditorPrintDoc ument.PrintPage

Dim R As Rectangle
Dim PicW, PicH, PicL, PicT As Integer

With AuditorPrintDoc ument.DefaultPa geSettings
.Landscape = True
End With

PicW = Me.SizePictureB ox.Width
PicH = Me.SizePictureB ox.Height

With AuditorPrintDoc ument.DefaultPa geSettings.Pape rSize
PicL = (.Width - PicW) / 2 - 30
End With

PicT = 20

R = New Rectangle(PicL, PicT, PicW, PicH)
e.Graphics.Draw Image(SizePictu reBox.Image, R)

End Sub

Nov 20 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1724
by: BlueSky | last post by:
Hi, I want to print in Landscape format from an aspx page (when ever the user chooses print from the browser or a print button on the form). I load aspx controls dynamically on the page. I used the following style sheet with which I was able to print in Landscape mode, if there is no <form> tag on the page. <style type="text/css" media="print"> DIV.page { MARGIN: 10% 0%; WRITING-MODE: tb-rl; HEIGHT: 80% }
1
2529
by: nuhura01 | last post by:
I want a printing properties to be set to landscape mode, so that when the user click a print button, it will print in landscape mode automatically. I use this code in the code-behind of the web form to print the page: HttpContext.Current.Response.Write("<script>window.print();</script>") How could I set it to print in landscape mode? Any solution for this?
2
8463
by: FireStarter | last post by:
I am apparently unable to print landscape... maybe I'm doing something wrong here. I am adding a printDocument to a form. The form also has a textbox containing the text that I want to print and a button that triggers the printing. All properties of all objects are left intact for simplicity's sake. Code on the form:
4
8750
by: Deano | last post by:
I'm in the situation of having to print a form - not a report. This will fit nicely in a landscape format but by default it prints portrait. Is there any code to make it play nice?
4
2461
by: sarn555 | last post by:
Dear, I want to print a VB6 form in landscape orientation and it should be done in a running mode. I mean through coding everything must be done at runtime. By default, the Form.PrintForm method prints the form in portrait mode, but I want to print the form in landscape mode. What should I do?
1
1613
Ali Rizwan
by: Ali Rizwan | last post by:
Hi all, How can print data report in landscape mode./ Thanx >> ALI <<
2
2453
by: chpadmamca | last post by:
Below is my html code, is there any way to print this document in landscape mode wih CSS? <html><head><style type="text/css"> table.fixed {table-layout:fixed; width:100%; border-collapse: collapse; word-wrap:break-word;}TR.head{font-family: verdana; font-size: 10pt; vertical-align: top ; color: #ffffff; background-color: black; font-weight: bold; }TR.data{font-family: verdana; font-size: 8pt; vertical-align:...
2
2540
Claus Mygind
by: Claus Mygind | last post by:
For my intranet web app we use exclusively FireFox as our browser. I have a report I want to format in the landscape mode and would like to include that code in the print button I display for the user. If it is possible could you please show some sample code?
2
3788
by: dhivyavasya | last post by:
I have to print a web page in landscape mode automatically when print is given. i dont want to go to settings and change the mode manually each time. help is needed
0
9518
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10212
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10161
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7538
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6777
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5436
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5560
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3720
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2919
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.