Facebook Twitter Gplus LinkedIn YouTube Google Maps RSS
Home Technical Print..
formats

Print..

Print to Default printer without showing Print Dlg.

Dim Psi As New ProcessStartInfo
Psi.UseShellExecute = True
Psi.Verb = “print”
Psi.WindowStyle = ProcessWindowStyle.Hidden
Psi.FileName = “C:\SimTemp\Test.txt”
Process.Start(Psi)

Print PDF file in VB.Net by giving Printer Name

Here is the solution of printing PDF file by giving printer name

Dim pathToExecutable As String = “AcroRd32.exe”

Dim sReport = “C:Test.PDF” ‘Complete name/path of PDF file

Dim SPrinter = “HP Officejet 5600 seriese” ‘Name Of printer

Dim starter As New ProcessStartInfo(pathToExecutable, “/t “ + sReport + ” “ + sPrinter + “”)

Dim Process As New Process()

Process.StartInfo = starter Process.Start()
‘try and close the process with 20 seconds delay
System.Threading.Thread.Sleep(30000)

Process.CloseMainWindow()
Dim iLoop As Int16 = 0
‘check the process has exited or not

If Process.HasExited = False Then

‘if not then loop for 100 time to try and close the process‘with 10 seconds delay
While Not Process.HasExited
System.Threading.Thread.Sleep(10000)
Process.CloseMainWindow()
iLoop = CShort(iLoop + 1)

If iLoop >= 100 Then

Exit While
End If
End While

End If

Process.Close()
Process.Dispose()
Process = Nothing
starter = Nothing

Tested the first part of the code. Works perfectly.

Never tested the other part

 
Tags:
 Share on Facebook Share on Twitter Share on Reddit Share on LinkedIn
No Comments  comments 

Leave a Reply

Your email address will not be published. Required fields are marked *

*

* Copy this password:

* Type or paste password here:

12,873 Spam Comments Blocked so far by Spam Free Wordpress

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

© All rights reserved to Cyberbrutus. 2012
credit

Switch to our mobile site