有谁知道一些C#中有关printDocument的知识。

来源:百度知道 编辑:UC知道 时间:2024/06/30 01:43:16

MSDN源码
  using System;
  using System.IO;
  using System.Drawing;
  using System.Drawing.Printing;
  using System.Windows.Forms;

  public class PrintingExample : System.Windows.Forms.Form
  {
  private System.ComponentModel.Container components;
  private System.Windows.Forms.Button printButton;
  private Font printFont;
  private StreamReader streamToPrint;

  public PrintingExample() : base()
  {
  // The Windows Forms Designer requires the following call.
  InitializeComponent();
  }

  // The Click event is raised when the user clicks the Print button.
  private void printButton_Click(object sender, EventArgs e)
  {
  try
  {
  streamToPrint = new StreamReader
  ("C:\\My Documents\\MyFile.txt");
  try
  {
  printFont = new Font("Arial", 10);
  PrintDocument pd = new PrintDocument();
  pd.Pr