净打印机状态的aspose.pdf始终为null

时间:2018-09-03 12:10:56

标签: c# printing aspose.pdf

这是我的代码:

   public string PrintPdfAspose(string printerName)
        {
            // For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
            // The path to the documents directory.
            string dataDir = filePath;

            // Create PdfViewer object
            PdfViewer viewer = new PdfViewer();

            // Open input PDF file
            viewer.BindPdf(dataDir);


            viewer.PrintDocumentWithSettings(pgs, ps);
            // Check the print status
            if (viewer.PrintStatus != null)
            {
                // An exception was thrown
                Exception ex = viewer.PrintStatus as Exception;
                if (ex != null)
                {
                    return ex.ToString();
                }
            }
            else
            {
                // No errors were found. Printing job has completed successfully
                viewer.Close();
                return "printing completed without any issue..";

            }

        }

我总是将PrintStatus设置为null,当打印机由于某种原因不进行打印时,应该会出现某种错误。有帮助吗?

0 个答案:

没有答案