468,242 Members | 1,728 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

Printing and setting Page Sizes

Hey folks,

I'm trying to print from a c# windows application using
System.Drawing.Printing. My problem is that it doesn't matter what I put in
for papersize, it always ignores what I tell it and always prints out the
same thing. Landscape works though. Does anyone see any problems with this
code?

printDoc.PrinterSettings.PrinterName = configSettings.labelPrinterName;
printDoc.DefaultPageSettings.Landscape = true;
printDoc.DefaultPageSettings.PaperSize.Width = 350;
printDoc.DefaultPageSettings.PaperSize.Height = 700;
printDoc.PrintPage += new PrintPageEventHandler(printDoc_PrintPage);
printDoc.Print();
:
:
private void printDoc_PrintPage(Object sender, PrintPageEventArgs e)
{
e.PageSettings.PaperSize.Width = 350;
e.PageSettings.PaperSize.Height = 700;
e.PageSettings.Landscape = true;

Font printFont = new Font("Arial", 10, System.Drawing.FontStyle.Bold);
e.Graphics.DrawString(strTextToPrint, printFont, Brushes.Black, 0, 0);
}
Nov 16 '05 #1
2 13218
Hi John,

I replied to your post in the drawing group. Did you try to change
Margins instead of PaperSize?

--
Happy Coding!
Morten Wennevik [C# MVP]
Nov 16 '05 #2
Hi Morten,

I can't see my post in the drawing group for some reason, so I didn't see
your other response. Sorry.

As far as the margins go, I did try adding them to the code I posted and set
them all to 0 but it produced the same results.

I'm printing to a special label printer, and right now the text outputted is
way too far over to the right. If you print from notepad it prints
correctly if you set the papersize width to 3.5" and height to 7.0" and
print Landscape. My landscape works, but it doesn't matter what I put for
papersize, it always prints out the same.

Thx for the help!
"Morten Wennevik" <Mo************@hotmail.com> wrote in message
news:opsicjkeqyklbvpo@pbn_computer...
Hi John,

I replied to your post in the drawing group. Did you try to change
Margins instead of PaperSize?

--
Happy Coding!
Morten Wennevik [C# MVP]

Nov 16 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Jody Gelowitz | last post: by
3 posts views Thread by Tapi | last post: by
1 post views Thread by John | last post: by
2 posts views Thread by rlntemp-gng | last post: by
reply views Thread by kermitthefrogpy | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.