Converto is a Strapi base solution for converting HTML to PDF. It can take either raw HTML or an URL as input, and will return an PDF generated on headless Chrome (Puppeteer).
Security warning: This solution does no checks on the html sent for conversion, make sure you trust HTML sent in to the solution. It is not secure, and should only be used for development purposes.
This solution exposes this API, which takes html as an input, and returns an pdf generated by headless Chrome (Puppeteer).
POST /api/pdfcreo
The postdata should contain either:
- url The url to make pdf from
OR
- html The html to make pdf from
The header should contain:
- Authorization with api token
Optional fields:
- scale: The scale of print. Should be a number between 0.2 and 2. Default is 1.
- format: The paper format. Default is A4.
Both methods require Authorization: Bearer <JWT token>
header. To obtain an jwt token
you create an API token through the admin panel and pass it directly as a bearer token.
- Clone the repo, and run
yarn install
in the project folder. - Run Strapi with Converto with the command
yarn develop
- Login on
localhost:1337/admin
, and create a new user. - Go to
Settings
, andApi tokens
. Get an API token with permission on pdfcreo. - Add the token to the header as a bearer token, and send your request to `localhost:1337/api/pdfcreo``
Find more documentation on the API, with an Postman Collection.
We have a Docker image available on Docker Hub.