Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/stephane-klein/gibbon-pdf
Generate PDF with Template and JSON Schema
https://github.com/stephane-klein/gibbon-pdf
api form json-schema pdf-generation puppeteer
Last synced: 27 days ago
JSON representation
Generate PDF with Template and JSON Schema
- Host: GitHub
- URL: https://github.com/stephane-klein/gibbon-pdf
- Owner: stephane-klein
- Created: 2019-08-06T07:34:42.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-07-13T03:12:55.000Z (over 1 year ago)
- Last Synced: 2024-04-13T04:26:44.756Z (9 months ago)
- Topics: api, form, json-schema, pdf-generation, puppeteer
- Language: JavaScript
- Homepage:
- Size: 1.94 MB
- Stars: 9
- Watchers: 3
- Forks: 2
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Gibbon-pdf
Docker image: https://hub.docker.com/r/spacefill/gibbon-mail
Generate PDF with Template and JSON Schema.
Project status: [POC](https://en.wikipedia.org/wiki/Proof_of_concept)
Screencast: https://www.youtube.com/watch?v=2M10x76f6c8
## Requirement:
- [nodejs](https://nodejs.org) `14.16.X`
- [Docker](https://www.docker.com/)## Why this project?
- I would like to move PDF generation from my application in a separate service
- I would like to allow humans to generate PDF manually, via a simple application plugged to the same API.
- I would like to keep a history (optionally) of all document generated## Roadmaps
- [x] Integrate [`mozilla-services/react-jsonschema-form`](https://github.com/mozilla-services/react-jsonschema-form)
- [x] Integrate [`puppeteer`](https://github.com/GoogleChrome/puppeteer/)
- [x] Docker Image (`harobed/poc-generate-pdf-with-html-template-and-jsonschema:latest`)
- [x] curl example
- [x] Screencast
- [ ] Add S3 upload option
- [ ] Add [UISchema](https://react-jsonschema-form.readthedocs.io/en/latest/) support
- [ ] Check json input with JSON Schema
- [ ] Test frontend
- [X] Configure CI
- [ ] Swagger
- [ ] Add option to save generated pdf (in PostgreSQL)## Docker Image
[`spacefill/gibbon-pdf`](https://hub.docker.com/r/spacefill/gibbon-pdf) Docker
Image is automatically builded with with our CI. We currently maintain several versions
as we use [`semver`](https://semver.org/) to tag our docker images- `latest` tag is pushed with the last commit on `master`
- `vX.X.X` tag are pushed when we push a new tagTo see how to create a new tag see ["How to publish a new version"](/README.md#how-to-publish-a-new-version)
## Features
- Generate PDF file from:
- HTML template
- Json field values (validated by [JSON Schema](https://json-schema.org/))
- Rest API endpoints to generate html preview or PDF
- Web UI to generate PDF manually:
- HTML form are autogenerated by [JSON Schema](https://json-schema.org/)
- User can preview the document or generate the PDF
- Optionnaly record all PDF generation### How does the multi-language support works?
Inside your pdf templates folders, you can create multiple languages files for the same pdf, in the following format: `{lang}.html`.
You also need to let a default file in case the language is not found or no language is requested.
So, for example, your folder should look something like this:
```
$ ls pdf-templates/pdf-example
default.html de.html fr.html es.html
```Then, you can add the `lang` property to the body or query params of your request, which will send the pdf with the requested language if it exists.
For example, the following body will try to send a german pdf:
```
{
...,
"lang": "de"
}
```If the `lang` property is not present in the body of your request, the default pdf will be sent.
## This project is based on this stack
- [Backend](backend/):
- [NodeJS](https://nodejs.org/en/) with [Koa](https://koajs.com/)
- [Nunjucks](https://mozilla.github.io/nunjucks/) to fill PDF Html templates
- [puppeteer](https://github.com/GoogleChrome/puppeteer) to rendering PDF documents (Chrome Engine)
- [Frontend](frontend/)
- [ReactJS](https://en.reactjs.org/), [Axios](https://github.com/axios/axios), [React-router](https://github.com/ReactTraining/react-router)
- [react-jsonschema-form](https://github.com/mozilla-services/react-jsonschema-form) to generate Form from JSON Schema (need Bootstrap version `v3.3.6`)
- [Bootstrap](https://getbootstrap.com/)
- Tooling
- [Jest](https://jestjs.io/) and [supertest](https://github.com/visionmedia/supertest) for backend tests
- [ESLint](https://eslint.org/)## FAQ
### How can I enable Authentication system?
This project hasn't build-in authentication system, it's a internal service in your stack,
you must protect it by a private network or [Basic access authentication](https://en.wikipedia.org/wiki/Basic_access_authentication) system.### Why « Gibbon-pdf » name?
[Gibbon](https://en.wikipedia.org/wiki/Gibbon) as an allusion to [Mandrill App](https://mandrill.com/).
---
Invoice examples:
- https://www.sparksuite.com/open-source/invoice.html
Compare with other projects:
- [athenapdf](https://github.com/arachnys/athenapdf)