@@ -29,15 +29,13 @@ export async function pdf(url, pdf_path, options, screenshot_dir, screenshot_opt
29
29
} )
30
30
31
31
await waitForPlutoBusy ( page , false , { timeout : 30 * 1000 } )
32
+ await screenshot_cells ( page , screenshot_dir , screenshot_options )
32
33
33
34
console . log ( "Exporting as pdf..." )
34
35
await page . pdf ( {
35
36
path : pdf_path ,
36
37
...options ,
37
38
} )
38
- if ( screenshot_dir != null ) {
39
- await screenshot_cells ( page , screenshot_dir , screenshot_options )
40
- }
41
39
42
40
console . log ( chalk . green ( "Exported ✓" ) + " ... cleaning up" )
43
41
@@ -55,15 +53,20 @@ async function screenshot_cells(page, screenshot_dir, { outputOnly, scale }) {
55
53
for ( let cell_id of cells ) {
56
54
const cell = await page . $ ( `[id="${ cell_id } "]${ outputOnly ? " > pluto-output" : "" } ` )
57
55
if ( cell ) {
56
+ await cell . scrollIntoView ( )
57
+ await cell . boundingBox ( )
58
58
await cell . scrollIntoView ( )
59
59
const rect = await cell . boundingBox ( )
60
60
if ( rect == null ) {
61
61
throw new Error ( `Cell ${ cell_id } is not visible` )
62
62
}
63
- const imgpath = path . join ( screenshot_dir , `${ cell_id } .png` )
64
63
65
- await cell . screenshot ( { path : imgpath , clip : { ...rect , scale } , omitBackground : false } )
66
- console . log ( `Screenshot ${ cell_id } saved to ${ imgpath } ` )
64
+ if ( screenshot_dir != null ) {
65
+ const imgpath = path . join ( screenshot_dir , `${ cell_id } .png` )
66
+
67
+ await cell . screenshot ( { path : imgpath , clip : { ...rect , scale } , omitBackground : false } )
68
+ console . log ( `Screenshot ${ cell_id } saved to ${ imgpath } ` )
69
+ }
67
70
}
68
71
}
69
72
}
0 commit comments