File tree Expand file tree Collapse file tree 1 file changed +32
-3
lines changed Expand file tree Collapse file tree 1 file changed +32
-3
lines changed Original file line number Diff line number Diff line change @@ -60,13 +60,42 @@ module.exports = launchOpts => {
60
60
61
61
const pdf = async ( url , opts = { } ) => {
62
62
const tempFile = createTempFile ( { ext : `.pdf` } )
63
- const { media = 'screen' } = opts
64
63
const { path } = tempFile
65
64
65
+ const {
66
+ media = 'screen' ,
67
+ format = 'A4' ,
68
+ printBackground = true ,
69
+ waitUntil = 'networkidle' ,
70
+ viewport = {
71
+ width : 2560 ,
72
+ height : 1440
73
+ } ,
74
+ margin = {
75
+ top : '0.25cm' ,
76
+ right : '0.25cm' ,
77
+ bottom : '0.25cm' ,
78
+ left : '0.25cm'
79
+ }
80
+ } = opts
81
+
66
82
const page = await newPage ( )
67
- await page . goto ( url , { waitUntil : 'networkidle' } )
83
+ await page . setViewport ( viewport )
84
+ await page . goto ( url , { waitUntil } )
68
85
await page . emulateMedia ( media )
69
- await page . pdf ( Object . assign ( { path } , opts ) )
86
+
87
+ await page . pdf (
88
+ Object . assign (
89
+ {
90
+ margin,
91
+ path,
92
+ format,
93
+ printBackground
94
+ } ,
95
+ opts
96
+ )
97
+ )
98
+
70
99
page . close ( )
71
100
72
101
return Promise . resolve ( tempFile )
You can’t perform that action at this time.
0 commit comments