print pdf from web service

G

Guest

I'm trying to use system.diagnostics.process to print a pdf from ASP.NET 2.0
webservice (using a network printer). It works fine in an executable, but
fails in asp.net. What happens is that the executable runs & Acrobat gets
launched with no exceptions thrown, but the process is running under the
ASPNET account & the printing never takes place. I found out that the ASPNET
account, by design, is prohibited from doing certain things, so I

(a) set impersonation to a user account with network admin rights
(b) set the process.startinfo.username, password, & domain properties to the
same user account
(c) set "processmodel username" to "system" and "password" to "Autogenerate"

I get the same result each time. acrobat launches under ASPNET and the
printing never happens. I even moved the code to a console app and invoked
that in the web service; again, no dice. Any ideas??

Here is the console app code:

Sub Main()
Dim myprocess As System.Diagnostics.Process = New
System.Diagnostics.Process
Try
myprocess.StartInfo.FileName = "C:\AssurantLetter.pdf"
myprocess.StartInfo.Verb = "Print"
myprocess.StartInfo.CreateNoWindow = True
myprocess.Start()
System.Console.WriteLine("success")
Catch ex As Exception
System.Console.WriteLine(ex.ToString)
End Try
End Sub

here is the web service code:

Public Function testprint() As String
Dim myprocess As System.Diagnostics.Process = New
System.Diagnostics.Process
Dim objPassword As New System.Security.SecureString
Try
objPassword.AppendChar("p")
objPassword.AppendChar("a")
objPassword.AppendChar("s")
objPassword.AppendChar("s")
objPassword.AppendChar("w")
objPassword.AppendChar("o")
objPassword.AppendChar("r")
objPassword.AppendChar("d")
myprocess.StartInfo.UseShellExecute = False
myprocess.StartInfo.Domain = "DOMAINNAME"
myprocess.StartInfo.UserName = "username"
myprocess.StartInfo.Password = objPassword
myprocess.StartInfo.CreateNoWindow = True

myprocess.Start("C:\Inetpub\wwwroot\PrintManager\HelperComponents\ConsoleApplication1.exe")
Return "success"
Catch ex As Exception
Return ex.ToString
End Try
End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top