0
我有一個窗體窗體,其中包含圖像&該圖像上的一些文本框。我需要在將這些文本框與該圖像一起填充後打印內容。我使用下面的代碼,但它只打印圖像,而不是文本框中的值。我有一個窗體,其中包含圖像和該圖像上的一些文本框
PrintDocument printDocument = new PrintDocument();
printDocument.PrintPage += PrintDocumentOnPrintPage;
printDocument.PrinterSettings.DefaultPageSettings.PaperSize = new System.Drawing.Printing.PaperSize("a2", this.Width, this.Height);
PrintDialog pdg = new PrintDialog();
pdg.Document = printDocument;
// if (pdg.ShowDialog() == DialogResult.OK)
//{
printDocument.Print();
//}
private void PrintDocumentOnPrintPage(object sender, PrintPageEventArgs e)
{
Graphics myGraphics = panel1.CreateGraphics();
Size s = this.Size;
Bitmap memoryImage = new Bitmap(panel1.Width , panel1.Height, myGraphics);
Graphics memoryGraphics = Graphics.FromImage(memoryImage);
Point screenLoc =PointToScreen(panel1.Location); // Get the location of the Panel in Screen Coordinates
memoryGraphics.CopyFromScreen(screenLoc.X, screenLoc.Y, 0, 0, s);
e.Graphics.DrawImage(memoryImage, 0, 0);
}
但我仍然無法管理打印尺寸