Giter Club home page Giter Club logo

pdf-generator's Introduction

pdf-generator

This Express.js service will serve a PDF generated by a headless Chrome for 2 cases :

  • from an arbitrary URL
  • from a HTML string, provided in the body of a POST request

You can fork this repo to deploy your own PDF generator on Scalingo

There is a github action that will automatically deploy your app on Scalingo when you push on the main branch.

You will need to provide the following environment variables (in the github repo settings):

Variables : APP_NAME: the name of the app on scalingo REGION: the region of the app on scalingo TARGZ_URL: the url of the tar.gz archive of the app to deploy

Secret : SCALINGO_API_TOKEN: Which should be a token with the correct rights to deploy the app mentionned in the variables.

Usage

  • To get a PDF named monpdf.pdf for the page http://mon-service.com/mapage, you have to set the PAGE_URL_PREFIX environment variable to http://mon-service.com and create a link like:
  <a href="https://<thisservicehostname>/print?page=%2Fmapage&name=monpdf.pdf">Download PDF</a>
  • The /ping endpoint can be used as a heartbeat for the service. It will return the string "ok" and a 200 status code.

Installation on Scalingo

  • Create a Scalingo application linked to the repository.

    as concurrency is not managed by this service, you should probably use S or M type containers. More information in the nodejs-buildpack documentation

  • Setup the environnement variables:

    • STACK should be set to heroku-18
    • PAGE_URL_PREFIX should be set to the prefix of the URL you'll want to print (see Usage)
    • PDF_NAME should be the default downloaded PDF filename; it will be used in case the name query var is missing

Future improvements

  • The generated PDF should probably be cached

pdf-generator's People

Contributors

cedricr avatar jeromebu avatar enguerranws avatar dependabot[bot] avatar

Stargazers

Benjamin Bohec avatar ikarius avatar  avatar Emmanuel Salomon avatar Julien Bouquillon avatar Vincent Agnano avatar Augustin avatar

Watchers

Julien Bouquillon avatar Jérémy Buget avatar Andrei Bocan avatar Alexandre CANTIN avatar  avatar Celine Ung avatar  avatar

Forkers

augustin82

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.