我想打印整个表格的尺寸(1415x1000)。但它正在打印尺寸(1185x740)的形式。
我参考了msdn网站上的代码:
[System.Runtime.InteropServices.DllImport("gdi32.dll")]
public static extern long BitBlt(IntPtr hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, IntPtr hdcSrc, int nXSrc, int nYSrc, int dwRop);
private Bitmap memoryImage;
private void CaptureScreen()
{
Graphics mygraphics = this.CreateGraphics();
Size s = this.Size;
memoryImage = new Bitmap(s.Width, s.Height, mygraphics);
Graphics memoryGraphics = Graphics.FromImage(memoryImage);
IntPtr dc1 = mygraphics.GetHdc();
IntPtr dc2 = memoryGraphics.GetHdc();
BitBlt(dc2, 0, 0, this.ClientRectangle.Width, this.ClientRectangle.Height, dc1, 0, 0, 13369377);//13369376);
mygraphics.ReleaseHdc(dc1);
memoryGraphics.ReleaseHdc(dc2);
}
private void printDocument1_PrintPage(object sender, PrintPageEventArgs e)
{
e.Graphics.DrawImage(memoryImage, 0, 0);
}
private void button1_Click_1(object sender, EventArgs e)
{
panel1.Hide();
CaptureScreen();
PrintDocument myDoc = new PrintDocument();
myDoc.PrinterSettings.DefaultPageSettings.PaperSize = new System.Drawing.Printing.PaperSize("Custom", 1415, 1000);
PrintPreviewDialog print_dlg = new PrintPreviewDialog();
print_dlg.Document = printDocument1;
print_dlg.ShowDialog();
}
但我无法在打印输出中获得完整的表格。我怎么做?