Printing to various network printers...

A

Alex

Hi,

I'm writing an app to run on a server, hopefully autmated, and every 5
minutes it needs to hit a database and if any new records have been
entered, print the record to a printer depending on certain criteria.
I'm not sure if I'll handle timing through the app or through Windows
Scheduler... but that's outside my question here.

All our printers are Jetdirect compliant printers and on our network
as \\printserver\printername or I can print directly to IP if that's
an option. My goal is to have a table containing all the printers
(whether by UNC or IP) and give each printer a unique ID, then a
second table will contain the data to print plus a PrinterID field for
VB so it knows which printer to send the output to.

My question is within VB, how do I send the print job directly to a
specific printer, bypassing the default printer? I did this years ago
in VB6, but I've never done it in VB.Net. I'm usign VB 2005 also, and
hopefully this'll be setup via Winforms.

Thanks --

Alex
 
T

Terry

Printing in .Net is significantly different then in VB6. The .Net way is to
use the PrintDocument class and .PrinterSettings.PrinterName. You may also
want to look at
Visual Basic Power Packs V2.0 for a more VB6 like way of printing.
 
K

kimiraikkonen

Printing in .Net is significantly different then in VB6. The .Net way is to
use the PrintDocument class and .PrinterSettings.PrinterName. You may also
want to look at
Visual Basic Power Packs V2.0 for a more VB6 like way of printing.

There are some control printing-related controls. Take a look at
toolbox for this.
 
K

kimiraikkonen

Hi,

I'm writing an app to run on a server, hopefully autmated, and every 5
minutes it needs to hit a database and if any new records have been
entered, print the record to a printer depending on certain criteria.
I'm not sure if I'll handle timing through the app or through Windows
Scheduler... but that's outside my question here.

All our printers are Jetdirect compliant printers and on our network
as \\printserver\printername or I can print directly to IP if that's
an option. My goal is to have a table containing all the printers
(whether by UNC or IP) and give each printer a unique ID, then a
second table will contain the data to print plus a PrinterID field for
VB so it knows which printer to send the output to.

My question is within VB, how do I send the print job directly to a
specific printer, bypassing the default printer? I did this years ago
in VB6, but I've never done it in VB.Net. I'm usign VB 2005 also, and
hopefully this'll be setup via Winforms.

Thanks --

Alex

Some links you may want to see:
http://www.startvbdotnet.com/controls/printdialog.aspx
http://www.vbdotnetheaven.com/UploadFile/mgold/PrintinginVBNET04202005015906AM/PrintinginVBNET.aspx
http://visualbasic.about.com/od/usingvbnet/a/printvb2005.htm

has good info on printing.

That controls must let you to select a specific printer rather than
default printer.
 
T

Teemu

Alex said:
My question is within VB, how do I send the print job directly to a
specific printer, bypassing the default printer? I did this years ago
in VB6, but I've never done it in VB.Net. I'm usign VB 2005 also, and
hopefully this'll be setup via Winforms.

Here is a way to get all printers:

Dim PrintDoc As New Printing.PrintDocument
Dim DefaultPrinter As String = PrintDoc.PrinterSettings.PrinterName
Dim PrinterList As New List (Of String)

For i As Integer = 0 To
Drawing.Printing.PrinterSettings.InstalledPrinters.Count - 1
PrinterList.Add(Drawing.Printing.PrinterSettings.InstalledPrinters(i)))
Next

And with this code you can select the printer:

PrintDoc.PrinterSettings.PrinterName = PrinterList(2) ' Set the right
printer

-Teemu
 

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

Similar Threads


Top