C# 打印时,自定义纸张

打印时,自定义纸张
 
using System.Drawing.Printing;
 
在Window 98下使用
PrintDocument Document = new PrintDocument();
Document.DefaultPageSettings.PaperSize = new PaperSize("A5", 827, 583);
 
在Win2000,XP以上的版本中使用
PaperSize ps = new PaperSize("自定", 627, 583);
foreach (PaperSize ps2 in Document.PrinterSettings.PaperSizes)
{
    if (ps2.PaperName == "A5")
    {
        printDocument1.DefaultPageSettings.PaperSize = ps2;//打印A5尺寸
    }
    //如果是自定尺寸,则用下面的语句
    if (ps2.PaperName == "自定")
    {
        printDocument1.DefaultPageSettings.PaperSize = ps;
    }
}
posted @ 2012-06-27 21:49  小软狐  阅读(1082)  评论(0编辑  收藏  举报