Create Barcode - QR Code Generator API
PDF4me Create Barcode enables you to create standalone barcode and QR code images with support for 150+ barcode types including QR codes, Code128, DataMatrix, Aztec, Hanxin, PDF417, and specialized formats. This API service generates compliant barcode images optimized for printing, mobile scanning, and digital applications. The API receives text data and barcode parameters through REST API calls, utilizing Base64 encoding for secure transmission. This solution is ideal for inventory management systems, product labeling automation, and enterprise barcode generation workflows.
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 Library: 150+ barcode types including QR codes, Code128, DataMatrix, Aztec, Hanxin, PDF417, postal codes, and specialized industry symbologies using Barcode Type parameter
- Standalone Image Generation: Create high-quality barcode images independently without requiring existing documents or templates through File Name specification
- Advanced Text Management: Configure barcode text display, positioning, and visibility with professional formatting options for clean presentation using Text parameter
- Enterprise Integration: Simple API with minimal parameters designed for seamless integration into existing business systems and workflows with proper parameter mapping
REST API Endpoint
The PDF4me REST API uses standard HTTP methods to interact with resources. All barcode generation operations are performed through a single endpoint:
- Method: POST
- Endpoint:
/api/v2/CreateBarcode
Supported Barcode Types
Supports 150+ barcode types for comprehensive barcode generation based on the JSON specification.
Popular 1D Barcodes
- Code128 - Universal barcode (255 chars max) using Barcode Type parameter
- Code39 - Alphanumeric barcode (43 chars max) through Text parameter
- EAN13/EAN8 - Retail product codes (13/8 chars) with File Name specification
- UPC-A/UPC-E - North American retail (12/8 chars) using API integration
Popular 2D Barcodes
- QR Code - Mobile scanning (4,296 chars max) using Barcode Type parameter
- DataMatrix - High-density 2D (2,335 chars max) through Text parameter
- PDF417 - Large data capacity (2,710 chars max) with File Name specification
- Aztec - Excellent error correction (3,832 chars max) using API integration
Specialized Formats
- Postal Codes: USPS, Royal Mail, Australia Post, Deutsche Post using Barcode Type parameter
- Healthcare: HIBC, GS1 DataBar, Pharmacode through Text parameter
- Logistics: MaxiCode, SSCC-18, ITF-14, GS1-128 with File Name specification
- QR Variants: Micro QR, iQR, rMQR using API integration
REST API Parameters
Complete list of parameters for the Create Barcode 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.
Required Parameters
| Parameter | Type | Description | Example |
|---|---|---|---|
| text* | String | Text to be encoded in the barcode. Text length depends on barcode type | PDF4me Create Barcode Sample |
| barcodeType* | String | Barcode format type. Options: qrCode, code128, dataMatrix, aztec, hanXin, pdf417, code39, ean13, ean8, upcA, upcE | qrCode |
| hideText* | Boolean | Hide barcode text label (true=hide, false=show text alongside barcode) | false |
| async* | Boolean | Enable asynchronous processing. When true, the API returns a 202 status and provides a polling URL in the Location header | true |
Output
The PDF4me Create Barcode REST API returns different responses based on the processing mode. The API returns the barcode as a binary image file (PNG format), not as JSON.
- Success Response
- Asynchronous Processing
- Error Responses
- Response Format Details
Synchronous Processing (Default)
When async is not set or set to false, the API processes the request immediately:
Status Code: 200 OK
Content-Type: image/png (or appropriate image format)
Response Body: The response body contains the barcode image as binary data (PNG format by default).
How to Use:
- Read the response body as binary data
- Save the binary data as an image file (e.g., .png, .jpg)
- Use the image file as needed
Example (JavaScript):
const response = await fetch(url, options);
const blob = await response.blob();
const url = URL.createObjectURL(blob);
// Use the URL to display or download the image
Example (Python):
response = requests.post(url, json=payload, headers=headers)
if response.status_code == 200:
with open('barcode.png', 'wb') as f:
f.write(response.content)
Asynchronous Processing
When async: true is set, the API processes the request asynchronously:
Status Code: 202 Accepted
Response Headers:
Location: https://api.pdf4me.com/api/v2/CreateBarcode/poll/12345-abcde-67890
Polling Process:
- Extract the
Locationheader from the 202 response - Poll the URL using GET requests
- Continue polling until you receive a 200 OK status
- The final response contains the barcode image as binary data (PNG format)
Polling Example:
// Initial request returns 202 with Location header
const response = await fetch(url, options);
const location = response.headers.get('Location');
// Poll until complete
while (true) {
const pollResponse = await fetch(location, { headers: { 'Authorization': 'Basic ' + apiKey } });
if (pollResponse.status === 200) {
const blob = await pollResponse.blob();
// Process blob (barcode image)
break;
}
await new Promise(resolve => setTimeout(resolve, 2000)); // Wait 2 seconds
}
Error Responses
The API returns standard HTTP error codes with error details:
- Invalid request parameters
- Missing required fields (
text,barcodeType,hideText,async) - Invalid barcode type
- Text length exceeds barcode type capacity
- Invalid or missing API key
- API key not properly Base64 encoded in Authorization header
- Missing
Authorization: Basicheader
- Server-side processing error
- Barcode generation failure
Error Response Format:
{
"error": "Error message describing what went wrong"
}
Response Format Details
Important: The API returns binary image data (PNG format by default), not JSON.
Response Structure:
- Content-Type:
image/png(or appropriate image MIME type) - Response Body: Binary image data
Image Format:
- Default format: PNG
- The barcode image is ready for direct use, download, or integration
Saving the Image:
JavaScript/Node.js:
const response = await fetch(url, options);
const blob = await response.blob();
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'barcode.png';
a.click();
Python:
response = requests.post(url, json=payload, headers=headers)
if response.status_code == 200:
with open('barcode.png', 'wb') as f:
f.write(response.content)
C#:
var response = await httpClient.PostAsync(url, content);
if (response.IsSuccessStatusCode)
{
var imageBytes = await response.Content.ReadAsByteArrayAsync();
await File.WriteAllBytesAsync("barcode.png", imageBytes);
}
Request Example
Header
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 useAuthorization: Basic YWJjMTIz
Payload
Example:
{
"text": "PDF4me Create Barcode Sample",
"barcodeType": "qrCode",
"hideText": false,
"async": true
}
Code Samples
The PDF4me Create Barcode REST API provides code samples in multiple programming languages. Choose the language that best fits your development environment:
- C#
- Java
- JavaScript
- Python
- Salesforce
- n8n
- Google Script
- AWS Lambda
Google Script Sample
Google Apps Script implementation for Google Workspace integration:
Industry Use Cases & Applications
- E-commerce & Retail
- Logistics & Shipping
- Healthcare & Medical
- Government & Compliance
- Education & Libraries
- Business & Finance
E-commerce & Retail Use Cases
- Product Labels: Generate standalone barcode images for product packaging and labels using Barcode Type parameter
- Price Tags: Create barcode images for dynamic pricing and automated checkout systems through Text parameter
- Inventory Management: Generate barcode images for warehouse management and stock control with File Name specification
- Product Catalogs: Create barcode images for product identification and catalog systems using API integration
Logistics & Shipping Use Cases
- Shipping Labels: Generate standalone barcode images for package tracking and delivery using Barcode Type parameter
- Package Identification: Create unique barcode images for each shipment across supply chains through Text parameter
- Warehouse Systems: Generate barcode images for bin locations and inventory tracking with File Name specification
- Supply Chain: Create barcode images for product tracking through distribution networks using API integration
Healthcare & Medical Use Cases
- Patient Identification: Generate barcode images for patient wristbands and medical records using Barcode Type parameter
- Medication Tracking: Create barcode images for drug identification and dosage verification through Text parameter
- Equipment Management: Generate barcode images for medical equipment and asset tracking with File Name specification
- Lab Sample Tracking: Create barcode images for test samples and result identification using API integration
Government & Compliance Use Cases
- ID Documents: Generate barcode images for driver's licenses, passports, and identification cards using Barcode Type parameter
- Form Processing: Create barcode images for tax forms and compliance documentation through Text parameter
- Document Tracking: Generate barcode images for regulatory tracking and audit trails with File Name specification
- Public Records: Create barcode images for government document identification systems using API integration
Education & Libraries Use Cases
- Student Cards: Generate barcode images for student identification and campus access using Barcode Type parameter
- Library Systems: Create barcode images for book identification and checkout systems through Text parameter
- Exam Security: Generate barcode images for test document identification and integrity with File Name specification
- Campus Services: Create barcode images for equipment and resource tracking using API integration
Business & Finance Use Cases
- Invoice Systems: Generate barcode images for automated invoice processing and payment using Barcode Type parameter
- Document Management: Create barcode images for business document identification through Text parameter
- Asset Tracking: Generate barcode images for equipment and asset management systems with File Name specification
- Compliance Documentation: Create barcode images for audit trails and financial records using API integration