Code Monkey home page Code Monkey logo

node-express-puppeteer-pdf-example's Introduction

Puppeteer PDF Example

This is a Docker example of using Puppeteer to Generate PDF Documents, there are some bonus stuff in this that could be adjusted to be really useful:

  • Base64 to HTML PDF Generation
  • Route Protection with API

Animated example of this app

Docker Deployment

I've created a image for this example that can be found here https://hub.docker.com/r/ctalke/node-express-puppeteer.

docker pull ctalke/node-express-puppeteer
docker run -d -p 3000:3000 --restart unless-stopped ctalke/node-express-puppeteer

Development Setup

Clone the repository, move into the directory, install all NPM Deps, and then crack open your editor.

git clone https://github.com/christopher-talke/node-express-puppeteer-pdf-example.git
cd node-expess-puppeteer-pdf-example
npm i
code .

To run the application in development, just run this command:

npm run dev

The Express application will open on https://localhost:3000

Docker Build

docker build -t puppeteer_in_docker .
docker run -p 3000:3000 puppeteer_in_docker

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Be nice, and don't be like this guy: Click Here

Author

@Christopher Talke

Contributors

@TMInnovations

License

MIT

node-express-puppeteer-pdf-example's People

Contributors

christopher-talke avatar dependabot[bot] avatar minoroffense avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

node-express-puppeteer-pdf-example's Issues

small fixes

Hi
I have used your project and I have added some small fixes at Puppeteer
I have also updated the Puppeteer version to the latest

Can I submit a PR? Or do you want to discuss what I have done?

Failed to launch chrome

Hey there,

just wanted to play around with your repo a bit. After starting up the docker image and trying to "Click here to print this page" the server complained with:

GET /generate-pdf?url=http://localhost:3000 - - ms - -
(node:21) UnhandledPromiseRejectionWarning: Error: Failed to launch chrome!
/app/node_modules/puppeteer/.local-chromium/linux-686378/chrome-linux/chrome: error while loading shared libraries: libXtst.so.6: cannot open shared object file: No such file or directory


TROUBLESHOOTING: https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md

    at onClose (/app/node_modules/puppeteer/lib/Launcher.js:348:14)
    at Interface.helper.addEventListener (/app/node_modules/puppeteer/lib/Launcher.js:337:50)
    at Interface.emit (events.js:194:15)
    at Interface.close (readline.js:379:8)
    at Socket.onend (readline.js:157:10)
    at Socket.emit (events.js:194:15)
    at endReadableNT (_stream_readable.js:1125:12)
    at process._tickCallback (internal/process/next_tick.js:63:19)(node:21) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)

I'd really like to see it workig. Could you maybe add the dependencies needed (libXtst.so.6)?

Thanks and all the best,
Thomas

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.