Category: Uncategorized

document.getElementById('uploadForm').addEventListener('submit', function (e) { e.preventDefault(); let pdfFile = document.getElementById('pdfFile').files[0]; if (!pdfFile) { alert("Please select a PDF file."); return; } let formData = new FormData(); formData.append("file", pdfFile); fetch('https://v2.convertapi.com/convert/pdf/to/docx?Secret=your-api-key', { method: 'POST', body: formData }) .then(response => response.json()) .then(data => { if (data && data.Files && data.Files.length > 0) { let downloadUrl = data.Files[0].Url; let downloadLink = document.getElementById('downloadLink'); downloadLink.href = downloadUrl; downloadLink.style.display = 'block'; } else { alert('Conversion failed.'); } }) .catch(error => { console.error('Error:', error); alert('Error converting file.'); }); });