ChainsawJoe
Programmer
Hi all!
I have this function which prints txt files just peachily
but just try and give it a pdf and you'll find Acrobat reader hiding in your running processes, not doing a whole lot.
I've tried loads of different versions of this, down to the basics:
I can get the commandline version to work:
but it still sits around in my running processes - I guess if I could get that to work in .net, then i could probably kill the process as well... hmm..
Can anyone help? Here's what I actually want to do:
within one page I'm using dynamicpdf to create a label with a couple of barcodes on it via a web app, and need to send several labels to a label printer sitting next to each user of the app.
So presumably the commandline version might not work unless I manage to specify a network printer on a "per user" basis to define where to print to?
I've scoured google and the previous posts here and can't seem to get any of the suggestions to work - can anyone point me towards anything that might help? Even third party solutions would be appreciated - time is, as always, of the essence!
Many thanks!
I have this function which prints txt files just peachily
Code:
Sub PrintAdobePDF(ByVal Filename As String)
Dim myProcess As New Process
Dim i As Integer = 1
Dim lbRunning As Boolean = True
Try
myProcess.StartInfo.FileName = Filename
myProcess.StartInfo.WorkingDirectory = New FileInfo(Filename).DirectoryName
myProcess.StartInfo.CreateNoWindow = True
myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden
myProcess.StartInfo.Verb = "print"
myProcess.Start()
If Not myProcess.HasExited Then
myProcess.WaitForInputIdle(10000)
While lbRunning And i <= 20
System.Threading.Thread.Sleep(500)
Select Case myProcess.HasExited
Case True
lbRunning = False
Case False
lbRunning = Not myProcess.CloseMainWindow
End Select
i += 1
End While
End If
If lbRunning AndAlso Not myProcess.HasExited Then myProcess.Kill()
myProcess.Dispose()
Catch ex As System.ComponentModel.Win32Exception
Const ERROR_FILE_NOT_FOUND As Integer = 2
Select Case ex.NativeErrorCode
Case ERROR_FILE_NOT_FOUND : Throw New System.IO.FileNotFoundException
Case Else : Throw New Exception(ex.Message & " (PrintAdobePDF)")
End Select
Catch ex As Exception
Throw New Exception(ex.Message & " (PrintAdobeFile)")
End Try
I've tried loads of different versions of this, down to the basics:
Code:
Dim starter As Process = New Process
Dim acroPath As String = "C:\Program Files\Adobe\Acrobat 7.0\Reader\AcroRd32.exe"
starter.Start(acroPath, "/p/h """ & Server.MapPath("testprint.pdf") & """")
I can get the commandline version to work:
Code:
"C:\Program Files\Adobe\Acrobat 7.0\Reader\AcroRd32.exe" /p/h "c:\testprint.pdf"
Can anyone help? Here's what I actually want to do:
within one page I'm using dynamicpdf to create a label with a couple of barcodes on it via a web app, and need to send several labels to a label printer sitting next to each user of the app.
So presumably the commandline version might not work unless I manage to specify a network printer on a "per user" basis to define where to print to?
I've scoured google and the previous posts here and can't seem to get any of the suggestions to work - can anyone point me towards anything that might help? Even third party solutions would be appreciated - time is, as always, of the essence!
Many thanks!