Skip to content

losol/converto

Repository files navigation

Converto

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.

What is this?

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.

Get started

  1. Clone the repo, and run yarn install in the project folder.
  2. Run Strapi with Converto with the command yarn develop
  3. Login on localhost:1337/admin, and create a new user.
  4. Go to Settings, and Api tokens. Get an API token with permission on pdfcreo.
  5. 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.

Docker

We have a Docker image available on Docker Hub.