Skip to content

Using ZXing.Net with Powershell

Michael Jahn edited this page Nov 29, 2017 · 3 revisions

You can use the ZXing barcode reader from the powershell. The following snippet shows one way to decode a barcode bitmap.

PS C:\>Add-Type -Path <place the path to the zxing.dll here>\zxing.dll
PS C:\>$reader = New-Object -TypeName ZXing.BarcodeReader
PS C:\>$reader.Options.TryHarder = 1 # set TryHarder option to true, other options can be set the same way
PS C:\>$bitmap = [System.Drawing.Bitmap]::FromFile("<path to your bitmap image file>")
PS C:\>$result = $reader.Decode($bitmap)
PS C:\>$bitmap.Dispose()
PS C:\>$result.Text