forked from bedimcode/responsive-portfolio-website-Alexa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate-pdf.js
66 lines (54 loc) · 1.72 KB
/
generate-pdf.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
// Replace 'your-resume-page-url' with the URL of your HTML page containing the resume
await page.goto('resume.html');
// Evaluate a function within the page to get the inner HTML of the resume div
const resumeHTML = await page.evaluate(() => {
const resumeDiv = document.getElementById('emily_holcomb_resume');
return resumeDiv ? resumeDiv.innerHTML : null;
});
if (resumeHTML) {
const pdfContent = `
<html>
<head>
<style>
.resume {
margin: 0 auto;
display: flex;
flex-direction: column;
justify-content: center;
/*align-items: center;*/
padding: 1.5rem;
}
.resume-group {
margin: 1.25rem 0;
}
.resume-detail {
margin: 1rem 0;
}
.resume-detail ul {
list-style-type: disc;
list-style-position: outside;
margin-left: 0;
padding-left: .5em; /* Adjust this value based on your design */
}
.resume-detail li {
text-align: left;
margin: 0.5rem;
}
</style>
</head>
<body>
${resumeHTML}
</body>
</html>
`;
await page.setContent(pdfContent);
await page.pdf({ path: 'emily_holcomb_resume.pdf', format: 'A4' });
} else {
console.error('Resume content not found');
}
await browser.close();
})();