我的richtextbox读入的是xml文件,打印时候行的字数超越过纸张(A4) 
我是第一次用PrintDocument 请问如何设置

解决方案 »

  1.   

    http://www.webmis.com.cn/DownLoad/PrinterPageSetting.rar
      

  2.   

    private void pd_PrintPage(object sender, PrintPageEventArgs ev) 
       {
          float linesPerPage = 0;
          float yPos = 0;
          int count = 0;
          float leftMargin = ev.MarginBounds.Left;
          float topMargin = ev.MarginBounds.Top;
          string line = null;      // Calculate the number of lines per page.
          linesPerPage = ev.MarginBounds.Height / 
             printFont.GetHeight(ev.Graphics);      // Print each line of the file.
          while(count < linesPerPage && 
             ((line=streamToPrint.ReadLine()) != null)) 
          {
             yPos = topMargin + (count * 
                printFont.GetHeight(ev.Graphics));
             ev.Graphics.DrawString(line, printFont, Brushes.Black, 
                leftMargin, yPos, new StringFormat());
             count++;
          }      // If more lines exist, print another page.
          if(line != null)
             ev.HasMorePages = true;
          else
             ev.HasMorePages = false;
       }