Skip to content

A web service for converting markdown to PDF

License

Notifications You must be signed in to change notification settings

spawnia/md-to-pdf

Repository files navigation

md-to-pdf

A web service for converting markdown to PDF

Web UI

For quick experimentation, you can use the web version hosted on Fly.io. Just paste your markdown and download the converted PDF.

Availability of the service is not guaranteed, see Fly.io status when it is down. If you need guaranteed availability, deploy it yourself.

API

You can convert markdown by sending a POST request to https://md-to-pdf.fly.dev.

curl --data-urlencode 'markdown=# Heading 1' --output md-to-pdf.pdf https://md-to-pdf.fly.dev
Parameter Required Description
markdown Required The markdown content to convert
css Optional CSS styles to apply
engine Optional The PDF conversion engine, can be weasyprint, wkhtmltopdf or pdflatex, defaults to weasyprint

Send data from files like this:

curl --data-urlencode "markdown=$(cat example.md)" 

Deploy

A prebuilt container image is available at Docker Hub. The container starts up the web service and listens for HTTP on port 8000.

You can run it yourself like this:

docker run --publish=8000:8000 spawnia/md-to-pdf

You may configure the webserver through Rocket environment variables. For example, you could allow larger payloads by increasing the limit for form data:

ROCKET_LIMITS={form="1MiB"}

Built with