- Find Printer Name
- Get Printer Driver By Printer Name Vb Net Database
- Get Printer Driver By Printer Name Vb Net Datagrid
- 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.
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
BlumerBlumer2 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.
CorinCorinThe 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.
Not the answer you're looking for? Browse other questions tagged vb.netprintingdefault or ask your own question.
I am upgrading VB6 to .NET after the upgrade I get the compile error:
My code in VB6 is something like this:
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.
natenate4 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.
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
natenateTake 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 BruceFind Printer Name
Stan BruceFrom MSDN:
Full documentation here: http://msdn.microsoft.com/en-us/library/microsoft.visualbasic.powerpacks.printing.compatibility.vb6.printer.textheight.aspx
jacjacPrinting 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