PDF resizer

Compress PDF

Compress PDF File

document.getElementById('pdfForm').addEventListener('submit', function(e) { e.preventDefault(); const fileInput = document.getElementById('pdfInput'); const file = fileInput.files[0]; if (!file) { alert('Please select a PDF file first.'); return; } const formData = new FormData(); formData.append('file', file); const apiKey = 'YOUR_PUBLIC_KEY'; const apiSecret = 'YOUR_SECRET_KEY'; fetch('https://api.ilovepdf.com/v1/compress', { method: 'POST', headers: { 'Authorization': 'Basic ' + btoa(apiKey + ':' + apiSecret) }, body: formData }) .then(response => response.json()) .then(data => { if (data.task_id) { alert('PDF compression completed successfully! Task ID: ' + data.task_id); } else { alert('Error compressing PDF file.'); } }) .catch(error => { console.error('Error:', error); alert('An error occurred while compressing the PDF file.'); }); });

एक टिप्पणी भेजें

0 टिप्पणियाँ
* Please Don't Spam Here. All the Comments are Reviewed by Admin.

#buttons=(Ok, Go it!) #days=(20)

Our website uses cookies to enhance your experience. Check Out
Ok, Go it!