B
brogdon
I'm attempting to build an ASP.NET (VB) application that will do
server-side printing of PDF files. I have used a Process object to
launch Adobe's AcroRd32 program with the /t switch which causes it to
open an Acrobat Reader window and silently send the document I want
printed to a local network printer:
Dim psiInfo As ProcessStartInfo = New ProcessStartInfo
(pathtoadobe, "/t " + filename + " " + printername)
psiInfo.CreateNoWindow = True
psiInfo.UseShellExecute = True
Dim procPrint As Process = New Process()
procPrint.StartInfo = psiInfo
procPrint.Start()
This works nicely except for the fact that after it finishes printing,
the Acrobat window stays open on the server. I had thought the /t
switch would cause it to close when it was finished, but I was
apparently wrong. This is unacceptable, because after ten print runs
on the server, I'll end up with ten open acrobat windows!
How can I deal with this problem? It's a simple matter to kill the
process, but how do I know when it's done sending the job to the
printer? If I kill it too early, I could lose pages or corrupt the job
or worse. Is there any way to send something like a WM_COMMAND to the
Adobe window (if I can manage to get a handle to it)? Is there any way
for my to look at the printer's print queue within my ASP.NET code (if
I can do that, I can just check to see if the queue is empty, at which
point I'd know I can kill the process)?
server-side printing of PDF files. I have used a Process object to
launch Adobe's AcroRd32 program with the /t switch which causes it to
open an Acrobat Reader window and silently send the document I want
printed to a local network printer:
Dim psiInfo As ProcessStartInfo = New ProcessStartInfo
(pathtoadobe, "/t " + filename + " " + printername)
psiInfo.CreateNoWindow = True
psiInfo.UseShellExecute = True
Dim procPrint As Process = New Process()
procPrint.StartInfo = psiInfo
procPrint.Start()
This works nicely except for the fact that after it finishes printing,
the Acrobat window stays open on the server. I had thought the /t
switch would cause it to close when it was finished, but I was
apparently wrong. This is unacceptable, because after ten print runs
on the server, I'll end up with ten open acrobat windows!
How can I deal with this problem? It's a simple matter to kill the
process, but how do I know when it's done sending the job to the
printer? If I kill it too early, I could lose pages or corrupt the job
or worse. Is there any way to send something like a WM_COMMAND to the
Adobe window (if I can manage to get a handle to it)? Is there any way
for my to look at the printer's print queue within my ASP.NET code (if
I can do that, I can just check to see if the queue is empty, at which
point I'd know I can kill the process)?