469,635 Members | 1,952 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,635 developers. It's quick & easy.

Printing landscape

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:

private void button1_Click(object sender, EventArgs e) {
printDocument1.Print();
}

private void printDocument1_PrintPage(object sender,
System.Drawing.Printing.PrintPageEventArgs e) {
e.PageSettings.Landscape = true;

e.Graphics.DrawString(textBox1.Text, new Font("Arial", 12,
FontStyle.Bold), Brushes.Black, 20, 20);
}
I am trying this with three different printers here in the office and it
still prints portrait. What am i doing wrong?
Dragos.
Mar 28 '07 #1
2 7771
Instead of setting the PageSetting in the PrintPage event, have you
tried setting the Landscape property to true on the PageSettings instance
returned by the call to the DefaultPageSetting property on the PrintDocument
class?

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"FireStarter" <d@d.comwrote in message
news:eJ**************@TK2MSFTNGP02.phx.gbl...
>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:

private void button1_Click(object sender, EventArgs e) {
printDocument1.Print();
}

private void printDocument1_PrintPage(object sender,
System.Drawing.Printing.PrintPageEventArgs e) {
e.PageSettings.Landscape = true;

e.Graphics.DrawString(textBox1.Text, new Font("Arial", 12,
FontStyle.Bold), Brushes.Black, 20, 20);
}
I am trying this with three different printers here in the office and it
still prints portrait. What am i doing wrong?
Dragos.

Mar 28 '07 #2
Nicholas Paldino [.NET/C# MVP] wrote:
Instead of setting the PageSetting in the PrintPage event, have you
tried setting the Landscape property to true on the PageSettings instance
returned by the call to the DefaultPageSetting property on the PrintDocument
class?

Hope this helps.

Thank you. It worked perfectly.
Dragos
Mar 28 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Darcy Kahle | last post: by
4 posts views Thread by Jody Gelowitz | last post: by
3 posts views Thread by MarcJ | last post: by
2 posts views Thread by viki | last post: by
4 posts views Thread by Eric | last post: by
3 posts views Thread by D Witherspoon | last post: by
2 posts views Thread by jc_va | last post: by
reply views Thread by atagore | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.