打印份数取决于文本框输入和放置页码C#

时间:2017-04-27 07:20:59

标签: c#

请帮助我是C#的新手,我有一个带有textbox1,textbox2和buttom1的windows窗体我想打印textbox1的值而不预览或让我直接告诉打印机没有任何交互,textbox值必须是我想要打印的字幕的数量,也是页码所有那些副本说如果我输入3它应该说第1/3页2/3 3/3请帮助和原谅我的英语 我的按钮

下面有以下代码
private void button1_Click(object sender, EventArgs e)
    {


        PrintDocument printDocument = new PrintDocument();
        printDocument.DefaultPageSettings.Landscape = true;
        printDocument.DefaultPageSettings.PaperSize = new PaperSize("zed", 400, 850 );
        //printDocument.PrinterSettings.Copies = 2;
        printDocument.PrintPage += PrintDocumentOnPrintPage;
        printDocument.Print();

1 个答案:

答案 0 :(得分:0)

我确实解决了.copies问题,但stil无法解决页面编号,这里是我现在的代码

 private void button1_Click(object sender, EventArgs e)
    {
        short numCopies = 0;
        numCopies = Convert.ToInt16(textBox2.Text);


        PrintDocument printDocument = new PrintDocument();
        printDocument.DefaultPageSettings.Landscape = true;
        printDocument.DefaultPageSettings.PaperSize = new PaperSize("zed", 400, 850 );
        printDocument.PrinterSettings.Copies = numCopies;
        printDocument.PrintPage += PrintDocumentOnPrintPage;
        printDocument.Print();

    }