Printing PDF Or Scanned Document Via ASP.NET at network Printer

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
 
N

Natty Gur

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

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top