Online Self-Publishing Guide Tool

Online Self-Publishing Guide

Create your personalized publishing plan by following the steps below.

The foundation of a successful book is a well-written and professionally edited manuscript. Plan your editing process carefully.

${data.pricing}

Marketing

Author Platform Building

${data.authorPlatform}

Book Launch Plan

${data.launchPlan}

Estimated Budget

$${Number(data.marketingBudget).toLocaleString() || '0'}

`; pdfContentArea.style.display = 'block'; pdfContentArea.style.position = 'absolute'; pdfContentArea.style.left = '-9999px'; pdfContentArea.style.width = '800px'; try { const canvas = await html2canvas(pdfContentArea, { scale: 2, useCORS: true }); const imgData = canvas.toDataURL('image/png'); const { jsPDF } = window.jspdf; const pdf = new jsPDF({ orientation: 'portrait', unit: 'px', format: 'a4' }); const pdfWidth = pdf.internal.pageSize.getWidth(); const pdfHeight = pdf.internal.pageSize.getHeight(); const imgHeight = canvas.height * pdfWidth / canvas.width; let heightLeft = imgHeight; let position = 0; pdf.addImage(imgData, 'PNG', 0, position, pdfWidth, imgHeight); heightLeft -= pdfHeight; while (heightLeft > 0) { position = position - pdfHeight; pdf.addPage(); pdf.addImage(imgData, 'PNG', 0, position, pdfWidth, imgHeight); heightLeft -= pdfHeight; } const filename = `Self-Publishing-Plan-${data.title.replace(/[^a-z0-9]/gi, '-') || 'Book'}.pdf`; pdf.save(filename); } catch (error) { console.error("Failed to generate PDF:", error); alert("Sorry, there was an error creating the PDF file."); } finally { pdfContentArea.style.display = 'none'; pdfContentArea.innerHTML = ''; } } // --- Event Listeners --- tabButtons.forEach((button, index) => { button.addEventListener('click', () => setActiveTab(index)); }); prevBtn.addEventListener('click', () => { if (currentTabIndex > 0) setActiveTab(currentTabIndex - 1); }); nextBtn.addEventListener('click', () => { if (currentTabIndex < tabButtons.length - 1) setActiveTab(currentTabIndex + 1); }); downloadPdfBtn.addEventListener('click', generatePdf); // --- Initial State --- setActiveTab(0); });
Scroll to Top