Can I Read Barcode in PDF document using C#?

back to home  >  Tech FAQ  >  Reading Barcode from PDF documentusing C# is available?

Question:

Hi, can anyone help me? I have some barcode in PDF document, and I'd like to decode these barcodes out. I searched in the google, and found many of others didn't do it well. How about your .net barcode reader SDK, support this?

---- Johnson

Answer:

Hi, Johnson.

Our .NET Barcode Scanner control is usually able to read barcode from raster image files, such as .bmp, .png, .jpg and so on. If you want to read barcode from PDF document, maybe it's a little more complicated. You need use pqScan PDF to Image Library to convert PDF page to image first, and then decode the barcode from this image.

Before starting your .net application, you need download the free trial version of .NET Barcode Scanner SDK and .NET PDF to Image SDK. And then add the reference to your .net project in the Visual Studio. Now, all the preparation is done.

Here we provide steps of reading barcode from PDF using C# language. You can find in each step, the code is very simple.

using System;
using System.Drawing;
using PQScan.PDFToImage;
using PQScan.BarcodeScanner;


namespace BarcodeReaderQuestion
{
    class Program
    {
        static void Main(string[] args)
        {
            //step 1: 
            //convert PDF to image.
            PDFDocument pdf = new PDFDocument();
            pdf.LoadPDF("sample.pdf");
            //get first page to image
            Bitmap bmp = pdf.ToImage(0);

            //step 2: 
            //scan barcode from image
            BarcodeResult[] results = BarCodeScanner.Scan(bmp);
            foreach (BarcodeResult result in results)
            {
                Console.WriteLine("barcode data:" + result.Data);
                Console.Write(" barcode type:" + result.BarType.ToString());
            }                 
        }       
    }
}

Hope the C# code can be helpful.

---- pqScan Support Team

Online Demo Download Trial Can I Read Barcode in PDF document using C#? Need help for reading barcode with unconventional position? How to read barcode from Microsoft Office? Can I read barcode image from report in C# .NET? Can I read color barcode image in C# .NET? Is it available for reading all of the barcode in a picture by one time? How to scan barcode from webcam or other device? Can I use your barcode reading SDK in Mono? I can't scan barcode from my images with different DPI. How to scan barcode in asp.net web application? How to scan barcode in WPF project using C# language? Can I run your .net barcode reader library in Windows7 or Windows8? How to scan rotated barcode in .net project?