C# 打印自定义纸张设置

本文介绍了如何在C#中使用PrintDocument类来打印自定义纸张大小,特别适用于票据打印。通过示例代码展示了在.NET2.0下无需用户界面设置即可完成自定义纸张设置的方法。
摘要由CSDN通过智能技术生成

.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();
            iSPriner.PrintPage += new PrintPageEventHandler
                (this.OnPrintPage);

        }

        public void Dispose()
        {
            if (iSPriner != null) iSPriner.Dispose();
            iSP
  • 2
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值