'|
K
PDFKraft.in
100% Client-Side
← Back to all tools
Choose Conversion Flow

Convert Word to PDF

Turn Microsoft Word (.docx) documents into clean PDFs directly in your browser.

Select Document

Accepts .docx files

In-Browser Presentation & Document Engine

PDFKraft decodes PowerPoint XML packages, DOCX trees, and PDF character vectors entirely in your computer's RAM using JavaScript WebAssembly. Zero uploads, zero logs, absolute security.

${baseName} ${bodyHtml} `; const blob = new Blob(['\ufeff', docFullHtml], { type: 'application/msword' }); updateProgress(100, "Done!"); triggerDownload(blob, `${baseName}.doc`); } else if (activeMode === 'pdf-to-excel') { const pagesData = await extractStructuredPdfLines(fileBuffer); updateProgress(85, "Creating Excel columns & sheets..."); const wb = XLSX.utils.book_new(); const tableRows = [ ["Source File", loadedFile.name], ["Generated By", "PDFKraft In-Browser Engine"], [] ]; pagesData.forEach(p => { tableRows.push([`--- Page ${p.pageNum} ---`]); p.lines.forEach(line => { const cols = line.split(/\s{2,}|\t/); tableRows.push(cols); }); tableRows.push([]); }); const ws = XLSX.utils.aoa_to_sheet(tableRows); XLSX.utils.book_append_sheet(wb, ws, "Extracted Data"); const wbout = XLSX.write(wb, { bookType: 'xlsx', type: 'array' }); const blob = new Blob([wbout], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' }); updateProgress(100, "Done!"); triggerDownload(blob, `${baseName}.xlsx`); } else if (activeMode === 'word-to-pdf') { updateProgress(40, "Parsing DOCX XML..."); const { value: textContent } = await mammoth.extractRawText({ arrayBuffer: fileBuffer }); const { jsPDF } = window.jspdf; const doc = new jsPDF(); updateProgress(75, "Rendering vector PDF pages..."); const splitLines = doc.splitTextToSize(textContent || "Document Content", 180); let y = 15; for (let i = 0; i < splitLines.length; i++) { if (y > 280) { doc.addPage(); y = 15; } doc.text(splitLines[i], 15, y); y += 7; } const pdfBlob = doc.output('blob'); updateProgress(100, "Done!"); triggerDownload(pdfBlob, `${baseName}.pdf`); } else if (activeMode === 'excel-to-pdf') { updateProgress(40, "Parsing Workbook..."); const workbook = XLSX.read(fileBuffer, { type: 'array' }); const firstSheet = workbook.Sheets[workbook.SheetNames[0]]; const sheetData = XLSX.utils.sheet_to_json(firstSheet, { header: 1 }); const { jsPDF } = window.jspdf; const doc = new jsPDF({ orientation: 'landscape' }); let y = 15; updateProgress(75, "Printing table to PDF..."); sheetData.slice(0, 50).forEach((row) => { if (y > 190) { doc.addPage(); y = 15; } doc.text(row.slice(0, 8).join(" | "), 10, y); y += 8; }); const pdfBlob = doc.output('blob'); updateProgress(100, "Done!"); triggerDownload(pdfBlob, `${baseName}.pdf`); } status.className = 'text-center text-xs font-bold p-3.5 rounded-xl bg-emerald-50 text-emerald-700 border border-emerald-200 block'; status.innerText = "✓ Converted successfully! File download started."; } catch (err) { status.className = 'text-center text-xs font-bold p-3.5 rounded-xl bg-rose-50 text-rose-700 border border-rose-200 block'; status.innerText = "Conversion error: " + err.message; } finally { btn.disabled = false; btn.innerHTML = ' Convert Document Now'; lucide.createIcons(); } } function escapeHtml(text) { return text .replace(/&/g, "&") .replace(//g, ">") .replace(/"/g, """) .replace(/'/g, "'"); } function triggerDownload(blob, filename) { const url = URL.createObjectURL(blob); const a = document.createElement('a'); a.href = url; a.download = filename; a.click(); URL.revokeObjectURL(url); }