Skip to content

Blazing fast Docker microservice for wkhtmltopdf and wkhtmltoimage

License

Notifications You must be signed in to change notification settings

picap-inc/wkhtmltopdf-microservice

 
 

Repository files navigation

wkhtmltopdf-microservice

Blazing fast Docker microservice for wkhtmltopdf and wkhtmltoimage

GitHub Stars Docker Pulls Docker Stars Issues MIT licensed

Docker image

https://hub.docker.com/r/umex/wkhtmltopdf-microservice

# Check the latest image version tag at Docker Hub
image: umex/wkhtmltopdf-microservice:1.2-alpine

Docker service

Quick test

docker run -p 9100:9100 --name wkhtmltopdf umex/wkhtmltopdf-microservice:1.2-alpine 

If you just use it internally within your Docker network, it is not required (and not recommendable) to expose the port.

For example: Your service any_backend can make HTTP requests to http://wkhtmltopdf:9100/pdf.

services:
   any_backend:
      image: superman/any_backend:latest
      ports:
         - "80:80"
      
   wkhtmltopdf:
      container_name: wkhtmltopdf_service
      image: umex/wkhtmltopdf-microservice:1.2-alpine
      restart: unless-stopped

Environment

wkhtmltopdf:
   environment:
      # Default max body size
      MAX_BODY: '50mb'
      # Max requests per minute
      MAX_REQUESTS: 100
      NODE_PORT: 9100

Check service is running

To test if the service is available, you can simply send a GET request to the service and should see a landing page. If you do this from your local browser, you need to expose the service port first.

GET http://localhost:9100
GET http://wkhtmltopdf:9100

Create PDF

POST http://localhost:9100/pdf
POST http://wkhtmltopdf:9100/pdf

PDF options: https://www.mankier.com/1/wkhtmltopdf

# JSON POST body
   
{
    "html": "<html><body><h1 style=\"color: red;\">HI I AM HERE</h1></body></html>",
    "wkConfig": {
        "dpi": "1200",
        "grayscale": true,
        "disableSmartShrinking": true,
        "imageQuality": 100,
        "pageWidth": 400,
        "pageHeight": 280,
        "marginTop": 0,
        "marginBottom": 0,
        "marginLeft": 0,
        "marginRight": 0
    }
}

Create IMAGE

POST http://localhost:9100/img
POST http://wkhtmltopdf:9100/img

Image options: https://www.mankier.com/1/wkhtmltoimage

# JSON POST body
   
{
   "html": "<html><body><h1 style=\"color: red;\">HI I AM HERE</h1></body></html>",
   "wkConfig": {
      "width": 400,
      "height": 280,
      "quality": 100
   }
}

Open source

Credits

About

Blazing fast Docker microservice for wkhtmltopdf and wkhtmltoimage

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 56.5%
  • Shell 33.1%
  • Dockerfile 10.4%