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:

AustralianPostCode

Aztec

BorderedTable

Checkbox

Circle

CircularI2of5

Codabar

CodablockF

Code128

Code16K

Code39

Code39Extended

Code39Mod43

Code39Mod43Extended

Code93

DataMatrix

DPMDataMatrix

EAN13

EAN2

EAN5

EAN8

GS1

GS1DataBarExpanded

GS1DataBarExpandedStacked

GS1DataBarLimited

GS1DataBarOmnidirectional

GS1DataBarStacked

GTIN12

GTIN13

GTIN14

GTIN8

HorizontalLine

IntelligentMail

Interleaved2of5

ITF14

MaxiCode

MICR

MicroPDF

MSI

Oval

PatchCode

PDF417

Pharmacode

PostNet

PZN

QRCode

Rectangle

RoyalMail

RoyalMailKIX

Segment

Trioptic

UnderlinedField

UPCA

UPCE

UPU

VerticalLine

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)

Response codes as follows:

Code

Description

200

The request has succeeded

400

Bad input parameters

401

Unauthorized

403

Not enough credits

405

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.