C#打印两页

时间:2017-01-31 07:06:39

标签: c# printing

你好我想要打印两个不同的页面。

所以我试试这个

int a = 50;
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
    SolidBrush sbrush = new SolidBrush(Color.Black);
    Pen myPen = new Pen(Color.Black);

    e.Graphics.DrawImage(Properties.Resources.picture1, 30, 20, 150, 50);
    e.Graphics.DrawString("OPERATION NAME", myFont_baslik, sbrush, 80, 100);
    e.Graphics.DrawLine(myPen, 50, 130, 770, 130);
    e.Graphics.DrawString("1/2", myFont_yazi, sbrush, 750, 30);

    if (a >= 50)
    {
        e.HasMorePages = true;
        a = 40;
        return;
    }
    else
    {
        e.HasMorePages = false;
    }


    e.Graphics.Clear(Color.White);
    e.Graphics.DrawString("RESULT", myFont_altbaslik, sbrush, 50, 50);

    e.Graphics.DrawString("No. \t Radius \t Diameter", myFont_altbaslik, sbrush, 50, 80);
    e.Graphics.DrawString("No. \t Radius \t Diameter", myFont_altbaslik, sbrush, 450, 80);

    for (int i = 0; i < listBox1.Items.Count; i++)
    {
        if (i < 56)
            e.Graphics.DrawString(listBox1.Items[i].ToString(), myFont_yazi, sbrush, 50, 100 + i * 18);
        else
        {
            e.Graphics.DrawString(listBox1.Items[i].ToString(), myFont_yazi, sbrush, 450, 100 + (i - 56) * 18);
        }
    }

    e.Graphics.DrawString("2/2", myFont_yazi, sbrush, 750, 30);
}

我在printdialog中看到两个页面。没关系。但物理打印机只打印最后一页。我想打印两页。我该如何解决这个问题?

enter image description here

enter image description here

0 个答案:

没有答案