In this article, we will take 2D barcode QR Code as an example, to tell VB.NET programmer how to read bar code from PDF file.
- Open Visual Studio and create a new Console Application using VB.NET.
- Download pqScan .NET PDF to Image Converter and .NET Barcode Decoder online.
- Integrate "PQScan.PDFToImage.dll" and "PQScan.BarcodeScanner.Matrix.dll" to created Visual Basic project by adding reference.
- Use the following vb.net class code to implement QR Code reading from PDF document.
Imports System.Drawing Imports PQScan.PDFToImage Imports PQScan.BarcodeScanner.Matrix Namespace ReadBarcodeInPDF Class Program Private Shared Sub Main(args As String()) ' Create an instance of PQScan.PDFToImage.PDFDocument object. Dim pdfDoc As New PDFDocument() ' Load a PDF file. pdfDoc.LoadPDF("sample.pdf") ' Convert the first page of PDF to an image. Dim bmp As Bitmap = pdfDoc.ToImage(0) ' Read all QR Code information. Dim barcodeResults As BarcodeResult() = BarCodeScanner.Scan(bmp, BarCodeType.QRCode) For Each barcodeInfo As BarcodeResult In barcodeResults Console.WriteLine(barcodeInfo.Data) Next End Sub End Class End Namespace