Reference Letter Generator

Reference Letter Generator

1. Writer & Applicant Details

2. Recipient Details

3. Key Content Points

Enter your details in the Data Configuration tab and click "Generate Letter" to see your professional reference letter here.

Sincerely,

${data.writerName}
${data.writerTitle}
${data.writerAddress.replace(/\n/g, '
')}
`; letterContentDiv.innerHTML = letterHtml; }; generateBtn.addEventListener("click", () => { generateLetter(); showTab(1); // Switch to Dashboard }); // --- PDF Download --- pdfBtn.addEventListener("click", () => { const { jsPDF } = window.jspdf; const applicant = applicantNameInput.value.replace(/[^a-zA-Z0-9]/g, '_') || 'Applicant'; const fileName = `${applicant}_Reference_Letter.pdf`; html2canvas(exportArea, { scale: 2, useCORS: true, backgroundColor: '#ffffff' }).then(canvas => { const imgData = canvas.toDataURL('image/png'); const doc = new jsPDF({ orientation: 'p', unit: 'pt', format: 'letter' // Use US Letter format }); const pdfWidth = doc.internal.pageSize.getWidth(); const pdfHeight = doc.internal.pageSize.getHeight(); const imgProps = doc.getImageProperties(imgData); const imgWidth = imgProps.width; const imgHeight = imgProps.height; const margin = 40; const usableWidth = pdfWidth - (2 * margin); const ratio = usableWidth / imgWidth; let scaledHeight = imgHeight * ratio; if (scaledHeight > pdfHeight - (2 * margin)) { // Multi-page handling (Simplified for letter format) let position = margin; const pageHeight = pdfHeight - (2 * margin); let heightLeft = scaledHeight; doc.addImage(imgData, 'PNG', margin, position, usableWidth, scaledHeight); heightLeft -= pageHeight; while (heightLeft > 0) { position = margin - heightLeft; doc.addPage(); doc.addImage(imgData, 'PNG', margin, position, usableWidth, scaledHeight); heightLeft -= pageHeight; } } else { // Single page doc.addImage(imgData, 'PNG', margin, margin, usableWidth, scaledHeight); } doc.save(fileName); }).catch(err => { console.error("RLG PDF Error:", err); // alert("An error occurred while generating the PDF."); // Per spec }); }); // --- Initial Load --- // Prefill config with sample data on load writerNameInput.value = "Dr. Eleanor Vance"; writerTitleInput.value = "Professor of Computer Science"; writerAddressInput.value = "Department of Computer Science\nUniversity of Northwood\nNorthwood, CA 95000"; applicantNameInput.value = "Alexander Chen"; relationshipTimeInput.value = "3 years"; recipientTitleInput.value = "The Admissions Committee"; recipientDeptInput.value = "Northwood Graduate Program"; recipientAddressInput.value = "Graduate Admissions Office\nNorthwood University, South Campus\nPalo Alto, CA 94305"; contextInput.value = "Alex was a student in my Advanced Algorithms course and subsequently worked in my lab as a research assistant."; strength1Input.value = "Alex developed a novel data sorting algorithm for our project, demonstrating exceptional analytical rigor and independence in problem-solving."; strength2Input.value = "He consistently took the lead in study groups, clearly explaining complex concepts and motivating his peers, proving strong communication skills."; closingStatementInput.value = "I recommend Alex Chen without reservation and believe he possesses the rare combination of technical ability and intellectual curiosity needed for success in your program."; // Render the initial sample letter generateLetter(); showTab(0); // Start on Config tab });
Scroll to Top