Online Guide

For Using BC.NetPdfBarcodeReader.All
Read and recognize 2d & 1d barcodes from PDF document page(s) at fast speed.

Guide Overview

It's easy to use BC.NetPdfBarcodeReader.All library to scan and read barcode symbologies from PDF in your .NET/C#/VB.NET projects. Here we will show you in simple steps. Please firstly download and get the free trial library (BC.NetPdfBarcodeReaderTrial.All.dll). And the only thing for the integration of our library is to add your project reference to it.

BC.NetPdfBarcodeReader.All

We take the Console Application as an example of how to use BC.NetPdfBarcodeReader.All library to scan and read 1D & 2D barcodes from PDF document page(s). For ease of use, here are simple code examples for C# and VB.NET developers (see as follows). Moreover, a demo project is included in our free trial package. You can download a free trial to see more.

PLEASE NOTE: You need to copy BC.Resources.dll from x86 or x64 folder of the trial package to your C# project bin directory, Bin\Debug. For VB.NET project, you also need to do this but should copy the dll to your project folder Bin\x86\Debug or Bin\x64\Debug.


PDF Barcode Generation Examples in C# & VB.NET

This section includes several pieces of using BC.NetPdfBarcodeReader.All library to read barcode(s) from PDF in C# and VB.NET programming which includes,
1. Scan and read one type barcode(s) from one PDF page
2. Scan and read one type barcode(s) from multiple PDF pages
3. Scan and read multiple types of barcodes from one PDF page
4. Scan and read multiple types of barcodes from multiple PDF pages

How to in C#

using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Drawing.Imaging;
using BC.NetPdfBarcodeReaderTrial.All;
using BC.NetPdfBarcodeReaderTrial.Pdf;

namespace BCNetPdfBarcodeReader
{
    class Program
    {
        static void Main(string[] args)
        {
            ReadOneBarcodeTypeFromOnePdfPage();
            //ReadMultipleBarcodeTypesFromOnePdfPage();
            //ReadOneBarcodeTypeFromMultiplePdfPages();
            //ReadMultipleBarcodeTypesFromMultiplePdfPages();
        }

        public static void ReadOneBarcodeTypeFromOnePdfPage()
        {
                PdfDoc pdf = new PdfDoc("test.pdf");
                pdf.SetDPI = 72;
                Image pageImage = pdf.ConvertToImage(0, 1000, 1000);
                Bitmap bitmap = new Bitmap(pageImage);                
                string[] data = NetPdfBarcodeReader.Recognize(bitmap, NetPdfBarcodeReader.Code128);
                foreach (string result in data)
                {
                    Console.WriteLine(result);
                }
                    Console.ReadKey();
        }

        public static void ReadMultipleBarcodeTypesFromOnePdfPage()
        {
                PdfDoc pdf = new PdfDoc("test1.pdf");
                pdf.SetDPI =72;
                Image pageImage = pdf.ConvertToImage(0, 1900, 1000);                
                Bitmap bitmap = new Bitmap(pageImage);
                string[] data = NetPdfBarcodeReader.Recognize(bitmap, NetPdfBarcodeReader.Code128);
                foreach (string result in data)
                {
                    Console.WriteLine(result);
                }
                string[] data1 = NetPdfBarcodeReader.Recognize(bitmap, NetPdfBarcodeReader.Qrcode);
                foreach (string result in data1)
                {
                    Console.WriteLine(result);
                }  
                    Console.ReadKey();
        }

        public static void ReadOneBarcodeTypeFromMultiplePdfPages()
        {
                PdfDoc pdf = new PdfDoc("test2.pdf");
                pdf.SetDPI = 72;
                for (int i = 0; i < pdf.FilePageCount; i++)
                {
                    Image pageImage = pdf.ConvertToImage(i, 1200, 1200);
                    Bitmap bitmap = new Bitmap(pageImage);
                    //pageImage.Save("Page" + i + ".jpg", ImageFormat.Jpeg);
                    string[] data = NetPdfBarcodeReader.Recognize(bitmap, NetPdfBarcodeReader.Code128);
                    foreach (string result in data)
                  {
                    Console.WriteLine(result);
                  }                          
                }
                    Console.ReadKey();
         }

        public static void ReadMultipleBarcodeTypesFromMultiplePdfPages()
        {
            PdfDoc pdf = new PdfDoc("test3.pdf");
            pdf.SetDPI = 72;
            for (int i = 0; i < pdf.FilePageCount; i++)
            {
                Image pageImage = pdf.ConvertToImage(i, 1000, 1200);
                Bitmap bitmap = new Bitmap(pageImage);
                pageImage.Save("Page" + i + ".jpg", ImageFormat.Jpeg);
                string[] data = NetPdfBarcodeReader.Recognize("Page" + i + ".jpg", NetPdfBarcodeReader.Code128);
                foreach (string result in data)
                {
                    Console.WriteLine(result);
                }

                string[] data1 = NetPdfBarcodeReader.Recognize("Page" + i + ".jpg", NetPdfBarcodeReader.Qrcode);
                foreach (string result in data1)
                {
                    Console.WriteLine(result);
                } 
            }           
            Console.ReadKey();
        }
    }
}

How to in VB.NET

Imports System
Imports System.IO
Imports System.Collections.Generic
Imports System.Linq
Imports System.Text
Imports System.Drawing
Imports System.Drawing.Imaging
Imports BC.NetPdfBarcodeReaderTrial.All
Imports BC.NetPdfBarcodeReaderTrial.Pdf

Module BCNetPdfBarcodeReader

    Public Sub Main()
        ReadOneBarcodeTypeFromOnePdfPage()
        'ReadMultipleBarcodeTypesFromOnePdfPage()
        'ReadOneBarcodeTypeFromMultiplePdfPages()
        'ReadMultipleBarcodeTypesFromMultiplePdfPages()

    Public Sub ReadOneBarcodeTypeFromOnePdfPage()
        Dim pdf As PdfDoc = New PdfDoc("test.pdf")
        pdf.SetDPI = 72
        Dim pageImage As Image = pdf.ConvertToImage(0, 1000, 1000)
        Dim bitmap As Bitmap = New Bitmap(pageImage)
        Dim data As String() = NetPdfBarcodeReader.Recognize(bitmap, NetPdfBarcodeReader.Code128)

        For Each result As String In data
            Console.WriteLine(result)
        Next

        Console.ReadKey()
    End Sub

    End Sub
    Public Sub ReadMultipleBarcodeTypesFromOnePdfPage()
        Dim pdf As PdfDoc = New PdfDoc("test1.pdf")
        pdf.SetDPI = 72
        Dim pageImage As Image = pdf.ConvertToImage(0, 1900, 1000)
        Dim bitmap As Bitmap = New Bitmap(pageImage)
        Dim data As String() = NetPdfBarcodeReader.Recognize(bitmap, NetPdfBarcodeReader.Code128)

        For Each result As String In data
            Console.WriteLine(result)
        Next

        Dim data1 As String() = NetPdfBarcodeReader.Recognize(bitmap, NetPdfBarcodeReader.Qrcode)

        For Each result As String In data1
            Console.WriteLine(result)
        Next

        Console.ReadKey()
    End Sub

    Public Sub ReadOneBarcodeTypeFromMultiplePdfPages()
        Dim pdf As PdfDoc = New PdfDoc("test2.pdf")
        pdf.SetDPI = 72

        For i As Integer = 0 To pdf.FilePageCount - 1
            Dim pageImage As Image = pdf.ConvertToImage(i, 1200, 1200)
            Dim bitmap As Bitmap = New Bitmap(pageImage)
            Dim data As String() = NetPdfBarcodeReader.Recognize(bitmap, NetPdfBarcodeReader.Code128)

            For Each result As String In data
                Console.WriteLine(result)
            Next
        Next

        Console.ReadKey()
    End Sub

    Public Sub ReadMultipleBarcodeTypesFromMultiplePdfPages()
        Dim pdf As PdfDoc = New PdfDoc("test3.pdf")
        pdf.SetDPI = 72

        For i As Integer = 0 To pdf.FilePageCount - 1
            Dim pageImage As Image = pdf.ConvertToImage(i, 1000, 1200)
            Dim bitmap As Bitmap = New Bitmap(pageImage)
            pageImage.Save("Page" & i & ".jpg", ImageFormat.Jpeg)
            Dim data As String() = NetPdfBarcodeReader.Recognize("Page" & i & ".jpg", NetPdfBarcodeReader.Code128)

            For Each result As String In data
                Console.WriteLine(result)
            Next

            Dim data1 As String() = NetPdfBarcodeReader.Recognize("Page" & i & ".jpg", NetPdfBarcodeReader.Qrcode)

            For Each result As String In data1
                Console.WriteLine(result)
            Next
        Next

        Console.ReadKey()
    End Sub


End Module

Besides reading barcodes from PDF, we also provide a .NET barcode reading solution for various image formats. If you are also interested in this, please see our product BC.NetBarcodeReader.All and its online tutorial.