🏷️ Barcode Generator Pro

Create professional barcodes with advanced customization and download options

⚙️ Generator Settings

2.0
100px
12px

👁️ Live Preview

0
Generated
0
Downloads

📜 Recent Barcodes

No barcodes generated yet

${svgData} `); printWindow.document.close(); printWindow.focus(); setTimeout(() => printWindow.print(), 500); showToast('Print dialog opened!'); } function copyToClipboard() { const svg = document.getElementById('barcode'); if (!svg.innerHTML) { showToast('Please generate a barcode first', 'error'); return; } const svgData = new XMLSerializer().serializeToString(svg); navigator.clipboard.writeText(svgData).then(() => { showToast('Barcode SVG copied to clipboard!'); }).catch(() => { showToast('Failed to copy to clipboard', 'error'); }); } function clearForm() { document.getElementById('barcodeText').value = ''; document.getElementById('barcodeFormat').value = 'CODE128'; document.getElementById('barcodeWidth').value = '2'; document.getElementById('barcodeHeight').value = '100'; document.getElementById('lineColor').value = '#000000'; document.getElementById('backgroundColor').value = '#ffffff'; document.getElementById('displayValue').checked = true; document.getElementById('fontSize').value = '12'; updateRangeDisplay(); document.getElementById('barcode').innerHTML = ''; document.getElementById('barcodeInfo').textContent = ''; document.getElementById('textError').style.display = 'none'; lastHistoryText = ''; // Reset history tracking clearTimeout(debounceTimer); // Clear any pending timer } function addToHistory(text, format, options) { const historyItem = { text: text, format: format, options: options, timestamp: new Date().toLocaleString() }; history.unshift(historyItem); if (history.length > 10) history.pop(); // Keep only last 10 localStorage.setItem('barcodeHistory', JSON.stringify(history)); updateHistory(); } function updateHistory() { const historyList = document.getElementById('historyList'); if (history.length === 0) { historyList.innerHTML = '

No barcodes generated yet

'; return; } historyList.innerHTML = history.map((item, index) => `
${item.text} (${item.format})
${item.timestamp}
`).join(''); } function loadFromHistory(index) { const item = history[index]; document.getElementById('barcodeText').value = item.text; document.getElementById('barcodeFormat').value = item.format; document.getElementById('barcodeWidth').value = item.options.width; document.getElementById('barcodeHeight').value = item.options.height; document.getElementById('lineColor').value = item.options.lineColor; document.getElementById('backgroundColor').value = item.options.background; document.getElementById('displayValue').checked = item.options.displayValue; document.getElementById('fontSize').value = item.options.fontSize; updateRangeDisplay(); generateBarcode(false); // Don't add to history when loading from history lastHistoryText = item.text; // Update the tracking variable showToast('Loaded from history!'); } function clearHistory() { history = []; localStorage.removeItem('barcodeHistory'); updateHistory(); showToast('History cleared!'); } function loadStats() { const savedStats = localStorage.getItem('barcodeStats'); if (savedStats) { stats = JSON.parse(savedStats); } updateStats(); } function saveStats() { localStorage.setItem('barcodeStats', JSON.stringify(stats)); } function updateStats() { document.getElementById('totalGenerated').textContent = stats.generated; document.getElementById('totalDownloads').textContent = stats.downloads; } function showToast(message, type = 'success') { const toast = document.getElementById('toast'); toast.textContent = message; toast.className = `toast ${type === 'error' ? 'toast-error' : ''}`; toast.classList.add('show'); setTimeout(() => { toast.classList.remove('show'); }, 3000); } function toggleTheme() { const currentTheme = document.documentElement.getAttribute('data-theme'); const newTheme = currentTheme === 'dark' ? 'light' : 'dark'; document.documentElement.setAttribute('data-theme', newTheme); localStorage.setItem('theme', newTheme); const themeToggle = document.querySelector('.theme-toggle'); themeToggle.textContent = newTheme === 'dark' ? '☀️' : '🌙'; } function loadTheme() { const savedTheme = localStorage.getItem('theme') || 'light'; document.documentElement.setAttribute('data-theme', savedTheme); const themeToggle = document.querySelector('.theme-toggle'); themeToggle.textContent = savedTheme === 'dark' ? '☀️' : '🌙'; }