This service provides an API to generate PDFs using various tools.
To build the Docker container for this service, follow these steps:
-
Clone this repository:
git clone https://github.com/azettl/printcss-live-backend.git cd printcss-live-backend
-
Build the Docker image:
docker build -t printcss-live-backend .
With AH Formatter (needs to be an *.rpm.gz file):
docker build --build-arg AH_FORMATTER_FILE=AHFormatter.rpm.gz -t printcss-live-backend .
With BFO Publisher (needs to be the bfopublisher-bundle-*.jar file):
docker build --build-arg BFO_PUBLISHER_FILE=bfopublisher-bundle-1.3.jar -t printcss-live-backend .
With Typeset.sh (needs to be a *.phar file):
docker build --build-arg TYPESETSH_FILE=typesetsh.phar -t printcss-live-backend .
With all renderes:
docker build --build-arg AH_FORMATTER_FILE=AHFormatter.rpm.gz --build-arg BFO_PUBLISHER_FILE=bfopublisher-bundle-1.3.jar --build-arg TYPESETSH_FILE=typesetsh.phar -t printcss-live-backend .
-
Create SSL Cert:
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/privkey.pem -out /etc/ssl/certs/fullchain.pem
-
Run the container:
docker run -d -p 443:5000 --name printcss-live-backend-container -v /etc/ssl/certs/fullchain.pem:/opt/ssl/certs/fullchain.pem -v /etc/ssl/private/privkey.pem:/opt/ssl/private/privkey.pem printcss-live-backend
CORS
The default allowed origin is
http://localhost:*
, if you want to change it, pass the ALLOWED_ORIGIN parameter.docker run -d -p 5000:5000 -e ALLOWED_ORIGIN="http://yourhost:*" --name printcss-live-backend-container printcss-live-backend
/generate_pdf
POST
- tool (string, required): The PDF generation tool to use. Options: pdfreactor, prince, vivliostyle, pagedjs, weasyprint, ahformatter, bfopublisher, typesetsh
- input_file (file, required): The input HTML file to convert to PDF
- Success: Returns the generated PDF file
- Error: Returns an error message with status code 400 or 500
curl -X POST -F 'tool=weasyprint' -F 'input_file=@/path/to/your/input.html' http://localhost:5000/generate_pdf --output output.pdf
/supported_tools
GET
Returns a list of supported tools.
curl http://localhost:5000/supported_tools
For detailed API documentation in JSON format, send a GET request to the /generate_pdf
endpoint.
This service supports the following PDF generation tools:
Name | Website | License | |
---|---|---|---|
💰 | PDFreactor | https://www.pdfreactor.com/ | License |
💰 | Prince | https://www.princexml.com/ | License |
🆓 | Vivliostyle | https://vivliostyle.org/ | License |
🆓 | PagedJS | https://pagedjs.org/ | License |
🆓 | WeasyPrint | https://weasyprint.org/ | License |
💰 | AH Formatter | https://www.antennahouse.com/ | License |
💰 | BFO Publisher | https://publisher.bfo.com/ | License |
💰 | Typeset.sh | https://typeset.sh/ | License |
Each tool has its own strengths and may produce slightly different results. This docker container will help you to choose the tool that best fits your specific requirements.
There is no possibility to add the license keys for PDFreactor, AH Formatter and Prince yet.
- The service runs on port 5000 inside the container, which is mapped to port 443 on your host machine in the example run command above.
For any issues or feature requests, please open an issue on this GitHub repository.