Skip to content

Instantly share code, notes, and snippets.

@bseib
Created March 5, 2023 14:24
Show Gist options
  • Save bseib/07eade25cda82762c6d7d9e7b843861f to your computer and use it in GitHub Desktop.
Save bseib/07eade25cda82762c6d7d9e7b843861f to your computer and use it in GitHub Desktop.
How to traverse list of printers and get the paper sizes available
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