Barcode Reader#

Available Methods#

/barcode/read/from/url#

Read barcodes from images and PDF. Can read all popular barcode types from QR Code and Code 128, EAN to Datamatrix, PDF417, GS1 and many other barcodes.

  • Method: POST

  • Endpoint: /v1/barcode/read/from/url

Attributes#

Note

Attributes are case-sensitive and should be inside JSON for POST request, for example:

{
    "url": "https://example.com/file1.pdf"
}

Attribute

Description

Required

url

URL to the source file. 1

yes

httpusername

HTTP auth user name if required to access source url.

no

httppassword

HTTP auth password if required to access source url.

no

pages

Comma-separated indices of pages (or page ranges) that you want to use. The first-page index is always 0. For example, if you have a 7-page document that you want to be split into 3 separate PDFs but a different number of pages it would go like this: 0, 1, 2- or 1, 2, 3-7 which will result in 1 PDF with page one, 1 PDF with page two and one PDF with the rest of the pages. You can also use inverted page numbers adding ! before the number. E.g. !0 means “the last page”, 1-!1 means “from the second to the penultimate page”, and !1- - “last two pages”. Also, you can use a single asterisk (*) character as the range to split the document into separate pages. The input must be in string format.

no

type

Set the barcode type, must be in a string format. QRCode by default. See: Supported Barcode Types.

no

types

See Optical Marks Reader.

Comma-separated list of object types to decode, must be in a string format. Object types supported:

  • Checkbox - locates check boxes.

  • Radiobox - locates radio boxes.

  • Segment - locates and selects objects on a page (general selection)

  • UnderlinedField - detects fillable fields (typically, underlined spaces, i.e. fields to fill in a form).

  • Rectangle - detects rectangles, including checkboxes. Also returns the value as 1 if a checkmark or a filled rectangle was detected.

  • Oval - detects rounded or oval marks (typically, a radiobox). Returns value of 1 if filled out radiobox was detected.

  • HorizontalLine - detects horizontal lines.

  • VerticalLine - detects vertical lines.

For selecting multiple types then comma-separate the items.

no

async

Set async to true for long processes to run in the background, API will then return a jobId which you can use with the Background Job Check endpoint to check the status of the process and retrieve the output while you can proceed with other tasks.

no

profiles

Use this parameter to set additional configurations for fine-tuning and extra options. Explore the Profiles section for more.

no

Supported Barcode Types#

The supported barcode types are as follows:

Name

Type

Character Set

Length

Notes

AustralianPostCode

2D

Numbers Only

4

Aztec

2D

Full ASCII; FNC1 and ESI control codes

Variable, Min 12 - Max 3832

Codabar

Linear

Numbers: 0-9; Symbols: - : . $ / + Start/Stop Characters: A, B, C, D, E, *, N, or T

Variable

CodablockF

Complex - see this guide.

Code128

Linear

All ASCII characters and control codes

Variable

Code16K

Code39

Linear

Uppercase letters A-Z; Numbers 0-9; Space - . $ / + %

Variable

Code39Extended

Linear

All ASCII characters and control codes

Variable

Code39Mod43

Code39Mod43Extended

Code93

Linear

Uppercase letters A-Z; Numbers 0-9; Space - . $ / + %

DataMatrix

2D

All ASCII characters

Variable

DPMDataMatrix

EAN13

Linear

Numbers Only

13 + check digit +2 optional +5 optional

EAN2

Linear

Numbers only

Exact 2 Numbers

EAN5

Linear

Numbers Only

Exact 5 Numbers

EAN8

Linear

Numbers Only

7 + check digit

GS1 - 128

Linear

ASCII symbols

128 ASCII symbols

GS1DataBarExpanded

Linear

String

74 numeric or 41 alphabetic characters

GS1DataBarExpandedStacked

Linear

String

74 numeric or 41 alphabetic characters

GS1DataBarLimited

Linear

Numbers Only

Upto 14 digits

Last digit must be checksum and will be verified

GS1DataBarOmnidirectional

Linear

Numbers Only

Upto 14 digits

Last digit must be checksum and will be verified

GS1DataBarStacked

Linear

Numbers Only

Upto 14 digits

Last digit must be checksum and will be verified

GTIN12

Linear

Numbers Only

Expects 11 digits. User may enter 12th digit

GTIN13

Linear

Numbers Only

Expects 12 digits. User may enter 13th digit

GTIN14

Linear

Numbers Only

Expects 13 digits. User may enter 14th digit

GTIN8

Linear

Numbers Only

Expects 7 digits. User may enter 8th digit

IntelligentMail

Linear

Numbers Only

Upto 31 digits of data

Tracking code should be exactly 20 digits long and Rounding code may be 0,5,9 or 11 digits long. Spaces and dots are allowed as separators.

Interleaved2of5

Linear

Numbers Only

EVEN if checksum is not to be added, ODD if checksum is to be added

ITF14

Linear

Numbers Only

Expects 13 digits. User may enter 14th digit which will be verified.

MaxiCode

2D

All ASCII characters

93

MICR

MicroPDF

2D

String

1850 characters or 2710 digits

MSI

Linear

Numbers Only

Variable

PatchCode

PDF417

Linear

This symbology supports all 256 ASCII characters and 8-bit binary data.

Variable

Pharmacode

Linear

Decimal Numbers

Number can be between 1 to 131070

PostNet

Postal

Numbers Only

5 + check digit +4 optional +6 optional

PZN

Linear

Numbers Only

Excatly 6 or 7 digits

QRCode

2D

All ASCII characters

Variable

RoyalMail

Postal

Digits and characters from A to Z

RoyalMailKIX

Postal

All numeric digits (0-9). All uppercase letters (A-Z)

Variable

Trioptic

UPCA

Linear

Numbers Only

11 + check digit +2 optional +5 optional

UPCE

Linear

Numbers Only

UPC-E encodes 6 digits of numeric message data together with a number system digit and a check digit, for a total of 8 digits.

UPU

Postal

Query parameters#

No query parameters accepted.

Payload#

{
    "url": "https://pdfco-test-files.s3.us-west-2.amazonaws.com/barcode-reader/sample.pdf",
    "types": "QRCode,Code128,Code39,Interleaved2of5,EAN13",
    "pages": "0",
    "async": false
}

Response 2#

{
    "barcodes": [
        {
            "Value": "abcdef123456",
            "RawData": "",
            "Type": 14,
            "Rect": "{X=448,Y=23,Width=106,Height=112}",
            "Page": 0,
            "File": "https://pdfco-test-files.s3.us-west-2.amazonaws.com/barcode-reader/sample.pdf",
            "Confidence": 1,
            "Metadata": "",
            "TypeName": "QRCode"
        },
        {
            "Value": "test123",
            "RawData": "",
            "Type": 2,
            "Rect": "{X=111,Y=60,Width=255,Height=37}",
            "Page": 0,
            "File": "https://pdfco-test-files.s3.us-west-2.amazonaws.com/barcode-reader/sample.pdf",
            "Confidence": 0.90625155,
            "Metadata": "",
            "TypeName": "Code128"
        },
        {
            "Value": "123456",
            "RawData": "",
            "Type": 4,
            "Rect": "{X=111,Y=129,Width=306,Height=37}",
            "Page": 0,
            "File": "https://pdfco-test-files.s3.us-west-2.amazonaws.com/barcode-reader/sample.pdf",
            "Confidence": 0.7710818,
            "Metadata": "",
            "TypeName": "Code39"
        },
        {
            "Value": "<FNC1>0112345678901231",
            "RawData": "",
            "Type": 2,
            "Rect": "{X=111,Y=198,Width=305,Height=37}",
            "Page": 0,
            "File": "https://pdfco-test-files.s3.us-west-2.amazonaws.com/barcode-reader/sample.pdf",
            "Confidence": 0.9156459,
            "Metadata": "",
            "TypeName": "Code128"
        },
        {
            "Value": "12345670",
            "RawData": [
                1,
                2,
                3,
                4,
                5,
                6,
                7,
                0
            ],
            "Type": 5,
            "Rect": "{X=111,Y=267,Width=182,Height=0}",
            "Page": 0,
            "File": "https://pdfco-test-files.s3.us-west-2.amazonaws.com/barcode-reader/sample.pdf",
            "Confidence": 1,
            "Metadata": "",
            "TypeName": "I2of5"
        },
        {
            "Value": "1234567890128",
            "RawData": "",
            "Type": 6,
            "Rect": "{X=102,Y=336,Width=71,Height=72}",
            "Page": 0,
            "File": "https://pdfco-test-files.s3.us-west-2.amazonaws.com/barcode-reader/sample.pdf",
            "Confidence": 0.895925164,
            "Metadata": "",
            "TypeName": "EAN13"
        }
    ],
    "pageCount": 1,
    "error": false,
    "status": 200,
    "remainingCredits": 99826192,
    "credits": 35
}

CURL#

curl --location --request POST 'https://api.pdf.co/v1/barcode/read/from/url' \
--header 'x-api-key: ' \
--data-raw '{
    "url": "https://pdfco-test-files.s3.us-west-2.amazonaws.com/barcode-reader/sample.pdf",
    "types": "QRCode,Code128,Code39,Interleaved2of5,EAN13",
    "pages": "0",
    "async": false
}'


Optical Marks Reader#

Our barcode reader engine can also find the following marks and objects on scanned documents:

  • Checkboxes

  • Radioboxes

  • Vertical and horizontal lines

  • General segments (basically, all content types on the page).

Payload#

{
    "url": "https://pdfco-test-files.s3.us-west-2.amazonaws.com/pdf-to-html/sample.pdf",
    "types": "Checkbox,UnderlinedField",
    "async": false
}

Response 2#

{
    "barcodes": [
        {
            "Value": "box",
            "RawData": "",
            "Type": 53,
            "Rect": "{X=298,Y=437,Width=132,Height=6}",
            "Page": 0,
            "File": "https://pdfco-test-files.s3.us-west-2.amazonaws.com/pdf-to-html/sample.pdf",
            "Confidence": 1,
            "Metadata": "",
            "TypeName": "UnderlinedField"
        }
    ],
    "pageCount": 1,
    "error": false,
    "status": 200,
    "duration": 860,
    "remainingCredits": 98725528,
    "credits": 35
}

CURL#

curl --location --request POST 'https://api.pdf.co/v1/barcode/read/from/url' \
--header 'x-api-key: ' \
--data-raw '{
  "url": "https://pdfco-test-files.s3.us-west-2.amazonaws.com/pdf-to-html/sample.pdf",
  "types": "Checkbox,UnderlinedField",
  "async": false
}'


Code samples#

Footnotes

1

Supports links from Google Drive, Dropbox, and PDF.co Built-In Files Storage. To upload files via the API check out the File Upload section. Note: If you experience intermittent Too Many Requests or Access Denied errors, please try to add cache: to enable built-in URL caching. (e.g cache:https://example.com/file1.pdf) For data security, you have the option to encrypt output files and decrypt input files. Learn more about user-controlled data encryption.

2(1,2)

Main response codes as follows:

Code

Description

200

Success

400

Bad request. Typically happens because of bad input parameters, or because the input URLs can’t be reached, possibly due to access restrictions like needing a login or password.

401

Unauthorized

402

Not enough credits

445

Timeout error. To process large documents or files please use asynchronous mode (set the async parameter to true) and then check status using the /job/check endpoint. If a file contains many pages then specify a page range using the pages parameter. The number of pages of the document can be obtained using the /pdf/info endpoint.