日期:2011-05-23  浏览次数:20564 次

文章标题是翻译出的中文标题,英文原文标题为:Master Everyday Printing in .NET

文章来自Fawcette Technical Publications(www.ftponline.com)

文章详细地讲述了 System.Drawing.Printing  命名空间中的 20个类 7 个枚举以及 3个委托的用法。

本文将先贴出英文原文,最后再贴出完整源代码,希望对大家有所帮助!

英文原文:

Listing 1 C#

Create and Dispose.

The PrintDocument object exposes several events. BeginPrint is fired before any pages are actually printed, giving you the opportunity to allocate objects or open files. EndPrint occurs after the last page has been printed. Don’t forget to bind the events to your PrintDocument object.

 

// At the class level

private Font bodyFont;

private Font headerFont;

private StreamReader data;

private PrintDocument doc;

private void MainForm_Load(object

   sender, System.EventArgs e) {

   doc = new PrintDocument();

   // shows up in Print Manager

   doc.DocumentName = “Contact List”;

   doc.BeginPrint += new

       PrintEventHandler(doc_BeginPrint);