• 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 = @"indocument.ps";
                                    PrintReport.PrintController = new StandardPrintController();
                                    PrintReport.Print();
                                    Process p_adobe = Process.Start(Application.StartupPath + @"/Acrobat/acrodist.exe");
                                    p_adobe.WaitForExit();
                                    Focus();
                                    UpFile(@"outdocument.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;
    
  • 相关阅读:
    day14_集合框架1(ArrayList,LinkedList,HashSet)
    day13_String、StringBuffer、StringBuilder
    初识Java_day01
    关于局部内部类访问带有final修饰符的局部变量
    day03,day04_数组,循环(上)
    day09(下)_异常(上)
    day08_多态
    day11_多线程(多线程安全问题)
    day16_集合框架3(HashMap,TreeMap)
    day09(上)_内部类
  • 原文地址:https://www.cnblogs.com/gaara-zhang/p/9663277.html
Copyright © 2020-2023  润新知