111,092
社区成员




string newDpiX = e.Graphics.DpiX.ToString();//获取X值分辨率
string newDpiY = e.Graphics.DpiY.ToString();//获取Y值分辨率
Rectangle destRect = new Rectangle(0, 0, int.Parse(newDpiX), int.Parse(newDpiY)); // 这是要打印的区域
e.Graphics.DrawImage(memoryImage, destRect, 0, 0, memoryImage.Width, memoryImage.Height, System.Drawing.GraphicsUnit.Pixel);
//memoryImage.Width, memoryImage.Height, 这是图片的尺寸
PrintDialog BS = new PrintDialog();
int x = BS.PrinterSettings.DefaultPageSettings.PaperSize.Width;//打印机默认纸张大小
int y = BS.PrinterSettings.DefaultPageSettings.PaperSize.Height;
Image memoryImage = Image.FromFile(Application.StartupPath + @"\Image\back.jpg");//图片路径
Rectangle destRect = new Rectangle(0, 0, x, y);//设置要图片铺满的矩形区域
e.Graphics.DrawImage(memoryImage, destRect, 0, 0, memoryImage.Width, memoryImage.Height, System.Drawing.GraphicsUnit.Pixel);