Aspose.Pdf.Examples.CSharp.AsposePDFFacades.Printing.CheckPrintJobStatus.Run C# (CSharp) Method

Run() public static method

public static Run ( ) : void
return void
        public static void Run()
        {
            try
            {
                // ExStart:CheckPrintJobStatus
                // The path to the documents directory.
                string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Printing();

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

                // Bind source PDF file
                viewer.BindPdf(dataDir + "input.pdf");
                viewer.AutoResize = true;

                // Hide printing dialog
                viewer.PrintPageDialog = false;

                // Create Printer Settings object
                System.Drawing.Printing.PrinterSettings ps = new System.Drawing.Printing.PrinterSettings();
                System.Drawing.Printing.PageSettings pgs = new System.Drawing.Printing.PageSettings();
                System.Drawing.Printing.PrintDocument prtdoc = new System.Drawing.Printing.PrintDocument();

                // Specify the printer anme
                ps.PrinterName = "Microsoft XPS Document Writer";

                // Resultant Printout name
                ps.PrintFileName = "ResultantPrintout.xps";

                // Print the output to file
                ps.PrintToFile = true;
                ps.FromPage = 1;
                ps.ToPage = 2;
                ps.PrintRange = System.Drawing.Printing.PrintRange.SomePages;

                // Specify the page size of printout
                pgs.PaperSize = new System.Drawing.Printing.PaperSize("A4", 827, 1169);
                ps.DefaultPageSettings.PaperSize = pgs.PaperSize;
                pgs.Margins = new System.Drawing.Printing.Margins(0, 0, 0, 0);

                // Print the document with settings specified above
                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)
                    {
                        // Get exception message
                    }
                }
                else
                {
                    // No errors were found. Printing job has completed successfully
                    Console.WriteLine("printing completed without any issue..");
                }
                // ExEnd:CheckPrintJobStatus
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
        public static void GetSetPrintOwnerName()