Affiliate Marketing Content Generator
Create high-converting content for your affiliate products.
Define Your Affiliate Product
Generate Your Content
Preview & Export Content Brief
Your generated content will appear here.
Your generated content will appear here.
'; }; 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 margin = 50; let cursorY = 0; // --- PDF Template: Content Marketing Brief --- pdf.setFillColor(15, 23, 42); // Slate 900 pdf.rect(0, 0, pageW, 70, 'F'); pdf.setFont('helvetica', 'bold').setFontSize(20).setTextColor(255, 255, 255); pdf.text('Affiliate Content Brief', margin, 45); cursorY = 110; const addSection = (title, content) => { pdf.setFont('helvetica', 'bold').setFontSize(10).setTextColor(100, 116, 139); // Slate 500 pdf.text(title.toUpperCase(), margin, cursorY); cursorY += 15; const contentLines = pdf.setFont('helvetica', 'normal').setFontSize(12).setTextColor(51, 65, 85) .splitTextToSize(content, pageW - margin * 2); pdf.text(contentLines, margin, cursorY); cursorY += (contentLines.length * 12) + 20; pdf.setDrawColor(226, 232, 240).line(margin, cursorY - 10, pageW - margin, cursorY - 10); }; addSection("Affiliate Product", productNameEl.value || 'N/A'); addSection("Target Audience", targetAudienceEl.value || 'N/A'); addSection("Content Type", contentTypeEl.value || 'N/A'); cursorY += 20; const generatedLines = (generatedContentEl.value || "No content generated.").split('\n'); for (const line of generatedLines) { if (cursorY > pdf.internal.pageSize.getHeight() - margin) { pdf.addPage(); cursorY = margin; } if (line.startsWith('## ')) { const titleLines = pdf.setFont('helvetica', 'bold').setFontSize(18).setTextColor(17, 24, 39) .splitTextToSize(line.substring(3), pageW - margin * 2); pdf.text(titleLines, margin, cursorY); cursorY += (titleLines.length * 18) + 15; } else if (line.startsWith('### ')) { const headingLines = pdf.setFont('helvetica', 'bold').setFontSize(14).setTextColor(13, 148, 136) // Teal 600 .splitTextToSize(line.substring(4), pageW - margin * 2); pdf.text(headingLines, margin, cursorY); cursorY += (headingLines.length * 14) + 10; } else if (line.startsWith('* ')) { const bulletLines = pdf.setFont('helvetica', 'normal').setFontSize(11).setTextColor(55, 65, 81) .splitTextToSize(line.substring(2), pageW - margin * 2 - 15); pdf.text('•', margin, cursorY); pdf.text(bulletLines, margin + 15, cursorY); cursorY += (bulletLines.length * 11) + 5; } else if (line.trim() !== "") { const paraLines = pdf.setFont('helvetica', 'normal').setFontSize(11).setTextColor(55, 65, 81) .splitTextToSize(line, pageW - margin * 2); pdf.text(paraLines, margin, cursorY); cursorY += (paraLines.length * 11) + 10; } } pdf.save(`Affiliate-Content-${(productNameEl.value || 'Untitled').replace(/\s+/g, '-')}.pdf`); }; // --- Event Listeners --- if (generateBtn) generateBtn.addEventListener('click', handleGenerateClick); if (downloadPdfBtn) downloadPdfBtn.addEventListener('click', handleDownloadPdf); });