Created
March 5, 2023 14:24
-
-
Save bseib/07eade25cda82762c6d7d9e7b843861f to your computer and use it in GitHub Desktop.
How to traverse list of printers and get the paper sizes available
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Public Sub investigatePrinterPaperSizeSituation() | |
Dim printerList As PrinterSettings.StringCollection = PrinterSettings.InstalledPrinters() | |
For Each printer As String In printerList | |
_logger.logInfo("found printer: " & printer) | |
Dim settings As PrinterSettings = new PrinterSettings() | |
'' So...., check this out: | |
settings.PrinterName = printer | |
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' | |
'' Apparently PrinterSettings is stateful in such a way that by | |
'' assigning the name of the printer we care about, the subsequent | |
'' member function calls will return info about *that* printer. | |
'' 🤔🤯, 🥴🤢🤮 | |
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' | |
For Each paperSize As PaperSize In settings.PaperSizes() | |
_logger.logInfo(" : " & paperSize.PaperName) | |
Next | |
Next | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment