By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,466 Members | 1,309 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,466 IT Pros & Developers. It's quick & easy.

How can I change page size for printing?

P: n/a
Hi my friends,

I'm writing a small program to print a form. The form is on customer sized
paper. I trying to use following code to change paper size, but it dosn't
work. Why??
There's always an error message: 'you can only change papersize when its
kind is Costom'. I did set Papersize.Kind to Custom. Thanks ahead for your
help.

Larry

PrintDocument prndoc=new PrintDocument();

prndoc.DocumentName="F4 Print";

prndoc.DefaultPageSettings.Landscape=true;
foreach(PaperSource psrc in
prndoc.DefaultPageSettings.PrinterSettings.PaperSo urces)

{

if(psrc.Kind==PaperSourceKind.Manual)

{

prndoc.DefaultPageSettings.PaperSource =psrc;

break;

}

}


foreach(PaperSize psize in prndoc.PrinterSettings.PaperSizes)

{

if(psize.Kind==PaperKind.Custom)

{

prndoc.DefaultPageSettings.PaperSize=psize;

break;

}

}

prndoc.DefaultPageSettings.PaperSize.Width=272;//69mm

prndoc.DefaultPageSettings.PaperSize.Height=622;//158mm
Nov 16 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.