System.Drawing.Printing.PrintDocument doc = new System.Drawing.Printing.PrintDocument(); //PrintDocument对象
strDefaultPrinter = doc.PrinterSettings.PrinterName;//获取默认的打印机名
strDefaultPaperName = doc.DefaultPageSettings.PaperSize.PaperName;//获取默认打印规格
doc.PrinterSettings.PrinterName = "打印机名";//设置要调用的打印机
int rawKind = 1;//尺寸号码
for (int i = 0; i <= doc.PrinterSettings.PaperSizes.Count - 1; i++)//循环当前所指定的打印机支持的打印尺寸规格
{if (doc.PrinterSettings.PaperSizes[i].PaperName == "A4")
{
rawKind = doc.PrinterSettings.PaperSizes[i].RawKind;//从循环中获取自己想要的尺寸号码
break;
}
}
ReportTest r = new ReportTest()//创建要打印的水晶报表对象
r.PrintOptions.PrinterName = "打印机名"; //水晶报表指定打印机名称
r.PrintOptions.PaperSize = (CrystalDecisions.Shared.PaperSize)rawKind;//水晶报表通过尺寸号码指定打印尺寸
r.PrintToPrinter(1, false, 0, 0);//打印报表