473,385 Members | 1,973 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Print PDF file in vb.net By giving printer name

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
3 28440
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
"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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Buzz Bonner | last post by:
Hi, Does anyone know how I can print the user's name in the footer of every page of every print job across a network to a shared PCL supported printer. Regards, Mark
0
by: Buzz Bonner | last post by:
Hi, Does anyone know how I can print the user's name in the footer of every page of every print job across a network to a shared PCL supported printer. Regards, Mark
0
by: ripal.soni | last post by:
Hi there I am .net developer ,right now working on a project in that i need to print pdf file using vb.net and i also have to pass printer name as argument ,file should be printed on a...
3
by: printline | last post by:
Hello Guys I cannot print from a locally installed printer that is mapped to a windows 2003 sever. I have installed the printer locally and can print locally. I connect to the windows 2003...
10
by: bhughes2187 | last post by:
Hey all, The access app I am creating, pulls a .dbf file into a table in access. The name of the printer to be printed to is contained in that file/table. How would I cycle through the list of...
1
by: =?Utf-8?B?SmJhcmJlcg==?= | last post by:
All users in my XP Professional PC were able to print to a network printer until now. Now, the only account that can print to the network printer is the admin account. I have an HP PSC 2200 series...
10
by: mandanarchi | last post by:
I have a button that prints a report and runs a query to update the records whose invoice was printer. I have the report setup to print on a specific printer. It's been working fine for months,...
0
by: Zulqarnain | last post by:
I have developed a report in developer 6i. It properly prints on laser printer but it do not print on receipt printer (CZERLOP). Printing job has sent to printer & printer also detect this job but...
9
johny10151981
by: johny10151981 | last post by:
I am having a silly trouble. I am not getting printer name properly using PRINTDLG struct and PrintDlg Function. I tried to follow the suggestion provided in msdn it is not working. The test...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.