不好意思,我不是楼主,路过。但是想问jinbingg(bing),你可以说一下用C#自己写打印程序应该多注意哪些方面,
或者提一点点思路呀?

解决方案 »

  1.   

    也是,请教jinbingg(bing)如何用c#自己写打印程序?有无代码或例子?
      

  2.   

    private void menuItemPrint_Click(object sender, System.EventArgs e)
    {
    statusBar1.Text="打印操作";
    PrintDialog printDialog=new PrintDialog(); printDialog.Document=printDocument; if(printDialog.ShowDialog()==DialogResult.OK)
    {
    try
    {
    printDocument.Print();
    }
    catch(Exception ex)
    {
    MessageBox.Show(ex.Message);
    }
    }

      

  3.   

    private void menuItemSet_Click(object sender, System.EventArgs e)
    {
    statusBar1.Text="页面设置";

    PageSetupDialog pageSet=new PageSetupDialog();
    pageSet.Document=printDocument;
    pageSet.AllowOrientation=true;
    pageSet.ShowDialog();

    } private void printDocument_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
    {

    float linesPerPage=0;
    float yPos=0;
    int count=0;
    float leftMargin=e.MarginBounds.Left;
    float topMargin=e.MarginBounds.Top;
    string line=null;
    StreamReader streamToPrint=new StreamReader(currentFileName);
    SolidBrush brush=new SolidBrush(textBox1.ForeColor);
    linesPerPage=e.MarginBounds.Height/textBox1.Font.GetHeight(e.Graphics); while(count<linesPerPage&&((line=streamToPrint.ReadLine())!=null))
    {
    yPos=topMargin+(count*textBox1.Font.GetHeight(e.Graphics));
    e.Graphics.DrawString(line,textBox1.Font,brush,leftMargin,yPos,new StringFormat());
    count++;
    }
    if(line!=null)
    {
    e.HasMorePages=true;
    }
    else
    {
    e.HasMorePages=false;
    }
    }