Django library for invoking splat
Project description
splat
splat is simple aws lambda function that takes HTML/CSS/JS, invokes PrinceXML to render it and returns the resulting PDF in one of many ways.
It is intended to be a DIY docraptor of sorts.
Installation
Simply build the docker image, deploy it to AWS, then invoke the lambda with an event body JSON that performs the desired operation. For example: {"document_content": "<h1>Hello, World!</h1>"}
Ways of invoking splat
Input
Pass content in event: {"document_content": "<h1>Hello, World!</h1>"}
Pass content via URL: {"doucment_url": "<h1>Hello, World!</h1>"}
Output
Returns PDF base64 encoded by default.
To save to an s3 bucket (lambda requires permission): {"bucket_name": "<BUCKET>"}
To save to a presigned url: {"presigned_url": "<URL>"}
Options
To enable Javascript: {"javascript": true}
PrinceXML License
splat will attempt to install a PrinceXML license file by default. Just drop your license.dat
in the root directory before you build the docker container. The licence file is gitignored for your convenience.
If you do not have a licence file, Prince will watermark your PDFs, and you can only use them non-commercially. See their license page for more information.
You can check the status of the licence by invoking the lambda with the {"check_license": true}
option, and interpreting the response, you can use this to periodically check the status of the licence and raise an alert if it's about to expire, and to verify that your new licence has updated correctly.
Fonts
splat will add any fonts inside a fonts.zip
file. Ensure the zip file contains a folder called fonts
with all fonts inside. Simply drop into the root directory and build the docker container. The fonts.zip
file is gitignored for your convenience. By default, prince comes with a small suite of liberation fonts.
Library
Splat can be used via the uptick_splat
library. Install with pip install uptick_splat
.
Usage:
from uptick_splat import configure_splat, pdf_with_splat
configure_splat(
function_region="ap-southeast-2",
function_name="splat",
default_bucket_name="your-bucket-to-upload-html-to",
)
some_html = "<h1>test</h1>"
pdf_with_splat(some_html, bucket_name="test_bucket")
# or
pdf_with_splat(some_html)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file uptick_splat-0.1.8.tar.gz
.
File metadata
- Download URL: uptick_splat-0.1.8.tar.gz
- Upload date:
- Size: 5.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.2 CPython/3.11.3 Darwin/21.3.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5b6d31b941650cc501307d8bca0f5416eee90a595c3169b692f8985c54829dd7 |
|
MD5 | 3ec1ca62ca537f6445d27f4af04756ee |
|
BLAKE2b-256 | f68dda870c950da2935b4aaf799d36901ec9b0cfa4c8f0f2dc39f131b8d44e23 |
File details
Details for the file uptick_splat-0.1.8-py3-none-any.whl
.
File metadata
- Download URL: uptick_splat-0.1.8-py3-none-any.whl
- Upload date:
- Size: 6.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.2 CPython/3.11.3 Darwin/21.3.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 02562fd8e2049c5e3c13e6b39c89e1bd281e12b5d4cfa9f60b3c59c817393b62 |
|
MD5 | 931a18e397c40b6d385b3b7acd9d9963 |
|
BLAKE2b-256 | 46f9f8f18963be0646f6e2fe0346e37d98e3afc51d8521cdd9c545ff9932b03b |