100% Client-Side • Auto-Save
Informações Pessoais & Perfil
Clique ou arraste uma foto
Banner de fundo superior
Contatos & Comunicação
Chave PIX (Pagamentos Rápidos)
Exibir botão de PIX no cartão
Redes Sociais & Portfólios
Links Personalizados Livres (Custom Links)

Adicione botões extras com links de agendamento (Calendly), cardápios, PDFs, catálogos ou rotas.

QR Code & vCard (Agenda do Celular)
Exibir QR Code no corpo do cartão
Aparência, Temas & Tipografia
Fundo 1
Fundo 2
Acento
Texto

Exportação & Compartilhamento

Ultra-HD • 300 DPI
RENDERIZAÇÃO EM TEMPO REAL

Seu Nome

Sua Profissão ou Cargo

4U.IA.BR // LABS

Breve descrição profissional de impacto.

Aponte a câmera para salvar o contato
Seu Nome
Engenheiro de Software
4U.IA.BR LABS
Seu Nome
Arquiteturas soberanas e inovação
Aponte a câmera do celular para adicionar instantaneamente à sua agenda.
Clique no cartão para virar Frente ↔ Verso (85×55 mm Gráfica)
Operação realizada com sucesso!
`; const blob = new Blob([htmlContent], { type: 'text/html;charset=utf-8' }); const url = URL.createObjectURL(blob); const a = document.createElement('a'); a.href = url; a.download = `${nome.replace(/\s+/g, '_').toLowerCase()}_cartao.html`; a.click(); URL.revokeObjectURL(url); showToast('Página HTML exportada com sucesso!'); } // Unified Robust Canvas Capture with Stacking Context Enforcement async function captureCardCanvas(element, scale = 3) { return await html2canvas(element, { scale: scale, useCORS: true, logging: false, backgroundColor: null, onclone: (clonedDoc) => { // Force avatar images and rings to strict stacking order so gradients never cover avatars const av = clonedDoc.getElementById('previewAvatar'); if (av) { av.style.position = 'relative'; av.style.zIndex = '10'; } const ring = clonedDoc.getElementById('previewAvatarRing'); if (ring) { ring.style.position = 'relative'; ring.style.zIndex = '1'; } const physAv = clonedDoc.getElementById('physAvatarFront'); if (physAv) { physAv.style.position = 'relative'; physAv.style.zIndex = '10'; } } }); } // 2. Export PDF with Clickable Links via jsPDF async function exportPDFDocument() { const { jsPDF } = window.jspdf; const nome = document.getElementById('inputNome').value.trim() || 'fbr4g4'; showToast('Processando PDF em alta definição...'); try { const isPhysical = (cardMode === 'physical'); if (isPhysical) { const frontEl = document.getElementById('cardPhysicalFront'); const backEl = document.getElementById('cardPhysicalBack'); const origFrontDisplay = frontEl.style.display; const origBackDisplay = backEl.style.display; // 1. Capture Front Side frontEl.style.display = 'flex'; backEl.style.display = 'none'; const canvasFront = await captureCardCanvas(frontEl, 3); // 2. Capture Back Side frontEl.style.display = 'none'; backEl.style.display = 'flex'; const canvasBack = await captureCardCanvas(backEl, 3); // Restore user's current view frontEl.style.display = origFrontDisplay; backEl.style.display = origBackDisplay; const imgFront = canvasFront.toDataURL('image/png'); const imgBack = canvasBack.toDataURL('image/png'); const pdfWidth = 85; // mm standard ABNT const pdfHeight = 55; // mm standard ABNT const pdf = new jsPDF({ orientation: 'landscape', unit: 'mm', format: [pdfWidth, pdfHeight] }); // Page 1: Frente (Front) pdf.addImage(imgFront, 'PNG', 0, 0, pdfWidth, pdfHeight); // Page 2: Verso (Back with QR Code) pdf.addPage([pdfWidth, pdfHeight], 'landscape'); pdf.addImage(imgBack, 'PNG', 0, 0, pdfWidth, pdfHeight); pdf.save(`${nome.replace(/\s+/g, '_').toLowerCase()}_cartao_fisico_frente_verso.pdf`); showToast('PDF para Gráfica (Frente e Verso 85x55mm) gerado com sucesso!'); return; } // Digital Card Mode const targetEl = document.getElementById('cardPreviewDigital'); const canvas = await captureCardCanvas(targetEl, 3); const imgData = canvas.toDataURL('image/png'); const cardWidth = targetEl.offsetWidth; const cardHeight = targetEl.offsetHeight; const aspectRatio = cardHeight / cardWidth; let pdfWidth = 80; let pdfHeight = pdfWidth * aspectRatio; const pdf = new jsPDF({ orientation: pdfHeight > pdfWidth ? 'portrait' : 'landscape', unit: 'mm', format: [pdfWidth, pdfHeight] }); pdf.addImage(imgData, 'PNG', 0, 0, pdfWidth, pdfHeight); // Add real clickable link annotations on the PDF const scaleX = pdfWidth / cardWidth; const scaleY = pdfHeight / cardHeight; const links = targetEl.querySelectorAll('a'); links.forEach(link => { const rect = link.getBoundingClientRect(); const targetRect = targetEl.getBoundingClientRect(); const href = link.getAttribute('href'); if (href && href !== '#') { const relX = (rect.left - targetRect.left) * scaleX; const relY = (rect.top - targetRect.top) * scaleY; const w = rect.width * scaleX; const h = rect.height * scaleY; pdf.link(relX, relY, w, h, { url: href }); } }); pdf.save(`${nome.replace(/\s+/g, '_').toLowerCase()}_cartao_digital.pdf`); showToast('PDF gerado com links clicáveis!'); } catch (err) { console.error(err); showToast('Erro ao exportar PDF. Tente novamente.'); } } // 3. Export Image (PNG / JPG 300 DPI) async function exportImageCapture(format = 'png') { const nome = document.getElementById('inputNome').value.trim() || 'fbr4g4'; showToast('Capturando imagem em 300 DPI...'); try { if (cardMode === 'physical') { const frontEl = document.getElementById('cardPhysicalFront'); const backEl = document.getElementById('cardPhysicalBack'); const isBack = (backEl.style.display === 'flex'); const targetEl = isBack ? backEl : frontEl; const sideName = isBack ? 'verso' : 'frente'; const canvas = await captureCardCanvas(targetEl, 3); const link = document.createElement('a'); link.download = `${nome.replace(/\s+/g, '_').toLowerCase()}_cartao_fisico_${sideName}.${format}`; link.href = canvas.toDataURL(format === 'png' ? 'image/png' : 'image/jpeg', 0.95); link.click(); showToast(`Imagem do ${sideName.toUpperCase()} do cartão baixada em 300 DPI!`); return; } // Digital Card Mode const targetEl = document.getElementById('cardPreviewDigital'); const canvas = await captureCardCanvas(targetEl, 3); const link = document.createElement('a'); link.download = `${nome.replace(/\s+/g, '_').toLowerCase()}_cartao_digital.${format}`; link.href = canvas.toDataURL(format === 'png' ? 'image/png' : 'image/jpeg', 0.95); link.click(); showToast('Imagem exportada com nitidez máxima (300 DPI)!'); } catch (err) { console.error(err); showToast('Erro ao exportar imagem.'); } } // 4. Download vCard (.vcf) function downloadVCardFile() { const nome = document.getElementById('inputNome').value.trim() || 'Contato'; const vcfContent = generateVCardContent(false); // false = include photo in file download const blob = new Blob([vcfContent], { type: 'text/vcard;charset=utf-8' }); const url = URL.createObjectURL(blob); const a = document.createElement('a'); a.href = url; a.download = `${nome.replace(/\s+/g, '_').toLowerCase()}.vcf`; a.click(); URL.revokeObjectURL(url); showToast('vCard (.vcf) baixado! Abra no celular para salvar.'); } // Generate vCard 3.0 Standard String (forQR keeps payload ultra-light for instant camera scanning) function generateVCardContent(forQR = false) { const nome = document.getElementById('inputNome').value.trim() || 'Contato'; const cargo = document.getElementById('inputCargo').value.trim() || ''; const empresa = document.getElementById('inputEmpresa').value.trim() || ''; const bio = document.getElementById('inputBio').value.trim() || ''; const email = document.getElementById('inputEmail').value.trim() || ''; const tel = document.getElementById('inputTelefone').value.trim() || ''; const ddi = document.getElementById('whatsappDdi').value; const waRaw = document.getElementById('inputWhatsapp').value.replace(/\D/g, ''); const wa = waRaw ? (ddi + waRaw) : ''; const site = document.getElementById('inputWebsite').value.trim() || ''; const endereco = document.getElementById('inputEndereco').value.trim() || ''; let vcf = "BEGIN:VCARD\r\nVERSION:3.0\r\n"; vcf += `FN:${nome}\r\n`; if (cargo) vcf += `TITLE:${cargo}\r\n`; if (empresa) vcf += `ORG:${empresa}\r\n`; if (wa) vcf += `TEL;TYPE=CELL,VOICE:${wa}\r\n`; if (tel) vcf += `TEL;TYPE=WORK,VOICE:${tel}\r\n`; if (email) vcf += `EMAIL;TYPE=PREF,INTERNET:${email}\r\n`; if (site) vcf += `URL:${site}\r\n`; if (endereco) vcf += `ADR;TYPE=WORK:;;${endereco};;;;\r\n`; if (bio && !forQR) vcf += `NOTE:${bio}\r\n`; const ig = document.getElementById('inputInstagram').value.trim(); const li = document.getElementById('inputLinkedin').value.trim(); const fb = document.getElementById('inputFacebook').value.trim(); const gh = document.getElementById('inputGithub').value.trim(); if (gh) vcf += `X-SOCIALPROFILE;type=GitHub:${gh.startsWith('http') ? gh : 'https://github.com/' + gh}\r\n`; if (li) vcf += `X-SOCIALPROFILE;type=LinkedIn:${li.startsWith('http') ? li : 'https://linkedin.com/in/' + li}\r\n`; if (ig) vcf += `X-SOCIALPROFILE;type=Instagram:${ig.startsWith('http') ? ig : 'https://instagram.com/' + ig.replace(/^@/, '')}\r\n`; if (fb) vcf += `X-SOCIALPROFILE;type=Facebook:${fb.startsWith('http') ? fb : 'https://facebook.com/' + fb}\r\n`; // Only embed photo bytes when downloading the .vcf file, NEVER inside QR code if (!forQR && avatarDataUrl && avatarDataUrl.includes('base64,')) { const parts = avatarDataUrl.split('base64,'); const mime = parts[0].includes('png') ? 'PNG' : 'JPEG'; vcf += `PHOTO;ENCODING=b;TYPE=${mime}:${parts[1].replace(/[\r\n]/g, '')}\r\n`; } vcf += "END:VCARD\r\n"; return vcf; } // Web Share Direct Trigger (Mobile native share or Desktop clipboard fallback) async function triggerWebShare() { const nome = document.getElementById('inputNome').value.trim() || 'fbr4g4'; const cargo = document.getElementById('inputCargo').value.trim() || ''; const site = document.getElementById('inputWebsite').value.trim() || window.location.href; if (navigator.share) { try { await navigator.share({ title: `${nome} - Cartão Digital`, text: `Olá! Aqui está o cartão de visitas digital de ${nome} (${cargo}):`, url: site }); showToast('Compartilhado com sucesso!'); return; } catch (e) { if (e.name !== 'AbortError') { console.warn('Web Share API error:', e); } } } // Fallback for Desktop / browsers without Web Share try { await navigator.clipboard.writeText(site); showToast('✓ Link copiado para a área de transferência!'); } catch (clipErr) { prompt('Copie o link abaixo:', site); } } // Copy Card to Clipboard as Image (with automatic download fallback) async function copyCardImageToClipboard() { try { showToast('Renderizando imagem...'); let targetEl = null; if (cardMode === 'physical') { const frontEl = document.getElementById('cardPhysicalFront'); const backEl = document.getElementById('cardPhysicalBack'); targetEl = (backEl.style.display === 'flex') ? backEl : frontEl; } else { targetEl = document.getElementById('cardPreviewDigital'); } const canvas = await captureCardCanvas(targetEl, 2); if (navigator.clipboard && typeof ClipboardItem !== 'undefined') { try { const blob = await new Promise(resolve => canvas.toBlob(resolve, 'image/png')); await navigator.clipboard.write([new ClipboardItem({ 'image/png': blob })]); showToast('✓ Cartão copiado! Cole no WhatsApp ou Slack (Ctrl+V).'); return; } catch (clipErr) { console.warn('Clipboard write image failed, falling back to download:', clipErr); } } // Fallback: download PNG image if clipboard is restricted by browser policy const a = document.createElement('a'); const nome = document.getElementById('inputNome').value.trim() || 'cartao'; a.download = `${nome.replace(/\s+/g, '_').toLowerCase()}_cartao.png`; a.href = canvas.toDataURL('image/png'); a.click(); showToast('Área de transferência restrita. A imagem PNG foi baixada!'); } catch (err) { console.error('Erro ao processar imagem:', err); showToast('Não foi possível processar a imagem.'); } } // Direct PIX Copy Handler function copyPixDirectly() { const pixChave = document.getElementById('inputPixChave').value.trim(); if (!pixChave) { showToast('Nenhuma chave PIX configurada.'); return; } navigator.clipboard.writeText(pixChave); showToast('Chave PIX copiada! Abra seu banco para transferir.'); } // Download Isolated QR Code in High-Res PNG function downloadQrCodePng() { const svgEl = document.querySelector('#previewQrHolder svg'); if (!svgEl) { showToast('Gere o QR Code primeiro.'); return; } const svgData = new XMLSerializer().serializeToString(svgEl); const svgBlob = new Blob([svgData], { type: 'image/svg+xml;charset=utf-8' }); const URL = window.URL || window.webkitURL || window; const blobURL = URL.createObjectURL(svgBlob); const image = new Image(); image.onload = () => { const canvas = document.createElement('canvas'); canvas.width = 400; canvas.height = 400; const ctx = canvas.getContext('2d'); ctx.fillStyle = '#ffffff'; ctx.fillRect(0, 0, 400, 400); ctx.drawImage(image, 20, 20, 360, 360); const link = document.createElement('a'); link.download = 'qrcode_contato.png'; link.href = canvas.toDataURL('image/png'); link.click(); URL.revokeObjectURL(blobURL); showToast('QR Code em PNG baixado com alta resolução!'); }; image.src = blobURL; } // ========================================================================== // LOCAL STORAGE & PRESETS MANAGEMENT // ========================================================================== const STORAGE_KEY = 'cardcraft_pro_v5'; function saveToLocalStorage() { const state = { cardMode, currentThemeKey, currentFont, currentShape, avatarDataUrl, bannerDataUrl, customLinksData, inputs: { inputNome: document.getElementById('inputNome').value, inputCargo: document.getElementById('inputCargo').value, inputEmpresa: document.getElementById('inputEmpresa').value, inputBio: document.getElementById('inputBio').value, whatsappDdi: document.getElementById('whatsappDdi').value, inputWhatsapp: document.getElementById('inputWhatsapp').value, inputEmail: document.getElementById('inputEmail').value, inputTelefone: document.getElementById('inputTelefone').value, inputWebsite: document.getElementById('inputWebsite').value, inputEndereco: document.getElementById('inputEndereco').value, togglePix: document.getElementById('togglePix').checked, pixTipo: document.getElementById('pixTipo').value, inputPixChave: document.getElementById('inputPixChave').value, inputPixNome: document.getElementById('inputPixNome').value, inputInstagram: document.getElementById('inputInstagram').value, inputLinkedin: document.getElementById('inputLinkedin').value, inputFacebook: document.getElementById('inputFacebook').value, inputGithub: document.getElementById('inputGithub').value, inputYoutube: document.getElementById('inputYoutube').value, inputTelegram: document.getElementById('inputTelegram').value, inputTwitter: document.getElementById('inputTwitter').value, inputTiktok: document.getElementById('inputTiktok').value, inputBehance: document.getElementById('inputBehance').value, toggleQrCode: document.getElementById('toggleQrCode').checked, qrCodeTarget: document.getElementById('qrCodeTarget').value, colorBg1: document.getElementById('colorBg1').value, colorBg2: document.getElementById('colorBg2').value, colorAccent: document.getElementById('colorAccent').value, colorText: document.getElementById('colorText').value } }; localStorage.setItem(STORAGE_KEY, JSON.stringify(state)); } function loadFromLocalStorage() { try { const saved = localStorage.getItem(STORAGE_KEY); if (!saved) { // Load default 4U Engineer preset if virgin applyPreset('engenheiro'); return; } const state = JSON.parse(saved); cardMode = state.cardMode || 'digital'; currentThemeKey = state.currentThemeKey || 'tech'; currentFont = state.currentFont || 'Inter'; currentShape = state.currentShape || 'rounded'; avatarDataUrl = state.avatarDataUrl || ''; bannerDataUrl = state.bannerDataUrl || ''; customLinksData = state.customLinksData || []; if (state.inputs) { Object.keys(state.inputs).forEach(key => { const el = document.getElementById(key); if (el) { if (el.type === 'checkbox') { el.checked = state.inputs[key]; } else { el.value = state.inputs[key]; } } }); } // Restore custom links UI const container = document.getElementById('customLinksList'); container.innerHTML = ''; customLinksData.forEach(d => addCustomLinkItem(d)); // Restore avatar and banner previews if (avatarDataUrl) { document.getElementById('avatarPlaceholder').style.display = 'none'; document.getElementById('avatarActive').style.display = 'flex'; document.getElementById('thumbAvatar').src = avatarDataUrl; } if (bannerDataUrl) { document.getElementById('bannerPlaceholder').style.display = 'none'; document.getElementById('bannerActive').style.display = 'flex'; document.getElementById('thumbBanner').src = bannerDataUrl; } selectTheme(currentThemeKey); selectFont(currentFont); selectButtonShape(currentShape); switchCardMode(cardMode); } catch (e) { console.error('Falha ao restaurar localStorage', e); applyPreset('engenheiro'); } } // Apply a full Professional Preset function applyPreset(presetKey) { const data = professionalPresets[presetKey]; if (!data) return; document.getElementById('inputNome').value = data.nome; document.getElementById('inputCargo').value = data.cargo; document.getElementById('inputEmpresa').value = data.empresa; document.getElementById('inputBio').value = data.bio; document.getElementById('whatsappDdi').value = data.whatsappDdi || '+55'; document.getElementById('inputWhatsapp').value = data.whatsapp; document.getElementById('inputEmail').value = data.email; document.getElementById('inputTelefone').value = data.telefone; document.getElementById('inputWebsite').value = data.website; document.getElementById('inputEndereco').value = data.endereco; document.getElementById('togglePix').checked = data.togglePix; document.getElementById('pixTipo').value = data.pixTipo; document.getElementById('inputPixChave').value = data.pixChave; document.getElementById('inputPixNome').value = data.pixNome; document.getElementById('inputInstagram').value = data.instagram; document.getElementById('inputLinkedin').value = data.linkedin; document.getElementById('inputFacebook').value = data.facebook || ''; document.getElementById('inputGithub').value = data.github; document.getElementById('inputYoutube').value = data.youtube; document.getElementById('inputTelegram').value = data.telegram; document.getElementById('inputTwitter').value = data.twitter; document.getElementById('inputTiktok').value = data.tiktok; document.getElementById('inputBehance').value = data.behance; // Apply Images from preset if available if (data.avatarDataUrl !== undefined) { avatarDataUrl = data.avatarDataUrl; if (avatarDataUrl) { document.getElementById('avatarPlaceholder').style.display = 'none'; document.getElementById('avatarActive').style.display = 'flex'; document.getElementById('thumbAvatar').src = avatarDataUrl; } else { document.getElementById('avatarPlaceholder').style.display = 'block'; document.getElementById('avatarActive').style.display = 'none'; } } if (data.bannerDataUrl !== undefined) { bannerDataUrl = data.bannerDataUrl; if (bannerDataUrl) { document.getElementById('bannerPlaceholder').style.display = 'none'; document.getElementById('bannerActive').style.display = 'flex'; document.getElementById('thumbBanner').src = bannerDataUrl; } else { document.getElementById('bannerPlaceholder').style.display = 'block'; document.getElementById('bannerActive').style.display = 'none'; } } // Custom links const container = document.getElementById('customLinksList'); container.innerHTML = ''; customLinksData = data.customLinks || []; customLinksData.forEach(l => addCustomLinkItem(l)); selectTheme(data.theme || 'tech'); selectFont(data.font || 'Inter'); selectButtonShape(data.shape || 'rounded'); updateLivePreview(); saveToLocalStorage(); showToast(`Template "${data.nome}" carregado!`); } // Modal for Presets Picker function openPresetModal() { const choice = prompt("Escolha o template que deseja carregar:\n1 - fbr4g4 (4U.IA.BR Flagship)\n2 - Advocacia & Consultoria\n3 - Médico & Especialista de Saúde\n4 - Designer & Artista Visual\n\nDigite 1, 2, 3 ou 4:"); if (choice === '1') applyPreset('engenheiro'); else if (choice === '2') applyPreset('advogada'); else if (choice === '3') applyPreset('medico'); else if (choice === '4') applyPreset('designer'); } function resetFormWithConfirm() { if (confirm("Deseja realmente limpar todos os campos do cartão?")) { localStorage.removeItem(STORAGE_KEY); avatarDataUrl = ''; bannerDataUrl = ''; customLinksData = []; document.querySelectorAll('input:not([type="checkbox"]):not([type="color"]), textarea').forEach(i => i.value = ''); document.getElementById('customLinksList').innerHTML = ''; document.getElementById('avatarActive').style.display = 'none'; document.getElementById('avatarPlaceholder').style.display = 'block'; document.getElementById('bannerActive').style.display = 'none'; document.getElementById('bannerPlaceholder').style.display = 'block'; selectTheme('tech'); selectFont('Inter'); selectButtonShape('rounded'); updateLivePreview(); showToast('Formulário limpo.'); } } // Helper Toast Notification function showToast(msg) { const toast = document.getElementById('toastBox'); document.getElementById('toastMsg').textContent = msg; toast.classList.add('show'); setTimeout(() => { toast.classList.remove('show'); }, 3200); } function escapeHtml(str) { return String(str).replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"'); }