A
Amrendra Nath
Hi Friends !
Can anyone help? Its an urgent.
I wanted to print PDF Document or Scanned Document Through
my .aspx page .By just clicking a button.I'm not using
codebehind.I want to do printing at my network printer.
I'm using System.Diagnosics.Process Namespace for calling
the print process at the server where i want to do my
printing.I'm only able to run Command.exe and notepad
process. Please help.
My code :
Public Sub PrintDoc(sender as Object, ev As EventArgs)
dim ERROR_FILE_NOT_FOUND As Integer = 2
dim ERROR_ACCESS_DENIED As Integer = 5
Dim myProcess As New Process()
Try
myProcess.StartInfo.FileName =
FileName response.Write
(myProcess.StartInfo.FileName)
myProcess.StartInfo.Verb = "Print"
myProcess.StartInfo.UseShellExecute=true
myProcess.StartInfo.CreateNoWindow = True
myProcess.Start()
Catch e As Win32Exception
response.Write("error")
If e.NativeErrorCode = ERROR_FILE_NOT_FOUND
Then
Response.Write(((e.Message + ". Check the
path.")))
Else
If e.NativeErrorCode = ERROR_ACCESS_DENIED
Then
' Note that if your word processor might
generate exceptions
' such as this, which are handled first.
Response.Write(((e.Message + ". You do
not have permission to print this file.")))
End If
End If
End Try
myProcess.WaitForExit()
if Not myProcess.HasExited Then
myProcess.Kill()
End If
myProcess.Close()
End Sub
Can anyone help? Its an urgent.
I wanted to print PDF Document or Scanned Document Through
my .aspx page .By just clicking a button.I'm not using
codebehind.I want to do printing at my network printer.
I'm using System.Diagnosics.Process Namespace for calling
the print process at the server where i want to do my
printing.I'm only able to run Command.exe and notepad
process. Please help.
My code :
Public Sub PrintDoc(sender as Object, ev As EventArgs)
dim ERROR_FILE_NOT_FOUND As Integer = 2
dim ERROR_ACCESS_DENIED As Integer = 5
Dim myProcess As New Process()
Try
myProcess.StartInfo.FileName =
FileName response.Write
(myProcess.StartInfo.FileName)
myProcess.StartInfo.Verb = "Print"
myProcess.StartInfo.UseShellExecute=true
myProcess.StartInfo.CreateNoWindow = True
myProcess.Start()
Catch e As Win32Exception
response.Write("error")
If e.NativeErrorCode = ERROR_FILE_NOT_FOUND
Then
Response.Write(((e.Message + ". Check the
path.")))
Else
If e.NativeErrorCode = ERROR_ACCESS_DENIED
Then
' Note that if your word processor might
generate exceptions
' such as this, which are handled first.
Response.Write(((e.Message + ". You do
not have permission to print this file.")))
End If
End If
End Try
myProcess.WaitForExit()
if Not myProcess.HasExited Then
myProcess.Kill()
End If
myProcess.Close()
End Sub