Implementing Barcode Generation
When to Use This Skill
Use this skill when you need to:
- Create linear barcodes (Code39, Code128, Code11, Codabar, Code32, Code93) for product identification and inventory management
- Generate QR codes for URLs, contact info, and quick data sharing
- Encode Data Matrix codes for compact, high-density encoding (healthcare, logistics)
- Customize barcode appearance (colors, dimensions, display text, logos)
- Export barcodes as image files (PNG, JPG) or base64 strings
- Add logos to QR codes for branding and visual enhancement
Important: API Verification Required
API Verification Required: Always verify API class names, properties, and signatures by reading reference files (references/*.md) BEFORE generating code examples. Do not assume or infer class names.
Real-world scenarios:
- Product labeling systems for retail/inventory
- Mobile payment & authentication (QR codes)
- Healthcare/pharmaceutical tracking (Data Matrix)
- Document management & archiving
- Marketing campaigns using branded QR codes
Component Overview
The Syncfusion Angular Barcode Generator supports three barcode families with extensive customization:
Barcode Types
| Type |
Use Case |
Character Set |
Industry |
| Linear (Code39, Code128, Code11, Codabar, Code32, Code93) |
Product IDs, serial numbers, inventory |
Alphanumeric (varies by type) |
Retail, Warehouse, Telecom |
| QR Code |
URLs, contact info, payments |
Full Unicode |
Marketing, Mobile, Finance |
| Data Matrix |
Compact encoding, small labels |
Numeric/Alphanumeric |
Healthcare, Manufacturing, Logistics |
Key Capabilities
- ✅ 7 linear barcode types with symbol validation
- ✅ Full customization (colors, dimensions, fonts, margins)
- ✅ Logo support for QR codes via
QRCodeLogo
- ✅ Multiple export formats (PNG, JPG, Base64)
- ✅ Automatic version selection for QR codes
- ✅ Display text customization below barcodes
Documentation & Navigation Guide
Getting Started
📄 Read: references/getting-started.md
- Installation & package setup (
@syncfusion/ej2-angular-barcode-generator)
- Ivy vs ngcc package selection
- Basic component setup & imports
- Creating first Code128 barcode & QR code
- Project configuration & CSS
Linear Barcodes (Code39, Code128, etc.)
📄 Read: references/linear-barcodes.md
- Code39 (standard alphanumeric)
- Code39 Extended (full ASCII support)
- Code128 (high-density encoding with 3 character sets)
- Code11 (telecommunications)
- Codabar (libraries, blood banks)
- Code32 (pharmaceutical/cosmetics)
- Code93 & Code93 Extended
- Character set limitations & validation
- When to choose each type
QR Codes
📄 Read: references/qr-codes.md
- QR code versions (1-40) & capacity
- Basic QR code generation
- Color customization (foreColor, backgroundColor)
- Dimension control (width, height)
- Display text below QR code
- Adding logos & icons (
QRCodeLogo with imageSource)
- Logo positioning & sizing
- Image sources (local files, URLs, base64)
- Error correction levels
Data Matrix Codes
📄 Read: references/data-matrix-barcodes.md
- Data Matrix overview & advantages
- Use cases (healthcare, logistics, compact encoding)
- Square vs rectangular symbols
- Dimension customization
- Color & appearance options
- Display text configuration
- When to use vs QR codes
Customization & Styling
📄 Read: references/customization.md
- Shared customization properties (all barcode types)
- Color customization (foreColor, backgroundColor)
- Dimensions & scaling (width, height)
- Margins & padding
- Display text properties & positioning
- CSS class customization
- Responsive barcode sizing
- Advanced styling across all types
Exporting Barcodes
📄 Read: references/exporting-barcodes.md
- Export as image file (PNG, JPG)
- Export as base64 string
- Download functionality & file naming
- Integration with backend systems
- Use cases (printing, storage, sharing)
Quick Start Example
Basic Code128 Barcode
<!-- app.component.html -->
<ejs-barcodegenerator
#barcode
type="Code128"
value="123456789"
width="200px"
height="150px">
</ejs-barcodegenerator>
// app.component.ts
import { Component } from '@angular/core';
import { BarcodeGeneratorComponent } from '@syncfusion/ej2-angular-barcode-generator';
@Component({
selector: 'app-root',
templateUrl: './app.component.html'
})
export class AppComponent {}
QR Code with Custom Color
<ejs-barcodegenerator
type="QRCode"
value="https://example.com"
[foreColor]="'#FF0000'"
width="200px"
height="200px">
</ejs-barcodegenerator>
Common Patterns
Pattern 1: Choose Barcode Type by Use Case
User needs to encode:
- Product/inventory? → Code128 (high-density, retail standard)
- Legacy system? → Code39 (widely supported)
- Pharmaceutical? → Code32 (industry standard)
- URL/contact? → QR Code (compact, mobile-friendly)
- Small label? → Data Matrix (high-density, space-efficient)
Pattern 2: Customize for Different Backgrounds
// Light background
@barcode type="Code128" foreColor="#000000" backgroundColor="#FFFFFF"
// Dark background
@barcode type="Code128" foreColor="#FFFFFF" backgroundColor="#000000"
// Branded QR code
@barcode type="QRCode" [qRCodeLogo]="logoConfig" foreColor="#1976D2"
Pattern 3: Export & Download
export class BarcodeComponent {
@ViewChild('barcode') barcode: BarcodeGeneratorComponent;
downloadBarcode() {
this.barcode.exportImage('barcode','PNG');
}
getBase64() {
const base64String = this.barcode.toDataURL('image/png');
// Send to server or store
}
}
Pattern 4: Branded QR Codes with Logo
<ejs-barcodegenerator
type="QRCode"
value="https://mysite.com"
#qrCode>
</ejs-barcodegenerator>
export class BrandedQRComponent implements OnInit {
@ViewChild('qrCode') qrCode: BarcodeGeneratorComponent;
ngOnInit() {
(this.qrCode.qrcodelogo as QRCodeLogo) = {
imageSource: 'assets/logo.svg',
width: 50,
height: 50
};
}
}
Key Props Summary
| Property |
Type |
Use When |
Default |
type |
string |
Selecting barcode type (Code128, QRCode, DataMatrix) |
Code128 |
value |
string |
Setting encoded data |
"" |
width |
string |
Controlling barcode width (px, %) |
Auto |
height |
string |
Controlling barcode height (px, %) |
Auto |
foreColor |
string |
Setting barcode color (#RGB or name) |
#000000 |
backgroundColor |
string |
Setting background color |
#FFFFFF |
displayText |
object |
{ visibility: false } |
Adding human-readable label below barcode |
margin |
object |
Adding space around barcode |
{left: 0, right: 0, top: 0, bottom: 0} |
qRCodeLogo |
object |
Adding logo to QR code (imageSource, width, height) |
undefined |
mode |
string |
Rendering mode (SVG or Canvas) |
SVG |
Common Use Cases
Use Case 1: Retail Product Labeling System
// Create multiple product barcodes with customization
products.forEach(product => {
<ejs-barcodegenerator
type="Code128"
[value]="product.sku"
[displayText]="{ text: 'Product SKU: 123456789', visibility: true }"
foreColor="#333333"
width="150px"
height="100px">
</ejs-barcodegenerator>
});
Use Case 2: Mobile QR Code with Branding
// QR code for app promotion with branded logo
<ejs-barcodegenerator
type="QRCode"
value="https://appstore.com/myapp"
[qRCodeLogo]="{ imageSource: 'assets/app-icon.png', width: 40, height: 40 }"
[foreColor]="'#1976D2'"
width="250px"
height="250px">
</ejs-barcodegenerator>
Use Case 3: Healthcare Tracking with Data Matrix
// Compact Data Matrix for pharmaceutical packaging
<ejs-barcodegenerator
type="DataMatrix"
[value]="medicineTrackingCode"
[displayText]="{ text: 'Product SKU: 123456789', visibility: true }"
width="80px"
height="80px">
</ejs-barcodegenerator>
Next Steps
- Start with getting-started.md to install the package
- Choose your barcode type guide based on use case
- Customize using customization.md
- Export barcodes using exporting-barcodes.md
1---2name: syncfusion-angular-barcode3description: Use Syncfusion EJ2 Angular Barcode/QR components to generate and customize barcodes in Angular. Trigger for Code39/Code128, EAN/UPC, QR Code, Data Matrix, label printing, inventory/product tags, colors/sizing/text, logo overlays, rendering, and export (PNG/SVG/PDF).4---56# Implementing Barcode Generation78## When to Use This Skill910Use this skill when you need to:11- **Create linear barcodes** (Code39, Code128, Code11, Codabar, Code32, Code93) for product identification and inventory management12- **Generate QR codes** for URLs, contact info, and quick data sharing13- **Encode Data Matrix codes** for compact, high-density encoding (healthcare, logistics)14- **Customize barcode appearance** (colors, dimensions, display text, logos)15- **Export barcodes** as image files (PNG, JPG) or base64 strings16- **Add logos to QR codes** for branding and visual enhancement1718## Important: API Verification Required19 20**API Verification Required**: Always verify API class names, properties, and signatures by reading reference files (`references/*.md`) BEFORE generating code examples. Do not assume or infer class names.2122**Real-world scenarios:**23- Product labeling systems for retail/inventory24- Mobile payment & authentication (QR codes)25- Healthcare/pharmaceutical tracking (Data Matrix)26- Document management & archiving27- Marketing campaigns using branded QR codes2829---3031## Component Overview3233The Syncfusion Angular Barcode Generator supports three barcode families with extensive customization:3435### Barcode Types3637| Type | Use Case | Character Set | Industry |38|------|----------|---------------|----------|39| **Linear (Code39, Code128, Code11, Codabar, Code32, Code93)** | Product IDs, serial numbers, inventory | Alphanumeric (varies by type) | Retail, Warehouse, Telecom |40| **QR Code** | URLs, contact info, payments | Full Unicode | Marketing, Mobile, Finance |41| **Data Matrix** | Compact encoding, small labels | Numeric/Alphanumeric | Healthcare, Manufacturing, Logistics |4243### Key Capabilities4445- ✅ **7 linear barcode types** with symbol validation46- ✅ **Full customization** (colors, dimensions, fonts, margins)47- ✅ **Logo support** for QR codes via `QRCodeLogo`48- ✅ **Multiple export formats** (PNG, JPG, Base64)49- ✅ **Automatic version selection** for QR codes50- ✅ **Display text** customization below barcodes5152---5354## Documentation & Navigation Guide5556### Getting Started57📄 **Read:** [references/getting-started.md](references/getting-started.md)58- Installation & package setup (`@syncfusion/ej2-angular-barcode-generator`)59- Ivy vs ngcc package selection60- Basic component setup & imports61- Creating first Code128 barcode & QR code62- Project configuration & CSS6364### Linear Barcodes (Code39, Code128, etc.)65📄 **Read:** [references/linear-barcodes.md](references/linear-barcodes.md)66- Code39 (standard alphanumeric)67- Code39 Extended (full ASCII support)68- Code128 (high-density encoding with 3 character sets)69- Code11 (telecommunications)70- Codabar (libraries, blood banks)71- Code32 (pharmaceutical/cosmetics)72- Code93 & Code93 Extended73- Character set limitations & validation74- When to choose each type7576### QR Codes77📄 **Read:** [references/qr-codes.md](references/qr-codes.md)78- QR code versions (1-40) & capacity79- Basic QR code generation80- Color customization (foreColor, backgroundColor)81- Dimension control (width, height)82- Display text below QR code83- Adding logos & icons (`QRCodeLogo` with `imageSource`)84- Logo positioning & sizing85- Image sources (local files, URLs, base64)86- Error correction levels8788### Data Matrix Codes89📄 **Read:** [references/data-matrix-barcodes.md](references/data-matrix-barcodes.md)90- Data Matrix overview & advantages91- Use cases (healthcare, logistics, compact encoding)92- Square vs rectangular symbols93- Dimension customization94- Color & appearance options95- Display text configuration96- When to use vs QR codes9798### Customization & Styling99📄 **Read:** [references/customization.md](references/customization.md)100- Shared customization properties (all barcode types)101- Color customization (foreColor, backgroundColor)102- Dimensions & scaling (width, height)103- Margins & padding104- Display text properties & positioning105- CSS class customization106- Responsive barcode sizing107- Advanced styling across all types108109### Exporting Barcodes110📄 **Read:** [references/exporting-barcodes.md](references/exporting-barcodes.md)111- Export as image file (PNG, JPG)112- Export as base64 string113- Download functionality & file naming114- Integration with backend systems115- Use cases (printing, storage, sharing)116117---118119## Quick Start Example120121### Basic Code128 Barcode122123```html124<!-- app.component.html -->125<ejs-barcodegenerator 126 #barcode127 type="Code128" 128 value="123456789" 129 width="200px" 130 height="150px">131</ejs-barcodegenerator>132```133134```typescript135// app.component.ts136import { Component } from '@angular/core';137import { BarcodeGeneratorComponent } from '@syncfusion/ej2-angular-barcode-generator';138139@Component({140 selector: 'app-root',141 templateUrl: './app.component.html'142})143export class AppComponent {}144```145146### QR Code with Custom Color147148```html149<ejs-barcodegenerator 150 type="QRCode" 151 value="https://example.com" 152 [foreColor]="'#FF0000'"153 width="200px" 154 height="200px">155</ejs-barcodegenerator>156```157158---159160## Common Patterns161162### Pattern 1: Choose Barcode Type by Use Case163164**User needs to encode:**165- Product/inventory? → **Code128** (high-density, retail standard)166- Legacy system? → **Code39** (widely supported)167- Pharmaceutical? → **Code32** (industry standard)168- URL/contact? → **QR Code** (compact, mobile-friendly)169- Small label? → **Data Matrix** (high-density, space-efficient)170171### Pattern 2: Customize for Different Backgrounds172173```typescript174// Light background175@barcode type="Code128" foreColor="#000000" backgroundColor="#FFFFFF"176177// Dark background178@barcode type="Code128" foreColor="#FFFFFF" backgroundColor="#000000"179180// Branded QR code181@barcode type="QRCode" [qRCodeLogo]="logoConfig" foreColor="#1976D2"182```183184### Pattern 3: Export & Download185186```typescript187export class BarcodeComponent {188 @ViewChild('barcode') barcode: BarcodeGeneratorComponent;189 190 downloadBarcode() {191 this.barcode.exportImage('barcode','PNG');192 }193194 getBase64() {195 const base64String = this.barcode.toDataURL('image/png');196 // Send to server or store197 }198}199```200201### Pattern 4: Branded QR Codes with Logo202203```html204<ejs-barcodegenerator 205 type="QRCode" 206 value="https://mysite.com"207 #qrCode>208</ejs-barcodegenerator>209```210211```typescript212export class BrandedQRComponent implements OnInit {213 @ViewChild('qrCode') qrCode: BarcodeGeneratorComponent;214 215 ngOnInit() {216 (this.qrCode.qrcodelogo as QRCodeLogo) = {217 imageSource: 'assets/logo.svg',218 width: 50,219 height: 50220 };221 }222}223```224225---226227## Key Props Summary228229| Property | Type | Use When | Default |230|----------|------|----------|---------|231| `type` | string | Selecting barcode type (Code128, QRCode, DataMatrix) | Code128 |232| `value` | string | Setting encoded data | "" |233| `width` | string | Controlling barcode width (px, %) | Auto |234| `height` | string | Controlling barcode height (px, %) | Auto |235| `foreColor` | string | Setting barcode color (#RGB or name) | #000000 |236| `backgroundColor` | string | Setting background color | #FFFFFF |237| `displayText` | object | `{ visibility: false }` | Adding human-readable label below barcode | "" |238| `margin` | object | Adding space around barcode | {left: 0, right: 0, top: 0, bottom: 0} |239| `qRCodeLogo` | object | Adding logo to QR code (imageSource, width, height) | undefined |240| `mode` | string | Rendering mode (SVG or Canvas) | SVG |241242---243244## Common Use Cases245246### Use Case 1: Retail Product Labeling System247248```typescript249// Create multiple product barcodes with customization250products.forEach(product => {251 <ejs-barcodegenerator 252 type="Code128"253 [value]="product.sku"254 [displayText]="{ text: 'Product SKU: 123456789', visibility: true }"255 foreColor="#333333"256 width="150px"257 height="100px">258 </ejs-barcodegenerator>259});260```261262### Use Case 2: Mobile QR Code with Branding263264```typescript265// QR code for app promotion with branded logo266<ejs-barcodegenerator 267 type="QRCode"268 value="https://appstore.com/myapp"269 [qRCodeLogo]="{ imageSource: 'assets/app-icon.png', width: 40, height: 40 }"270 [foreColor]="'#1976D2'"271 width="250px"272 height="250px">273</ejs-barcodegenerator>274```275276### Use Case 3: Healthcare Tracking with Data Matrix277278```typescript279// Compact Data Matrix for pharmaceutical packaging280<ejs-barcodegenerator 281 type="DataMatrix"282 [value]="medicineTrackingCode"283 [displayText]="{ text: 'Product SKU: 123456789', visibility: true }"284 width="80px"285 height="80px">286</ejs-barcodegenerator>287```288289---290291## Next Steps292293- Start with [getting-started.md](references/getting-started.md) to install the package294- Choose your barcode type guide based on use case295- Customize using [customization.md](references/customization.md)296- Export barcodes using [exporting-barcodes.md](references/exporting-barcodes.md)