0

画像とその画像上のいくつかのテキストボックスを含む Windows フォームがあります。それらのテキストボックスにその画像を入力した後、コンテンツを印刷する必要があります。以下のコードを使用しましたが、テキストボックスの値ではなく、画像のみを印刷します。

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);
}

しかし、私はまだ印刷サイズを管理できません

4

1 に答える 1