简体   繁体   中英

PDF Silent printing from WCF service

I want to print PDF or Image from WCF service.

I use acrobat for printing pdf throw process it is working with console application but not with windows or IIS hosted WCF service. I use following code for printing.

Process proc = new Process();
        string file = @"E:\FormValidation.pdf";
        string printerName = @"\\claysys036\Canon LBP2900";
        proc.StartInfo.FileName = @"C:\Program Files (x86)\Adobe\Reader 11.0\Reader\AcroRd32.exe";
        proc.StartInfo.Arguments = @" /t /h " + "\"" + file + "\"" + " " + "\"" + printerName + "\"";
        proc.StartInfo.UseShellExecute = true;
        proc.StartInfo.CreateNoWindow = true;
        proc.Start();
        proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
        if (proc.HasExited == false)
        {
            proc.WaitForExit(10000);
        }
        proc.EnableRaisingEvents = true;
        proc.Kill();

Your issue is probably related to the user that your services use. If it's the case, you can solve by granting the proper rights to this user or using a delegate user into your code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM