Detect & Read Barcodes from PDF

Example requests & Code samples for GdPicture Toolkits.
Post Reply
chr1s81
Posts: 4
Joined: Fri Sep 25, 2009 8:52 am

Detect & Read Barcodes from PDF

Post by chr1s81 » Fri Sep 25, 2009 9:58 am

Hello,
Does your Barcode recognition work with pdf documents?
Best regards,
Christoph

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: Barcode and PDF

Post by Loïc » Fri Sep 25, 2009 11:39 am

Yes it does. here is a sample:

Code: Select all

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim oGdViewer As New GdPicture.GdViewer
        Dim oGdPictureImaging As New GdPicture.GdPictureImaging

        oGdViewer.SetLicenseNumber("XXX") 'Replace XXX by a valid license KEY
        oGdPictureImaging.SetLicenseNumber("XXX") 'Replace XXX by a valid license KEY
        oGdPictureImaging.SetLicenseNumber1DBarcodeRecognition("XXX") 'Replace XXX by a valid license KEY


        oGdViewer.DisplayFromFile("") 'Prompt the user to select a PDF

        If oGdViewer.GetDocumentType = DocumentType.DocumentTypePDF Then
            Dim RasterPage As Integer = oGdViewer.PdfRenderPageToGdPictureImage(200, 1)
            oGdPictureImaging.ConvertTo1Bpp(RasterPage) 'We should have better accuracy in 1bpp mode
            oGdPictureImaging.Barcode1DReaderDoScan(RasterPage, Barcode1DReaderScanMode.BestQuality)

            Dim BarcodeCount As Integer = oGdPictureImaging.Barcode1DReaderGetBarcodeCount
            If BarcodeCount > 0 Then
                For i As Integer = 1 To BarcodeCount
                    MsgBox("Barcode No: " & Str(i))
                    MsgBox("Type: " & oGdPictureImaging.Barcode1DReaderGetBarcodeType(i).ToString)
                    MsgBox("Value: " & oGdPictureImaging.Barcode1DReaderGetBarcodeValue(i))
                    MsgBox("Angle: " & Str(oGdPictureImaging.Barcode1DReaderGetBarcodeSkewAngle(i)))
                Next
            Else
                MsgBox("No Barcode Detected !")
            End If
            oGdPictureImaging.Barcode1DReaderClear()
            oGdPictureImaging.ReleaseGdPictureImage(RasterPage)
        Else
            MsgBox("Not A PDF")
        End If
        oGdViewer.CloseDocument()
    End Sub
Let me know if you need more information.

Kind regards,

Loïc

chr1s81
Posts: 4
Joined: Fri Sep 25, 2009 8:52 am

Re: Detect & Read Barcodes from PDF

Post by chr1s81 » Fri Sep 25, 2009 1:30 pm

Thank you. Yes there is another question. If i want to use it without the viewer. What do i have to change? I dont find a function to open the pdf document.
Best regards

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: Detect & Read Barcodes from PDF

Post by Loïc » Fri Sep 25, 2009 1:45 pm

The PDF rasterization is currently only available into the GdViewer class.

But it is not a problem since you can instantiate a GdViewer silently.

Kind regards,

Loïc

chr1s81
Posts: 4
Joined: Fri Sep 25, 2009 8:52 am

Re: Detect & Read Barcodes from PDF

Post by chr1s81 » Fri Sep 25, 2009 3:00 pm

Ok :-) Hopefully this is the last question.
How do i set the next page on the rendered Tif/pdf image?

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: Detect & Read Barcodes from PDF

Post by Loïc » Fri Sep 25, 2009 3:02 pm

Hum... I am not sure to understand your issue.


Here:

Code: Select all

PdfRenderPageToGdPictureImage(200, 1)
1 is the page number. Of course, you can change it.

Loïc

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest