📄

Merge PDF

Combine multiple PDF files into one — free, fast, and private.

📁

Click to upload or drag & drop PDF files here

Supports: PDF · Max 50MB per file

How to Merge PDFs

3 simple steps — no account needed

1

Upload Files

Select or drag your PDF files into the upload area above.

2

Arrange Order

Files merge in the order listed. Remove any you don't need.

3

Download

Click Merge and download your combined PDF instantly.

Related PDF Tools

2. Replace the mergePDFs() function with actual pdf-lib merge code */ const dropzone = document.getElementById('dropzone'); const fileList = document.getElementById('file-list'); const toolActions= document.getElementById('tool-actions'); const statusMsg = document.getElementById('status-msg'); let files = []; // Init drag and drop via shared helper + local handler dropzone.addEventListener('click', () => { const input = document.createElement('input'); input.type = 'file'; input.accept = '.pdf'; input.multiple = true; input.onchange = e => addFiles(e.target.files); input.click(); }); dropzone.addEventListener('dragover', e => { e.preventDefault(); dropzone.classList.add('dragover'); }); dropzone.addEventListener('dragleave', () => dropzone.classList.remove('dragover')); dropzone.addEventListener('drop', e => { e.preventDefault(); dropzone.classList.remove('dragover'); addFiles(e.dataTransfer.files); }); function addFiles(newFiles) { Array.from(newFiles).forEach(f => { if (f.type !== 'application/pdf') { showStatus('Only PDF files are supported.', 'error'); return; } files.push(f); }); renderFileList(); } function renderFileList() { fileList.innerHTML = ''; statusMsg.className = 'status-msg'; // hide if (!files.length) { toolActions.style.display = 'none'; return; } toolActions.style.display = 'flex'; files.forEach((f, i) => { const item = document.createElement('div'); item.className = 'file-item'; item.innerHTML = ` 📄 ${f.name} ${(f.size/1024/1024).toFixed(2)} MB `; fileList.appendChild(item); }); fileList.querySelectorAll('.file-item-remove').forEach(btn => { btn.addEventListener('click', () => { files.splice(+btn.dataset.i, 1); renderFileList(); }); }); } document.getElementById('btn-clear').addEventListener('click', () => { files = []; renderFileList(); }); document.getElementById('btn-merge').addEventListener('click', mergePDFs); function showStatus(msg, type) { statusMsg.textContent = msg; statusMsg.className = 'status-msg ' + type; } async function mergePDFs() { if (files.length < 2) { showStatus('Please add at least 2 PDF files to merge.', 'error'); return; } showStatus('⏳ Merging PDFs… (connect pdf-lib to enable real merging)', 'success'); /* ── REAL MERGE (uncomment after adding pdf-lib) ─────────────── try { const { PDFDocument } = PDFLib; const mergedPdf = await PDFDocument.create(); for (const file of files) { const bytes = await file.arrayBuffer(); const doc = await PDFDocument.load(bytes); const pages = await mergedPdf.copyPages(doc, doc.getPageIndices()); pages.forEach(p => mergedPdf.addPage(p)); } const mergedBytes = await mergedPdf.save(); const blob = new Blob([mergedBytes], { type: 'application/pdf' }); const url = URL.createObjectURL(blob); const a = document.createElement('a'); a.href = url; a.download = 'merged.pdf'; a.click(); URL.revokeObjectURL(url); showStatus('✅ PDF merged successfully! Download started.', 'success'); } catch(e) { showStatus('Error merging PDFs: ' + e.message, 'error'); } ─────────────────────────────────────────────────────────────── */ }