PdfTurtle generates PDF reports and documents from HTML templates or raw HTML.
Try it! Here's a DEMO__π’__.
- β Free, OpenSource and Self-Hosted
- π¬ Generate PDFs in a descriptive way from HTML and CSS (with JavaScript support)
- β¨ Supports modern HTML and CSS standards (uses latest Chromium engine)
- π» Builtin template engines (go-template, raymond and django)
- πΌ Bundle template and assets in ZIP file (see Bundle workflow)
- π Fast generation with limited resources (limited multithreading)
- π₯ Multiple replicas supported (stateless service design)
- π₯ Frontend (Playground) for rapid development
- π« Beautiful fonts included and preoptimized style (CSS) for PDF or print
- π¦ Container image available (see Run with docker)
The container image is available on Docker Hub.
With the tag *-playground you get a bundled image with the web playground.
docker pull lucasgaitzsch/pdf-turtle
docker run -d \
-p 8000:8000 \
--name pdf-turtle \
--restart unless-stopped \
lucasgaitzsch/pdf-turtle
Included fonts:
- Open Sans
- Roboto
- Noto Emoji
command line argument | environment variable | type | default | description |
---|---|---|---|---|
--help | - | - | - | Show help |
--logDebug | LOG_LEVEL_DEBUG | boolean | false | Debug log level active |
--logJsonOutput | LOG_JSON_OUTPUT | boolean | false | Json log output |
--renderTimeout | RENDER_TIMEOUT | integer | 30 | Render timeout in seconds |
--workerInstances | WORKER_INSTANCES | integer | 30 | Count of worker instances |
--port | PORT | integer | 8000 | Server port |
--maxBodySize | MAX_BODY_SIZE | integer | 32 | Max body size in megabyte |
--servePlayground | SERVE_PLAYGROUND | boolean | false | Serve playground from path "./static-files/playground/" |
--secret | SECRET | string | "" | Secret used as bearer token |
flowchart LR
subgraph PG[PdfTurtle-Playground]
direction LR
O(go to<br>pdfturtle.gaitzsch.dev) --> |go to model tab| MO(paste an<br> example model)
click O href "https://pdfturtle.gaitzsch.dev" "https://pdfturtle.gaitzsch.dev"
O --> |go to body tab| B(design the body)
O --> |go to header tab| H(design the header)
O --> |go to footer tab| F(design the footer)
O --> |go in asstes menu| A(put your assets)
OPT(set your<br> options)
MO --> OPT
B --> OPT
H --> OPT
F --> OPT
A --> OPT
OPT --> S(fa:fa-file-zipper save as<br> ZIP bundle)
end
subgraph YP[your fancy project]
direction TB
PA(provide as asset)
PA-->CL(use clent lib)
PA-->SGC(use swagger to<br> build or generate client)
R(render PDF with<br> bundle and your model)
CL-->R
SGC-->R
R-->BH(fa:fa-smile be happy!)
end
S-->|copy zip bundle<br> to your project|YP
%%PG-->YP
Choose the fitting client lib for your language or generate / build your own by the OpenApi (Swagger) description.
Go to π’PdfTurtle-Playground, put an example model as JSON and design your PDF. Download the bundle as ZIP file and put it in your resources/assets.
Send a request to a PdfTurtle instance with your bundle and your model. You will get a rendered PDF.
And thats it.
If you want to have the same header for all documents, you can create a ZIP file with with only the header.html and the required assets. Now you can call the Service with multiple bundle files. The service will assemble the files together. Single files can be send as bundle-component without compressing to a ZIP file. All files with other names than "index.html", "header.html", "footer.html" and "options.json" will be put to the folder "/assets/".
You can write and test templates with the builtin playground.
Use Swagger-UI under /swagger/index.html as API documentation.
You can use the swagger description (/swagger/doc.json or ./server/docs/swagger.json) to generate a API client for the language of your choice.
You can import the swagger file to test the service with Postman or an alternative.
Template style | Package | PdfTurtle key | URL |
---|---|---|---|
Golang | html/template | golang | https://pkg.go.dev/html/template |
Django-syntax like (require model. prefix) | pongo2 | django | https://github.com/flosch/pongo2 |
Handlebars-syntax like | raymond | handlebars | https://github.com/aymerick/raymond |
Function name | Parameters | Description |
---|---|---|
marshal | object | Encodes provided object as JSON string |
barcodeQr | content | Renders a SVG QR code from content |
barcodeEan | content | Renders a SVG EAN code from content |
strContains | haystack, needle | Does the haystack contains the needle |
strHasPrefix | haystack, needle | Does the first string starts with the second |
strHasSuffix | haystack, needle | Does the first string end with the second |
add | float64, float64 | Adds two float64 numbers |
subtract | float64, float64 | Subtracts two float64 numbers |
multiply | float64, float64 | Multiplies two float64 numbers |
divide | float64, float64 | Divides two float64 numbers |
float64ToInt | float64 | Convert a int to float64 |
intToFloat64 | int | Convert a float64 to int |
bitwiseAnd | int, int | a & b |
See README_DEV.md.
- Bundle/Package support for exchangeable templates
- Client libs
- .NET Standard 2.0 (.NET Core 2.0 & .NET Framework 4.6.1 )
- Golang
- Kotlin, Java (JVM languages)
- ..?
- Markdown to PDF
- Preload and cache JavaScript libs
Contributors are welcome! Feel you free to fork the project and open a pull request.
If you wrote a client lib for a uncovered language please contact me. I will create a repo for you or link your client lib in this readme file.