Skip to content

Commit 637bb98

Browse files
authored
Merge pull request #49 from lumi-tip/master-lumi-hotfix-1
adding to puppeteear headers
2 parents cfd50f7 + 2b99c11 commit 637bb98

File tree

2 files changed

+47
-7
lines changed

2 files changed

+47
-7
lines changed

auth/pdfHelper.js

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,49 @@
11
import { renderToStaticMarkup } from 'react-dom/server';
2+
import fs from "fs";
3+
import path from "path";
24

35
const isProd = process.env.NODE_ENV !== "development";
46

57
export const componentToPDFBuffer = async (component) => {
6-
const html = renderToStaticMarkup(component);
8+
let html = renderToStaticMarkup(component);
9+
10+
const globalCSS = fs.readFileSync(path.resolve(process.cwd(), "styles", "globals.css"), 'utf-8');
11+
const latoLight = fs.readFileSync(path.resolve(process.cwd(), "fonts", "Lato", "Lato-Light.ttf")).toString("base64");
12+
const latoRegular = fs.readFileSync(path.resolve(process.cwd(), "fonts", "Lato", "Lato-Regular.ttf")).toString("base64");
13+
const latoBold = fs.readFileSync(path.resolve(process.cwd(), "fonts", "Lato", "Lato-Bold.ttf")).toString("base64");
14+
const mrsSaint = fs.readFileSync(path.resolve(process.cwd(), "fonts", "MrsSaintDelafield", "MrsSaintDelafield-Regular.ttf")).toString("base64");
15+
16+
const styles = `
17+
<style>
18+
${globalCSS}
19+
@font-face {
20+
font-family: 'Lato';
21+
font-style: normal;
22+
font-weight: 300;
23+
src: url(data:font/truetype;charset=utf-8;base64,${latoLight}) format('truetype');
24+
}
25+
@font-face {
26+
font-family: 'Lato';
27+
font-style: normal;
28+
font-weight: 400;
29+
src: url(data:font/truetype;charset=utf-8;base64,${latoRegular}) format('truetype');
30+
}
31+
@font-face {
32+
font-family: 'Lato';
33+
font-style: normal;
34+
font-weight: 700;
35+
src: url(data:font/truetype;charset=utf-8;base64,${latoBold}) format('truetype');
36+
}
37+
@font-face {
38+
font-family: 'Mrs Saint Delafield';
39+
font-style: normal;
40+
font-weight: 400;
41+
src: url(data:font/truetype;charset=utf-8;base64,${mrsSaint}) format('truetype');
42+
}
43+
</style>
44+
`;
45+
46+
html = html.replace('</head>', `${styles}</head>`);
747

848
let browser;
949
if (isProd) {

auth/pdfStyles.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,17 @@ export const stylesDefault = {
3535
name:{
3636
position: "absolute",
3737
left: "0%",
38-
top: "60%",
38+
top: "61%",
3939
textAlign: "center",
4040
width:"100%"
4141
},
4242
lastName:{
43-
fontSize:"36px",
43+
fontSize:"45px",
4444
fontWeight:300,
4545
fontFamily:"Lato, sans-serif"
4646
},
4747
firstName:{
48-
fontSize:"36px",
48+
fontSize:"45px",
4949
fontWeight:700,
5050
fontFamily:"Lato, sans-serif"
5151
},
@@ -56,7 +56,7 @@ export const stylesDefault = {
5656
textAlign:"center"
5757
},
5858
givenTo:{
59-
fontSize:"18px",
59+
fontSize:"24px",
6060
fontWeight:300,
6161
fontFamily:"Lato, sans-serif"
6262
},
@@ -67,7 +67,7 @@ export const stylesDefault = {
6767
textAlign:"center"
6868
},
6969
completionDescription:{
70-
fontSize:"18px",
70+
fontSize:"24px",
7171
fontWeight:300,
7272
fontFamily:"Lato, sans-serif",
7373
margin:0
@@ -99,7 +99,7 @@ export const stylesDefault = {
9999
margin:0,
100100
},
101101
sign:{
102-
fontSize:"30px",
102+
fontSize:"41px",
103103
fontFamily:"Mrs Saint Delafield, cursive",
104104
margin:0,
105105
},

0 commit comments

Comments
 (0)