Ejemplo n.º 1
0
        private static string CheckeAdobeReader(PrinterMethod printerMethod)
        {
            string adobeReaderPath = "";

            if (printerMethod == PrinterMethod.ForceAdobeReader ||
                printerMethod == PrinterMethod.PriorAdobeReader)
            {
                if (String.IsNullOrEmpty(adobeReaderPath))
                {
                    adobeReaderPath = Path.Combine(AdobePrinterHelper.GetAdobePath(), "AcroRd32.exe");
                }
                if (!String.IsNullOrEmpty(adobeReaderPath) && !File.Exists(adobeReaderPath))
                {
                    if (printerMethod == PrinterMethod.ForceAdobeReader)
                    {
                        throw new Exception("客户端未安装Adobe Reader,终止打印!");
                    }
                    else
                    {
                        //Adobe Reader Not Found
                        adobeReaderPath = "";
                    }
                }
            }

            return(adobeReaderPath);
        }
Ejemplo n.º 2
0
        /// <summary>
        ///     静默打印Pdf发票文档 带偏移量
        /// </summary>
        /// <param name="doc">PdfDocument对象 </param>
        /// <param name="top">上边距偏移量</param>
        /// <param name="left">左边距偏移量</param>
        /// <param name="printTaskName">打印机任务队列名称</param>
        /// <param name="printerName">打印机名称 不填表示选择系统默认打印机</param>
        /// <param name="adobePath">Adobe Reader Pdf 可执行程序路径</param>
        /// <param name="paperType">纸张类型</param>
        /// <param name="startAdobePrinter">启动Adobe模式打印</param>
        /// <returns>打印机调用结果</returns>
        public static bool QuietPrinter(PdfDocument doc,
                                        float top              = 0,
                                        float left             = 0,
                                        string printTaskName   = "",
                                        string printerName     = "",
                                        string adobePath       = "",
                                        SourceType paperType   = SourceType.Invoice,
                                        bool startAdobePrinter = false)
        {
            string pdfPath = ResetPageMargin(doc, top, left, paperType, printTaskName);

            if (startAdobePrinter)
            {
                try
                {
                    return(AdobePrinterHelper.AdobeReaderPrint(adobePath, pdfPath, printerName));
                }
                catch (Exception ex)
                {
                    throw new Exception("调用Adobe Reader执行打印任务失败!", ex);
                }
            }

            return(QuietPrinter(LoadPdf(pdfPath), printTaskName, printerName));
        }