zoukankan      html  css  js  c++  java
  • 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;
    
  • 相关阅读:
    堆排序
    jdk8 永久代变更
    oracle 区分大小写遇到的坑
    日志统计分析
    zookeeper 服务挂掉重启后,dubbo 服务是不会自动重新注册上的
    代码质量管理
    快速排序算法
    python flask 项目结构
    项目架构
    JS中的循环---最全的循环总结
  • 原文地址:https://www.cnblogs.com/gaara-zhang/p/9663277.html
Copyright © 2011-2022 走看看