.Net 提供的打印类PrintDocument 非常简洁易用,不过在实际应用开发中往往需要对纸张进行自定义,尤其是需要进行票据打印时。这个问题也困扰了我许久,经过查阅相关的资料和多次尝试,发现其实也很简单。下面的示例就是我在.Net2.0已经验证可行的办法:
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Drawing.Printing;
namespace PrintService
{
class AFCSPrinter :
{
/*页面打印委托*/
public delegate void DoPrintDelegate(Graphics g, ref bool HasMorePage);
PrintDocument iSPriner = null;
bool m_bUseDefaultPaperSetting = false;
DoPrintDelegate DoPrint = null;
public AFCSPrinter()
{
iSPriner = new PrintDocument();