424,066 Members | 2,123 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,066 IT Pros & Developers. It's quick & easy.

Print PDF file in vb.net By giving printer name

P: n/a
To Print file on your selected printer instead of default printer you
can write the following code
also you can find the complete solution in
http://ripalsoni.wordpress.com/2007/...-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()

the above code will print your pdf file on the printer you want ,you
can also print word document by the same way just change your
executable file path from Acrobat32.exe to word exe

Thanks

Ripal Soni

Apr 30 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
You've started a new thread in this group, so we don't know what previous
code you've tried or what kind of applicaiton you are working with.
<Laurie Scottwrote in message
news:20*****************@tri-cityenergy.com...
Hello,
I tried using your code but kept getting an error on the last line. So, I
put the process.start()on the next line.
that fixed the compiler error, but I keep getting the message "error
opening this document. file cannot be found." This is weird because I
have other code that executes to return the length of this very file.

Any hints?

I have spent several days trying to do something that should only take a
few minutes....

Jun 27 '08 #2

P: n/a
"Laurie Scott" schrieb:
I tried using your code but kept getting an error on the last line. So, I
put the process.start()on the next line.
that fixed the compiler error, but I keep getting the message "error
opening this document. file cannot be found."
Take a look at this code sample:

Printing files of various types without user interaction
<URL:http://dotnet.mvps.org/dotnet/faqs/?id=printinganyfile&lang=en>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Jun 27 '08 #3

P: n/a
Herfried;

This works for simple format documents.
I tried to use PrintDialog to allow more options as follow but nothing
printed when user clicked on "PRINT"

Printdialog1.PrinterSettings.PrintFileName = "C:\Test.PDF"
PrintDialog1.ShowDialog()

What did I do wrong?

Thanks

Bill
"Herfried K. Wagner [MVP]" <hi***************@gmx.atwrote in message
news:%2***************@TK2MSFTNGP04.phx.gbl...
"Laurie Scott" schrieb:
>I tried using your code but kept getting an error on the last line. So, I
put the process.start()on the next line.
that fixed the compiler error, but I keep getting the message "error
opening this document. file cannot be found."

Take a look at this code sample:

Printing files of various types without user interaction
<URL:http://dotnet.mvps.org/dotnet/faqs/?id=printinganyfile&lang=en>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Jul 2 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.