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

UsingImpersonation() public static method

public static UsingImpersonation ( ) : void
return void
        public static void UsingImpersonation()
        {
            // ExStart:UsingImpersonation
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Printing();
            PdfViewer viewer = new PdfViewer();
            viewer.BindPdf( dataDir + "input.pdf");
            viewer.PrintPageDialog = false;
            // Do not produce the page number dialog when printing
            using (new Impersonator("OwnerUserName", "SomeDomain", "OwnerUserNamePassword"))
            {
                System.Drawing.Printing.PrinterSettings ps = new System.Drawing.Printing.PrinterSettings();
                ps.PrinterName = "Microsoft XPS Document Writer";
                viewer.PrintDocumentWithSettings(ps); // OwnerUserName is a value of Owner column in spooler app
                viewer.Close();
            }
            // ExEnd:UsingImpersonation
        }
    }