lmttag
4/22/2008 12:47:00 AM
Hello,
We are having a lot of problems trying to print a PDF file in the background
using a C# application that is executed via SQL Server Agent. The output
should be printed to a local printer (HP Color LaserJet 1600) connected via a
USB port.
We have a C# application that calls System.Diagnostics.Process to run
Acrobat Reader (weâ??ve tried both v8.0.0 and v8.1.2), open an existing PDF
file, and send it to the local printer. The code is shown below.
System.Diagnostics.Process process = new System.Diagnostics.Process();
process.Refresh();
process.StartInfo.Arguments = "/t C:\Temp\TestPDF.pdf"; // and tried "/t
C:\Temp\TestPDF.pdf PrinterName"
process.StartInfo.CreateNoWindow = false;
//process.StartInfo.Domain;
//process.StartInfo.ErrorDialog = false;
process.StartInfo.FileName = "C:\\Program Files\\Adobe\\Reader
8.0\\Reader\\AcroRd32.exe";
//process.StartInfo.Password;
//process.StartInfo.UserName;
process.StartInfo.UseShellExecute = false;
//process.StartInfo.Verb = "Print";
process.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
process.StartInfo.WorkingDirectory = new
System.IO.FileInfo(m_PDFPathFile).DirectoryName;
process.Start();
Weâ??ve tried just about every combination of the process objects properties
trying to get the PDF file to print. But, it never works. The code executes
without error, just nothing ever shows up on the printer.
More infoâ?¦ Weâ??re executing our custom C# application via a SQL Server Agent
job. SQL Server Agent is running as Local System account. The Job Step Type
is Operating System (CmdExec), with Run as set to SQL Server Agent Account.
The command is simply the path and file name of our custom C# application
(e.g., C:\Temp\PrintPDF.exe).
Again, we get no errors/exception and no job failures, but the PDF never
gets printed.
How can we re-code or fix our situation?
What can be done/tried?
All help is appreciated. We are stuck.
Thanks.