This repository has been archived on 2020-04-29. You can view files and clone it, but cannot push or open issues or pull requests.
namensschilder/print.js
Simon Bruder 9202a01802
All checks were successful
continuous-integration/drone/push Build is passing
new proportions
2019-03-28 18:15:35 +00:00

25 lines
594 B
JavaScript

const puppeteer = require('puppeteer');
const process = require('process')
const name = process.argv[2];
(async () => {
const browser = await puppeteer.launch({
args: [
'--no-sandbox',
'--disable-setuid-sandbox'
]
})
const page = await browser.newPage()
await page.goto('file://' + process.cwd() + '/namensschild.html', {waitUntil: 'networkidle2'})
await page.$eval('#name', (el, name) => { el.innerText = name; setSize() }, name)
await page.pdf({
path: `static/namensschild.pdf`,
width: '180px',
height: '60px'
})
await browser.close()
})()