picturebox打印多页问题 [英] picturebox print multipage problem

查看:87
本文介绍了picturebox打印多页问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





任何人都可以解决这个问题



这里是我的代码



could anybody solve this problem

here is my code

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace notepad_demo
{
    public partial class Form2 : Form
    {
        bool page = true;
       // private StringReader myReader;
        public Form2()
        {
            InitializeComponent();
        }

        private void Form2_Load(object sender, EventArgs e)
        {
            this.pictureBox1.Location = new Point(16, 13);
            this.pictureBox1.Width = 850;
            this.pictureBox1.Height = 5750;
            //this.panel1.Location = new Point(128, 28);
            this.panel1.Width = 850;
            this.panel1.Height = 600;
            //this.panel1.AutoScroll = true;

            
        }

        private void pictureBox1_Paint(object sender, PaintEventArgs e)
        {
            using (Font myFont = new Font("Arial", 14))
            {
                e.Graphics.DrawString("Hello 1", myFont, Brushes.Green, new Point(2, 2));
                e.Graphics.DrawString("Hello 2", myFont, Brushes.Green, new Point(2, 20));
                e.Graphics.DrawString("Hello 3", myFont, Brushes.Green, new Point(2, 120));
                e.Graphics.DrawString("Hello 4", myFont, Brushes.Green, new Point(2, 200));
                e.Graphics.DrawString("Hello 5", myFont, Brushes.Green, new Point(2, 302));
                e.Graphics.DrawString(textBox1.Text, myFont, Brushes.Green, new Point(2, 502));
                
            }
           
        }

        private void button1_Click(object sender, EventArgs e)
        {
            
            printDialog1.Document = printDocument1;
            
            if (printDialog1.ShowDialog() == DialogResult.OK)
            {

                printDocument1.Print();
            }
        }

        private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            if (page)
            {
                float x = 20;
                float y = 100;
                Bitmap bmp = new Bitmap(this.pictureBox1.Width, this.pictureBox1.Height);
                this.pictureBox1.DrawToBitmap(bmp, new Rectangle(0, 0, this.pictureBox1.Width, this.pictureBox1.Height));
                e.Graphics.DrawImage((Image)bmp, x, y);
                e.HasMorePages = true;
                page = false;
            }
           
        }

        private void button2_Click(object sender, EventArgs e)
        {
            printPreviewDialog1.Document = printDocument1;
            printPreviewDialog1.ShowDialog();
        }
    }
}



如果我输入的更多多行文本图片框显示内容确定,但不是按照所示的打印完整picturebox。

它唯一的打印页面适合内容平衡文本不打印。


if i enterd more multi line text picturebox shown content ok,but not print full as per shown in picturebox.
its only print one page fit content balance text not print.

推荐答案

嗯...为什么不编码打印更多超过一页?

您当前的代码:

Well...why not code it to print more than one page?
Your current code:
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
 {
     if (page)
     {
         ...
         e.HasMorePages = true;
         page = false;
     }

 }

将casue teh系统尝试打印第二页,但是当事件被触发时,你不会打印任何东西,因为页面现在是假的。



我认为你需要弄清楚你想要的是什么打印在哪里,再次尝试编写PrintPage处理程序...

will casue teh system to try and print a second page, but when the event is fired for it, you don't print anything because page is now false.

I think you need to work out exactly what you are trying to print where, and try coding the PrintPage handler again...


这篇关于picturebox打印多页问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆