Home > other >  .Net Core connect to a Windows Printer
.Net Core connect to a Windows Printer

Time:01-02

NET 6 and F#. Hardware interaction is a new field!

I’m trying to connect to a printer that is installed on Windows and has a name “PRINTERNAME”. I was previously using a PHP library that could connect with that name, but the .NET library I was using cannot. So going to attempt it myself.

The printer is connected via USB.

What is the best way to connect and simply verify that that printer exists on the local machine?

I’m using F#, but it’s more of a framework question as I have no idea what type of interfaces or libraries to use.

CodePudding user response:

I don't have much experience with this, but I don't think there's any way to "connect" to a printer in .NET without actually printing something.

One thing you can do instead is enumerate the printers installed on your system:

open System.Drawing.Printing   // Nuget package: System.Drawing.Common

for printer in PrinterSettings.InstalledPrinters do
    printfn "%s" printer

The documentation for the PrinterSettings class might have more useful information for you.

  • Related