-
Notifications
You must be signed in to change notification settings - Fork 0
/
cv.js
48 lines (41 loc) · 1.31 KB
/
cv.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
document.getElementById("cvForm").addEventListener("submit", function(event) {
event.preventDefault();
const name = document.getElementById("name").value;
const email = document.getElementById("email").value;
const phone = document.getElementById("phone").value;
const linkedin = document.getElementById("linkedin").value;
const objective = document.getElementById("objective").value;
// Build LaTeX document string
const latex = `
\\documentclass[a4paper,10pt]{article}
\\usepackage{parskip}
\\usepackage{geometry}
\\geometry{left=1in,right=1in,top=1in,bottom=1in}
\\begin{document}
\\begin{center}
{\\Huge ${name}} \\\\
\\vspace{0.1cm}
${email} | ${phone} | ${linkedin} \\\\
\\end{center}
\\section*{Objective}
${objective}
\\end{document}
`;
// Send LaTeX content to server
fetch('/generate-cv', {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
body: new URLSearchParams({ latex })
})
.then(response => response.blob())
.then(blob => {
// Download the PDF
const link = document.createElement('a');
link.href = window.URL.createObjectURL(blob);
link.download = 'cv.pdf';
link.click();
})
.catch(error => console.error('Error:', error));
});