Skip to main content

Read Barcode from PDF - Scanner & Extractor API

PDF4me Read Barcode from PDF enables you to extract and recognize various types of barcodes and QR codes from PDF documents using advanced OCR and barcode recognition technology. This API service processes PDF files and extracts barcode data with position coordinates, type information, and extracted text. The API receives PDF content through REST API calls, utilizing Base64 encoding for secure transmission. With support for 1D and 2D barcodes including QR codes, DataMatrix, PDF417, Code128, and specialized industry formats, this solution is ideal for document processing, inventory management, tracking systems, and workflow automation.

Related Blog Posts
No blog post yet for this feature — coming soon.
In the meantime, browse the PDF4me blog for tutorials and workflows across every platform.
Visit the blog →

Authenticating Your API Request​

To access the PDF4me REST API, every request must include proper authentication credentials. Authentication ensures secure communication and validates your identity as an authorized user of the REST API.

Key Features​

  • Comprehensive Barcode Recognition: Support for 1D and 2D barcodes including QR codes, DataMatrix, PDF417, Code128, postal codes, and specialized industry formats
  • Seamless PDF Integration: Direct processing of PDF documents with support for all PDF versions and complex document structures
  • Flexible Page Processing: Process specific pages, page ranges, or entire documents with selective barcode extraction capabilities
  • Enterprise Batch Processing: Extract multiple barcodes from single or multiple pages with automated processing workflows
  • Structured Data Output: Return barcode data in structured JSON format with position coordinates, type information, and metadata for easy system integration

Supported Barcode Types​

The API supports a comprehensive range of barcode formats for reliable recognition:

1D Barcodes​

  • Code128 - Universal barcode format
  • Code39 - Alphanumeric barcode
  • Code93 - High-density barcode
  • Codabar - Numeric barcode
  • EAN8/EAN13 - European Article Number
  • UPC-A/UPC-E - Universal Product Code
  • Inter2of5 - Industrial 2 of 5
  • PatchCode - Document processing codes

2D Barcodes​

  • QR Code - Quick Response codes
  • DataMatrix - High-density 2D barcode
  • PDF417 - Portable Data File
  • MicroQRCode - Compact QR variant

Specialized Formats​

  • Postal Codes: Postnet, Planet, RM4SCC, Australia Post
  • Intelligent Mail: USPS Intelligent Mail barcodes
  • PharmaCode: Pharmaceutical barcodes
  • RSS Codes: Reduced Space Symbology

REST API Endpoint​

The PDF4me REST API uses standard HTTP methods to interact with resources. All barcode reading operations are performed through a single endpoint:

  • Method: POST
  • Endpoint: /api/v2/ReadBarcodes

REST API Parameters​

Complete list of parameters for the Read Barcode from PDF REST API. Parameters are organized by category for better understanding and implementation.

Important: Parameters marked with an asterisk (*) are required and must be provided for the API to function correctly.

ParameterRequiredWhat it doesExample
jobIdExtOptionalYour own reference for this call. It is stored with the API call log so you can correlate calls with your jobs. Type: string.
integrationsOptionalIntegration identifiers, forwarded unchanged with the job's notification settings. Type: array.
isAsyncOptionalSet to `true` to process the action asynchronously and get a job to poll at `/api/v2/GetActionStatus`. Only honoured by actions that support asynchronous processing. Type: boolean.true
docNameOptionalSource file name including its extension. Several actions dispatch on the extension, so it should always be set; when omitted a per-action default is used. Type: string.document.pdf
docContentRequiredThe source file. Accepts the base64-encoded file content, a `pdf4meblobid://<id>` reference to a previously uploaded blob, or an `https` URL to the source document. Required: an empty value fails with `File is empty`. Type: string.JVBERi...
docContentBytesOptionalAlternative raw byte payload for the source file. Type: string.
callBackUrlOptionalOptional URL notified when an asynchronous job completes. Type: string.
barcodeTypeOptionalBarcode types to look for, e.g. `["qrCode"]` or `["dataMatrix","code128"]`. With one entry an unknown type is rejected with 400; with several, unknown entries are skipped. Empty or no valid entry searches all types. Type: array.["all"]
pagesOptionalPages to scan, e.g. `all`, `1`, `1,3,5`, `2-5` or `2-` (2 to the last page). Type: string.all

Output​

The PDF4me Read Barcode from PDF REST API returns different responses based on the processing mode. The API returns structured JSON data with barcode information.

Synchronous Processing (Default)

When IsAsync is not set or set to false, the API processes the request immediately:

Status Code: 200 OK

Content-Type: application/json

Response Body:

{
"barcodes": [
{
"type": "qrCode",
"text": "Barcode content",
"page": 1,
"x": 100,
"y": 200,
"width": 50,
"height": 50
}
]
}

Response Fields:

  • barcodes (array): Array of detected barcode objects
    • type (string): Barcode type (e.g., "qrCode", "dataMatrix", "code128")
    • text (string): Extracted barcode content/text
    • page (number): Page number where barcode was found
    • x (number): X coordinate of barcode position
    • y (number): Y coordinate of barcode position
    • width (number): Width of the barcode
    • height (number): Height of the barcode

Example (JavaScript):

const response = await fetch(url, options);
const data = await response.json();
data.barcodes.forEach(barcode => {
console.log(`Found ${barcode.type}: ${barcode.text} on page ${barcode.page}`);
});

Request Example​

Content-Type: application/json
Authorization: Basic YOUR_BASE64_ENCODED_API_KEY

Note:

  • Get your API key from the PDF4me Dashboard
  • The API key must be Base64 encoded and prefixed with "Basic " in the Authorization header
  • Example: If your API key is abc123, encode it to Base64 and use Authorization: Basic YWJjMTIz

Payload​

Example:

{
"docContent": "JVBERi0xLjQKJeLjz9MKMSAwIG9iago8PAovVHlwZSAvQ2F0YWxvZwovUGFnZXMgMiAwIFIKPj4KZW5kb2JqCjIgMCBvYmoKPDwKL1R5cGUgL1BhZ2VzCi9LaWRzIFszIDAgUl0KL0NvdW50IDEKPD4KZW5kb2JqCjMgMCBvYmoKPDwKL1R5cGUgL1BhZ2UKL1BhcmVudCAyIDAgUgovTWVkaWFCb3ggWzAgMCA2MTIgNzkyXQovUmVzb3VyY2VzIDw8Ci9Gb250IDw8Ci9GMSA0IDAgUgo+Pgo+PgovQ29udGVudHMgNSAwIFIKPj4KZW5kb2JqCjQgMCBvYmoKPDwKL1R5cGUgL0ZvbnQKL1N1YnR5cGUgL1R5cGUxCi9CYXNlRm9udCAvSGVsdmV0aWNhCj4+CmVuZG9iago1IDAgb2JqCjw8Ci9MZW5ndGggNDQKPj4Kc3RyZWFtCkJUCi9GMSAxMiBUZgoxMDAgNzAwIFRkCihIZWxsbyBXb3JsZCkgVGoKRVQKZW5kc3RyZWFtCmVuZG9iagp4cmVmCjAgNgowMDAwMDAwMDAwIDY1NTM1IGYgCjAwMDAwMDAwMDkgMDAwMDAgbiAKMDAwMDAwMDA1NCAwMDAwMCBuIAowMDAwMDAwMTAxIDAwMDAwIG4gCjAwMDAwMDAxNzAgMDAwMDAgbiAKMDAwMDAwMDI0NCAwMDAwMCBuIAp0cmFpbGVyCjw8Ci9TaXplIDYKL1Jvb3QgMSAwIFIKPj4Kc3RhcnR4cmVmCjM0MQolJUVPRg==",
"docName": "document.pdf",
"barcodeType": ["all"],
"pages": "all",
"IsAsync": true
}

Code Samples​

The PDF4me Read Barcode from PDF REST API provides code samples in multiple programming languages. Choose the language that best fits your development environment:

C# (CSharp) Sample

Complete C# implementation for reading barcodes from PDF documents:

Industry Use Cases & Applications​

Finance & Banking Use Cases

  • Invoice Processing: Extract barcode data from invoices for automated payment processing
  • Financial Documents: Process financial documents with barcodes for payment processing
  • Payment Processing: Extract payment information from barcodes in financial documents
  • Banking Integration: Integrate barcode reading into banking applications and systems

Barcode Recognition Features​

Detection Capabilities​

  • Multi-format Support: Recognition of 1D and 2D barcodes in various formats
  • Position Tracking: Accurate barcode location and positioning data with coordinates
  • Page Selection: Process specific pages or entire documents using page options

Processing Features​

  • Batch Recognition: Extract multiple barcodes from single or multiple pages
  • Type Filtering: Specify which barcode types to detect using the barcodeType array
  • Structured Output: Returns barcode data with type, text, page, and position information

Get Help​