如何在图片框 C# Vis Studios 上打印文本框和带有文本框的图片

问题描述 投票:0回答:0

我正在尝试通过单击按钮打印出这张票。我可以打印出票证图像,但即使填写了文本,它也只打印背面图像,不包括文本框。我还希望文本框的位置与 picturebox1 的大小保持相关,这样打印时就不会弄乱对齐方式。

如果我能得到帮助,例如让 tbtoname.Text 与 picturebox1 一起打印,并且打印的位置也很好。那将是惊人的,我可以接受它并从那里开始。

这是我打印输出的screenshot和附加的代码。

 private void button1_Click(object sender, EventArgs e)
        {
            Startup_Screen f2 = new Startup_Screen();
            f2.Show();
            Visible = false;

            PrintDialog pd = new PrintDialog();
            PrintDocument doc = new PrintDocument();
            doc.PrintPage += myPrintPage;
            pd.Document = doc;
            if (pd.ShowDialog() == DialogResult.OK)
            {
                doc.Print();
            }
        }
       

        private void myPrintPage(object sender, PrintPageEventArgs e)
        {
            Bitmap bm = new Bitmap(pictureBox1.Width, pictureBox1.Height);
            pictureBox1.DrawToBitmap(bm, new Rectangle(0, 0, pictureBox1.Width, pictureBox1.Height));
            
      



            e.Graphics.DrawImage(bm, 0, 0);
            bm.Dispose();
        }


我试过打印图片框,打印时不包括文本框。

c# printing bitmap picturebox
© www.soinside.com 2019 - 2024. All rights reserved.