C#使用window API 控制打印纸张大小(转载)

来源:互联网 发布:matlab怎么导入数据 编辑:程序博客网 时间:2024/05/17 21:46

windows一个特点就是设备无关性,这样就给程序控制打印机提供了很好的方法。

首先引用“泥人张”写的打印API类。

using System;
using System.Collections;
using System.Text;
using System.Runtime.InteropServices;
using System.Security;
using System.ComponentModel;
using System.Drawing.Printing;

namespace PrintAPI
...

 然后在程序里调用写好的API即可。

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.IO;

namespace PrintAPI
...

 使用到的Printer.ini配置文件

[Printer]
InvoicePrinter
= pdfFactory Pro
ReceiptPrinter 
= pdfFactory Pro

[BillSize]
InvoiceWidth 
= 706
InvoiceHeight 
= 515

ReceiptWidth 
= 706
ReceiptHeight 
= 515

是不是很简单呢?

原创粉丝点击