PDA

View Full Version : پرینت فرم



mahan351
چهارشنبه 09 بهمن 1392, 00:07 صبح
سلام...
من امروز از یه دستور 2خطی واسه پرینت استفاده کردم و سایز فرم هم برابر سایز A5 بود ولی وقتی پرینت گرفتم کاملا زوم شده بود وسط فرم
چیکار کنم که فرم رو همونطور و اندازه ای که هست تو A5 پرینت بگیره؟

angoori
چهارشنبه 09 بهمن 1392, 06:27 صبح
menuStrip1.Hide();
try
{
PrintDocument document = new PrintDocument();

bitmap = new Bitmap(ClientRectangle.Width, ClientRectangle.Height, PixelFormat.Format32bppArgb);

using (Graphics graphics = Graphics.FromImage(bitmap))
{

Point point = Location;

graphics.CopyFromScreen(point.X + (Width - ClientRectangle.Width) / 2, point.Y + (Height - ClientRectangle.Height -3), 0, 0, new Size(Width, Height), CopyPixelOperation.SourceCopy);
document.PrintPage += document_PrintPage;

document.Print();
}
}
catch (Exception ex)
{

MessageBox.Show(ex.Message, "خطا");
return;
}

mahan351
چهارشنبه 09 بهمن 1392, 17:11 عصر
menuStrip1.Hide();
try
{
PrintDocument document = new PrintDocument();

bitmap = new Bitmap(ClientRectangle.Width, ClientRectangle.Height, PixelFormat.Format32bppArgb);

using (Graphics graphics = Graphics.FromImage(bitmap))
{

Point point = Location;

graphics.CopyFromScreen(point.X + (Width - ClientRectangle.Width) / 2, point.Y + (Height - ClientRectangle.Height -3), 0, 0, new Size(Width, Height), CopyPixelOperation.SourceCopy);
document.PrintPage += document_PrintPage;

document.Print();
}
}
catch (Exception ex)
{

MessageBox.Show(ex.Message, "خطا");
return;
}
رو این ها ارور میده:
http://upload.tehran98.com/upme/uploads/4c6c8de43644451c1.jpg

angoori
چهارشنبه 09 بهمن 1392, 20:24 عصر
Bitmap bitmap;


void document_PrintPage(object sender, PrintPageEventArgs e)
{

e.Graphics.DrawImage(bitmap, 0, 0);
}