c# 打印
两种方法:adobe PDF或gs,统一之处都是先把控件画在printDocument(控件)上,保存为gs文件,然后转成PDF打印
case "Adobe PDF": #region Adobe PrintReport.PrinterSettings.PrinterName = DBConnection.printer;//PrintReport即printDocument控件 PrintReport.DefaultPageSettings.PaperSize = new PaperSize("Custom", 745, 1050); PrintReport.DefaultPageSettings.Margins.Right = 70; PrintReport.DefaultPageSettings.Margins.Top = 90; PrintReport.PrinterSettings.PrintToFile = true; PrintReport.PrinterSettings.PrintFileName = @"in\document.ps"; PrintReport.PrintController = new StandardPrintController(); PrintReport.Print(); Process p_adobe = Process.Start(Application.StartupPath + @"/Acrobat/acrodist.exe"); p_adobe.WaitForExit(); Focus(); UpFile(@"out\document.pdf", SeriesID.Replace('*', 'x') + ".pdf");//利用ftp上传,可以忽略 #endregion break; default: #region gs PrintReport.PrinterSettings.PrinterName = DBConnection.printer; PrintReport.DefaultPageSettings.PaperSize = new PaperSize("Custom", 745, 1050); PrintReport.DefaultPageSettings.Margins.Right = 70; PrintReport.DefaultPageSettings.Margins.Top = 90; PrintReport.PrinterSettings.PrintToFile = true; PrintReport.PrinterSettings.PrintFileName = @"gs/document.ps"; PrintReport.PrintController = new StandardPrintController(); PrintReport.Print(); Environment.CurrentDirectory = Application.StartupPath + "/gs"; Process pros = Process.Start("ps2pdf.bat", "document.ps"); pros.WaitForExit(); Environment.CurrentDirectory = Application.StartupPath; Focus(); UpFile(@"gs/document.pdf", SeriesID.Replace('*', 'x') + ".pdf"); #endregion break;