-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_pdf.js
33 lines (30 loc) · 1.33 KB
/
build_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
let puppeteer = require('puppeteer')
let fs = require('fs-extra')
let path = require('path')
let margin = '0.5in'
;(async () => {
let browser = await puppeteer.launch()
let page = await browser.newPage()
await page.goto(`file:${path.join(__dirname, 'out/index.html')}`, {
waitUntil: 'networkidle2',
})
await page.addStyleTag({
content:
'html { font-size: 12px; line-height: 18px; } body { padding-left: 0; } .content { padding: 0; width: 100%; } .table-of-contents { position: relative; background: white; width: 100%; height: auto; page-break-before: always; font-size: 12px !important; line-heignt: 18px !important; } .table-of-contents a { text-decoration: underline; } #toc-header { display: none !important; } figcaption { font-size: 10px; line-height: 18px; } #report-splash { display: none; } #explanation { display: none; } table { font-size: 8px; line-height: 12px; } #report-iso { display: block; margin-top: 160px; } #html-logo { display: none !important; } #pdf-logo { display: block }',
})
await page.pdf({
path: 'out/ff06-2020-interpretability.pdf',
height: '8.5in',
width: '5.5in',
displayHeaderFooter: false,
headerTemplate: '',
printBackground: true,
margin: {
top: margin,
left: margin,
right: margin,
bottom: margin,
},
})
await browser.close()
})()