Blog Monetization Strategy Tool

Blog Monetization Strategy Tool

Develop a tailored plan to grow your blog's revenue.

Enter Your Blog's Details

Your generated strategy will appear here.

'; // Convert markdown-style headings to HTML let html = strategyText .replace(/### (.*?)\n/g, '

$1

') .replace(/\n/g, '
'); previewBodyEl.innerHTML = html; }; const handleDownloadPdf = () => { if (!window.jspdf) { console.error('jsPDF not loaded.'); return; } const { jsPDF } = window.jspdf; const pdf = new jsPDF({ orientation: 'portrait', unit: 'pt', format: 'a4' }); const pageW = pdf.internal.pageSize.getWidth(); const pageH = pdf.internal.pageSize.getHeight(); const margin = 50; const maxLineWidth = pageW - margin * 2; let cursorY = 0; // --- PDF Template: Professional Green Theme --- // Header Background pdf.setFillColor(22, 101, 52); // Green-900 pdf.rect(0, 0, pageW, 70, 'F'); pdf.setFont('helvetica', 'bold').setFontSize(20).setTextColor(255, 255, 255); pdf.text("Blog Monetization Strategy", margin, 45); cursorY = 110; // Section 1: Blog Profile pdf.setFont('helvetica', 'bold').setFontSize(14).setTextColor(21, 128, 61); // Green-700 pdf.text("Blog Profile", margin, cursorY); cursorY += 20; const addProfileLine = (label, value) => { pdf.setFont('helvetica', 'bold').setFontSize(10).setTextColor(30, 41, 59); // Slate-700 pdf.text(label, margin, cursorY); pdf.setFont('helvetica', 'normal').setFontSize(10).setTextColor(51, 65, 85); // Slate-600 const valueLines = pdf.splitTextToSize(value, maxLineWidth - 100); pdf.text(valueLines, margin + 100, cursorY); cursorY += valueLines.length * 12 + 5; }; addProfileLine("Niche:", blogNicheEl.value || "N/A"); addProfileLine("Monthly Traffic:", monthlyTrafficEl.value); addProfileLine("Primary Goal:", primaryGoalEl.value); addProfileLine("Current Methods:", getCurrentMonetization()); cursorY += 15; // Divider pdf.setDrawColor(220, 252, 231); // Green-200 pdf.setLineWidth(2); pdf.line(margin, cursorY, pageW - margin, cursorY); cursorY += 30; // Section 2: Recommended Strategy pdf.setFont('helvetica', 'bold').setFontSize(14).setTextColor(21, 128, 61); // Green-700 pdf.text("Recommended Monetization Strategy", margin, cursorY); cursorY += 25; const strategyText = generatedStrategyEl.value || "No strategy generated."; const lines = strategyText.split('\n'); lines.forEach(line => { if (cursorY > pageH - margin) { pdf.addPage(); cursorY = margin; } if (line.startsWith('### ')) { cursorY += 10; pdf.setFont('helvetica', 'bold').setFontSize(12).setTextColor(22, 101, 52); // Green-900 const headingText = line.substring(4); const headingLines = pdf.splitTextToSize(headingText, maxLineWidth); pdf.text(headingLines, margin, cursorY); cursorY += headingLines.length * 14 + 5; } else if (line.trim() !== "") { pdf.setFont('helvetica', 'normal').setFontSize(10).setTextColor(51, 65, 85); // Slate-600 const paraLines = pdf.splitTextToSize(line, maxLineWidth); pdf.text(paraLines, margin, cursorY); cursorY += paraLines.length * 12 + 8; } }); // Footer const pageCount = pdf.internal.getNumberOfPages(); for(let i = 1; i <= pageCount; i++) { pdf.setPage(i); pdf.setFont('helvetica', 'italic').setFontSize(8).setTextColor(148, 163, 184); // Slate-400 pdf.text(`Strategy generated on ${new Date().toLocaleDateString()}`, margin, pageH - 25); pdf.text(`Page ${i} of ${pageCount}`, pageW - margin, pageH - 25, { align: 'right' }); } pdf.save(`Blog-Monetization-Strategy-for-${(blogNicheEl.value || 'Blog').replace(/\s+/g, '-')}.pdf`); }; // --- Event Listeners --- if (generateBtn) generateBtn.addEventListener('click', handleGenerateClick); if (downloadPdfBtn) downloadPdfBtn.addEventListener('click', handleDownloadPdf); });
Scroll to Top