|
-
September 8th, 2011, 02:00 AM
#1
couple of questions about priniting in C#
hello all .
i was asked to make a program which takes the forms picture and then prints it. the form can be of any size and also there must be two modes for printing , a batch print option and a single printing option .
printing the form was easy but im stuck at the printing section .
my problems are :
1.i dont know how i can change the size of the card when printing.!
2.i have no idea how i can have a batch printing without user interference!
thank you all in advance
-
September 8th, 2011, 04:27 AM
#2
Re: couple of questions about priniting in C#
any help?
-
September 8th, 2011, 09:29 AM
#3
Re: couple of questions about priniting in C#
ok i have these functions for printing procedures :
Code:
protected void btnPrint_Click(object sender, EventArgs e)
{
PaperSize cardsize = new PaperSize("test", this.Width, this.Height);
PrintDocument pd = new PrintDocument();
pd.PrinterSettings.Duplex = Duplex.Horizontal;
PageSettings psetting = new PageSettings();
psetting.PaperSize = cardsize;
pd.DefaultPageSettings = psetting;
pd.PrintPage += new PrintPageEventHandler(PrintImage);
pd.Print();
}
Code:
void PrintImage(object o, PrintPageEventArgs e)
{
int x = SystemInformation.WorkingArea.X;
int y = SystemInformation.WorkingArea.Y;
int width = this.Width;
int height = this.Height;
Rectangle bounds = new Rectangle(x, y, width, height);
Bitmap img = new Bitmap(width, height);
this.DrawToBitmap(img, bounds);
Point p = new Point(100, 100);
e.Graphics.DrawImage(img, p);
}
i call this print function in a timer tick event , inwhich the forms information is updated each X seconds and when updated , it is printed and so on...
as you see i've tried to first resize the print page to match with the form size , but no luck!
i have no idea how im supposed to do that! searched couple of articles on google on printing! but nothing useful !
and the other problem is that , when printing , a window is shown to the user to choose a name and then save the print file ( i currently have no printer installed , so there is only a microsoft default printer ! - will this window just stop showing when an actual printer is installed ? )
any help ?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|