How to Read Barcode from PDF in C#.NET?

.NET Barcode Scanner SDK  >  Read Barcodes in .NET  >  C# Barcode Scanning from PDF

VeryPDF Barcode Generator & Recognition SDK/COM,

http://www.verypdf.com/app/barcode/try-and-buy.html#Buy_Barcode_Recognition_SDK

As you know, VeryPDF .NET Barcode Reader Library can be used to scan and recognize 1D and 2D barcodes from common image file formats (like PNG, JPEG, TIFF, GIF, BMP). However, there are also a lot of needs for decoding barcode information from PDF file in Visual C#.NET project. So, we provide a solution for this. To achieve fast C# barcode recognition from PDF document, both our .NET Barcode Reader SDK and .NET PDF to Image Conversion SDK should be used. For more information, you can see VeryPDF PDF to Image Converter in .NET.

http://www.verypdf.com/app/pdf-to-image-converter/try-and-buy.html#buy-cvt-com

These two SDKs support reading 10+ barcode types from PDF file using C# programming language, like linear barcodes (Code128, UPC-A, UPC-E, EAN8, EAN13, etc.) and matrix barcodes (QRCode, PDF417, DataMatrix, etc.).

Scan Barcode in PDF - C Sharp Sample

Now, taking linear bar code as an example, we will introduce you how to detect and decode Code 128 barcode image from PDF document page in C#.NET application. First, launch Visual Studio and create a new Console Application. Then, download "VeryPDF .NET PDF to Image SDK" and ".NET Barcode Reader SDK", and add "VeryPDF.PDFtoImageCom" and "VeryPDF.BarcodeCom" to your C# project reference. Finally, copy and paste the following free C# code into your project.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using VeryPDF;
using System.IO;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string appPath = Path.GetDirectoryName(Application.ExecutablePath);
            {
                System.Type VeryPDFType
                        = System.Type.GetTypeFromProgID("VeryPDF.BarcodeCom");
                VeryPDF.BarcodeCom VeryPDFCom = (VeryPDF.BarcodeCom)
                        System.Activator.CreateInstance(VeryPDFType);

                string appFolder = Path.GetDirectoryName(Application.ExecutablePath);
                string strFolder = appFolder;

                string strReturn = "";
                int nFileIndex = 0;
                VeryPDFCom.EnableDebugLog(true);

                string strBarcode = "CODE39";
                string strOutFile = strFolder + "\\_type2_code39.pdf";
                string strCmd = "-$ XXXXXXXXXXXXXXXXXX -type2 code39
                           -textxalign center -textyoffset 20 -textcolor FF0000
                           -paper 1000x1000 \"" + strBarcode + "\" \"" + strOutFile + "\"";
                strReturn += VeryPDFCom.GenerateBarcode(strCmd);
                nFileIndex = nFileIndex + 1;

                strBarcode = "CODE39";
                strOutFile = strFolder + "\\_type2_code39.png";
                strCmd = "-$ XXXXXXXXXXXXXXXXXX -type2 code39
                           -textxalign center -textyoffset 20 -textcolor FF0000
                           -paper 1000x1000 \"" + strBarcode + "\" \"" + strOutFile + "\"";
                strReturn += VeryPDFCom.GenerateBarcode(strCmd);
                nFileIndex = nFileIndex + 1;

                string strBarcodeFile = strFolder + "\\barcode.pdf";
                strCmd = "-$ XXXXXXXXXXXXXXXXXX -decode \"" + strBarcodeFile + "\"";
                strReturn += VeryPDFCom.GenerateBarcode(strCmd);
                nFileIndex = nFileIndex + 1;

                MessageBox.Show(strReturn);
            }
        }
    }
}

VN:F [1.9.20_1166]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.20_1166]
Rating: 0 (from 0 votes)

Related Posts

This entry was posted in Barcode Generator and tagged , , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *


Verify Code   If you cannot see the CheckCode image,please refresh the page again!