diff --git a/CHANGELOG.md b/CHANGELOG.md index 0fbd45ff8..b940ff550 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ This can also be enabled programmatically with `warnings.simplefilter('default', * [`Templates`](https://py-pdf.github.io/fpdf2/fpdf/Templates.html) can now be also defined in JSON files. * support to optionally set `wrapmode` in templates (default `"WORD"` can optionally be set to `"CHAR"` to support wrapping on characters for scripts like Chinese or Japanese) - _cf._ [#1159](https://github.com/py-pdf/fpdf2/issues/1159) - thanks to @carlhiggs * support for quadratic and cubic Bézier curves with [`FPDF.bezier()`](https://py-pdf.github.io/fpdf2/fpdf/Shapes.html#fpdf.fpdf.FPDF.bezier) - thanks to @awmc000 +- documentation on how to use `fpdf2` with [gunicorn](https://gunicorn.org/): [link to docs](https://py-pdf.github.io/fpdf2/UsageInWebAPI.html#gunicorn) * feature to identify the Unicode script of the input text and break it into fragments when different scripts are used, improving [text shaping](https://py-pdf.github.io/fpdf2/TextShaping.html) results * [`FPDF.image()`](https://py-pdf.github.io/fpdf2/fpdf/fpdf.html#fpdf.fpdf.FPDF.image): now handles `keep_aspect_ratio` in combination with an enum value provided to `x` * [`FPDF.write_html()`](https://py-pdf.github.io/fpdf2/fpdf/fpdf.html#fpdf.fpdf.FPDF.write_html): now supports CSS page breaks properties : [documentation](https://py-pdf.github.io/fpdf2/HTML.html#page-breaks) diff --git a/docs/UsageInWebAPI.md b/docs/UsageInWebAPI.md index e7232bdca..f49841dac 100644 --- a/docs/UsageInWebAPI.md +++ b/docs/UsageInWebAPI.md @@ -49,6 +49,28 @@ def hello_world(): ``` +## gunicorn ## +[Gunicorn 'Green Unicorn'](https://gunicorn.org/) is a Python WSGI HTTP Server for UNIX. + +The following code can be placed in a `gunicorn_fpdf2.py` file and launched using `gunicorn -w 4 gunicorn_fpdf2:app`: + +```python +from fpdf import FPDF + +def app(environ, start_response): + pdf = FPDF() + pdf.add_page() + pdf.set_font("Helvetica", size=12) + pdf.cell(text="Hello world!") + data = bytes(pdf.output()) + start_response("200 OK", [ + ("Content-Type", "application/pdf"), + ("Content-Length", str(len(data))) + ]) + return iter([data]) +``` + + ## AWS lambda ## The following code demonstrates some minimal [AWS lambda handler function](https://docs.aws.amazon.com/lambda/latest/dg/python-handler.html) that returns a PDF file as binary output: