我想打印整個頁面上我的形式,而是畫面看起來是這樣的:打印表格
http://i.stack.imgur.com/JSXh2.jpg
它看起來非常小,這就是爲什麼我需要要在全整版
這裏印刷的形式是我的代碼:
private void button5_Click(object sender, EventArgs e)
{
CaptureScreen();
printDocument1.Print();
}
private Bitmap _memoryImage;
private void CaptureScreen()
{
// put into using construct because Graphics objects do not
// get automatically disposed when leaving method scope
using (var myGraphics = CreateGraphics())
{
var s = Size;
_memoryImage = new Bitmap(s.Width, s.Height, myGraphics);
using (var memoryGraphics = Graphics.FromImage(_memoryImage))
{
memoryGraphics.CopyFromScreen(Location.X, Location.Y, 0, 0, s);
}
}
}
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
var wScale = e.MarginBounds.Width/(float)_memoryImage.Width;
var hScale = e.MarginBounds.Height/(float)_memoryImage.Height;
// choose the smaller of the two scales
var scale = wScale < hScale ? wScale : hScale;
// apply scaling to the image
e.Graphics.ScaleTransform(scale, scale);
// print to default printer's page
e.Graphics.DrawImage(_memoryImage, 0, 0);
}
你的幫助,將不勝感激
你想以橫向格式打印? – coolerfarmer
你最好保持這種方式。沒有什麼東西可以讓你的表格中的每個像素都被炸成6x6的墨水。結果看起來非常有顆粒感,文字看起來特別差。 –