Would you like to clone this notebook?

When you clone a notebook you are able to make changes without affecting the original notebook.


puppeteer express PDF export

node v8.17.0
version: 1.0.0
const puppeteer = require ('puppeteer'); //const express = require('express'); var express = require("@runkit/runkit/express-endpoint/1.0.0"); var app = express(exports); const browser = await puppeteer.launch({args: ['--no-sandbox']}); // usually you don't need this options, this are for running on runkit properly const main = async () => { const page = await browser.newPage(); await page.goto('https://example.com'); const pdf = await page.pdf(); return pdf; } app.get('/', async function (req, res) { const pdf = await main(); res.contentType("application/pdf"); res.send(pdf); }); /* not required on runkit app.listen(3000, function(){ console.log('Listening on 3000'); }); */

no comments

    sign in to comment