Extract Images from PDF and Recognize BarCodes

The PDF documents are usually comprised of Text, Image, Table, Attachments, Graph, Annotation and other related objects. There are cases when Barcodes are embedded inside PDF file and some customers have the requirement to identify the Barcodes present inside the PDF file. The following article explains the steps on how to extract images from PDF pages and identify the Barcodes inside them.

VeryPDF Barcode Generator & Recognition SDK/COM,

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

According to Document Object Model of "VeryPDF Barcode Recognition SDK" for .NET, a PDF file contains one or more pages where each page contains collection of Images, Forms and Fonts in Resources object. So in order to extract images from PDF file, we will traverse through individual pages of PDF file, get the collection of Images from particular page and save them in MemoryStream object for further processing with BarCodeReader.

image

The following VB.NET code will let you know how to extract barcodes from PDF files,

Public Class Form1
    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        Dim strFolderDir As String = Application.StartupPath()

        Dim VeryPDFCom As Object = CreateObject("VeryPDF.BarcodeCom")
        Dim filesys As Object = CreateObject("Scripting.FileSystemObject")
        Dim strFolder As String = strFolderDir

        Dim strReturn As String = ""
        Dim nFileIndex As Integer = 0
        VeryPDFCom.EnableDebugLog(1)

        Dim strBarcode = "CODE39"
        Dim strOutFile = strFolder & "\_type2_code39.pdf"
        Dim strCmd = "-$ XXXXXXXXXXXXXXXXXX -type2 code39 -textxalign center
                -textyoffset 20 -textcolor FF0000 -paper 1000x1000 """ & strBarcode
                & """ """ & strOutFile & """"
        strReturn = 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 = strReturn & VeryPDFCom.GenerateBarcode(strCmd)
        nFileIndex = nFileIndex + 1

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

        MsgBox(strReturn)
    End Sub
End Class

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, VeryPDF SDK & COM 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!