Get Printer Driver By Printer Name Vb Net Data

  1. Find Printer Name
  2. Get Printer Driver By Printer Name Vb Net Database
  3. Get Printer Driver By Printer Name Vb Net Datagrid
  4. Double Check The Printer Name And Make Sure

.NET Class to print directly to windows printer By Allen Stoner If you want to print a PCL file directly to an HP printer you need to bypass the Windows printer driver. Getting Printer Port in VB.NET. Now my requirement is to get the Printer Name, Printer Port and Printer Driver for the Printer, which user has selected. Hi Experts, Is it possible to get a network printers IP Address once mapped to my machine? I map printer through run print server printername.

Active10 years, 1 month ago

I'd like to be able to specify two different printers for two different jobs. I'm using the following class to handle printing these, but regardless of what I do, the default printer is always the one that's printed to.

If I inspect my PrinterSettings attribute immediately before the call to DrawString, the PrinterName attribute is still correctly set to the printer I specify, but it's still the default printer that kicks out the job. I'm sure I'm missing something obvious, but would certainly appreciate if someone could point out what it is. :)

Thanks

BlumerBlumer
4,6002 gold badges28 silver badges46 bronze badges

2 Answers

I just created a test app with the class code you posted and it works fine. It uses whatever printer I select. So I must conclude that wherever you are using this class you're accidentally altering the PrintSettings object after you initialize the object but before you call Print.

Or perhaps the printer name you specify isn't valid and the default is used as a backup. You can check this using PrinterSettings.IsValid after setting the PrinterName property.

CorinCorin
1,5012 gold badges23 silver badges38 bronze badges

The PrinterSettings.PrinterName property is actually what you should be using.

You can get a list of installed printers using PrinterSettings.InstalledPrinters (System.Drawing.Printing namespace). Perhaps your provider printer name is slightly different from what it should be, because I can confirm this actually works.

ThorarinThorarin
38.6k9 gold badges62 silver badges105 bronze badges

Not the answer you're looking for? Browse other questions tagged vb.netprintingdefault or ask your own question.

Active4 years, 10 months ago

I am upgrading VB6 to .NET after the upgrade I get the compile error:

My code in VB6 is something like this:

Printer

What is the correct way to declare a printer in .NET?

Note: I tried to download the printer power pack, but was unable to get it to work.

natenate
7203 gold badges24 silver badges62 bronze badges

4 Answers

Visual Basic 6.0 had an intrinsic Printer object that you could use without explicitly declaring it. In contrast, the Printer Compatibility library behaves like any other .NET Framework object; you must explicitly declare a .NET Framework Printer object before you can use it.

Name

After you upgrade your project, you could add Printer object like this:

1) On the Project menu, click Add Reference.

2) In the Add Reference dialog box, on the .NET tab, click Microsoft.VisualBasic.PowerPacks.Printing.Printer, and then click OK.

3) In the Code Editor, add the following statement at the top of the module that contains your Visual Basic 6.0 Printer code:

Imports Microsoft.VisualBasic.PowerPacks.Printing.Compatibility.VB6

4) Add the following code at the top of the procedure that contains Printer code:

Public Printer As New Printer

natenate
7203 gold badges24 silver badges62 bronze badges

Take a look at PrintDocument in the System.Drawing.Printing namespace.

You can also find a tutorial here, which covers your problem.

The other answers are suggesting using the Microsoft.VisualBasic.PowerPacks.Printing.Compatibility.VB6 namespace, but as per MSDN:

This namespace enables Visual Basic 6.0 Printer code to run without modification in an upgraded project; it is not intended for new development. For new development, use the PrintDocument component.

Stan Bruce

Find Printer Name

Stan Bruce
1,3592 gold badges20 silver badges32 bronze badges

From MSDN:

Full documentation here: http://msdn.microsoft.com/en-us/library/microsoft.visualbasic.powerpacks.printing.compatibility.vb6.printer.textheight.aspx

jacjac
8,4302 gold badges23 silver badges59 bronze badges

Printing in VB.NET is very different to VB6. Here's sample code to get you started. I'd recommend you consider 'printing' to PDF instead, e.g. using the PDFSharp library. PDFSharp is more like the VB6 printer object, and you get a PDF of the document as an added bonus.

SSS

Get Printer Driver By Printer Name Vb Net Database

SSS

Get Printer Driver By Printer Name Vb Net Datagrid

4,6421 gold badge14 silver badges37 bronze badges

Double Check The Printer Name And Make Sure

Not the answer you're looking for? Browse other questions tagged vb.netprintingvb6vb6-migrationdeclare or ask your own question.