Coder Social home page Coder Social logo

serverless-pdf-generator's Introduction

PDF generator built as a serverless application.

Runs on AWS Lambda, built with the Serverless Framework and Lift.

Why?

This is a small application that turns web pages into PDF.

  • Turns HTML pages to PDF using Chrome Headless and Puppeteer
  • Runs on AWS Lambda: extremely cheap, deploys in 1 minute, scales automatically
  • Generated PDFs are cached in AWS S3 to be served faster

This allows to generate PDF files by simply implementing web pages in your application.

Clear and simple API for your application:

https://123456.execute-api.us-east-1.amazonaws.com/pdf?url=<URL to export>

Demo

Try the live demo:

https://7f3oaopd3c.execute-api.us-east-1.amazonaws.com/pdf?url=https://bref.sh/docs/

โ˜๏ธ the link above will export the bref.sh/docs/ page into a PDF.

Feel free to change the URL to export. However, the demo only allows generating PDF from the bref.sh domain.

Deployment

The URL of the deployed application should display in the terminal.

Usage

Call the application's URL and append the ?url= query parameter with the URL of the page you wish to export.

For example:

https://123456.execute-api.us-east-1.amazonaws.com/pdf?url=https://mywebsite.com/

The exported PDF will be returned.

Force regeneration

PDF are generated on the first HTTP call and cached into S3. That makes subsequent responses much faster.

To force regenerating the PDF (for example if the web page has changed), add the force=1 query parameter to the URL.

Configuration

Change the DOMAIN_WHITELIST environment variable to set the whitelisted domains.

Indeed, to avoid abuse, the application will only generate PDFs from pre-approved domain names.

serverless-pdf-generator's People

Contributors

mnapoli avatar

Watchers

 avatar

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.