blob: 39c79cc8a19000ed6ccc9d9aa3b5018ae3e93329 (
plain)
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
|
const fs = require('fs');
const childProcess = require('child_process');
const resumeHtml = fs.readFileSync('../resume.html').toString();
const resumeCss = fs.readFileSync('../resume.css').toString();
const resumeDlCss = fs.readFileSync('./resume_dl.css').toString();
function getRidofTagsBetween(start, end, html) {
let si = newHtml.indexOf(start);
let ei = newHtml.indexOf(end, si) + end.length;
return html.substring(0, si) + newHtml.substring(ei);
}
const newHeader = `
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta charset="UTF-8" />
<script src="https://twemoji.maxcdn.com/2/twemoji.min.js?11.2"></script>
<script>window.onload = function () { twemoji.parse(document.body);}</script>
<link href="https://fonts.googleapis.com/css?family=Open+Sans:400,600,300" rel="stylesheet" type="text/css">
<style>
${resumeCss}
${resumeDlCss}
</style>
</head>
`
const startHead = resumeHtml.indexOf('<head>');
const endHead = resumeHtml.indexOf('</head>') + '</head>'.length;
let newHtml = resumeHtml.substring(0, startHead) + newHeader + resumeHtml.substring(endHead);
newHtml = getRidofTagsBetween('<header>', '</header>', newHtml);
newHtml = getRidofTagsBetween(`<div id='resume_button_container'>`, '</div>', newHtml);
fs.writeFileSync('./resume_dl.html', newHtml);
childProcess.exec('wkhtmltopdf --encoding \'UTF-8\' ./resume_dl.html cv.pdf ')
|