Printing and setting Page Sizes

J

John Smith

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);
}
 
M

Morten Wennevik

Hi John,

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

John Smith

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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top