// wget -qO- http://192.168.73.188:9001/p/Ransom-Headlessnesss-in-the-Design-stdin.js/export/html | node stdin.js stdin.pdf const htmlPdf = require('html-pdf-chrome'); const options = { port: 9222, // port Chrome is listening on printOptions: { printBackground: true, paperWidth: 8.267717, paperHeight: 11.69291, marginTop: 1, marginRight: 1, marginBottom: 1, marginLeft: 1 }, }; const outFile = process.argv[2]; const print = (data, options, out) => { htmlPdf.create(data, options).then((pdf) => pdf.toFile(out)); console.log('printed to ' + out); } 'Read from stdin...' console.log("Reading data from stdin"); const stdin = process.stdin; stdin.resume(); stdin.once('data', data => { print(data, options, outFile); });