khalilgharbaoui / wkhtmltopdf-binary-edge-alpine

Alpine linux wkhtmltopdf binary ruby gem with qt patches
MIT License
14 stars 10 forks source link
alpine-linux docker html linux pdf pdf-generation pdf-generator rails ruby wkhtmltopdf

wkhtmltopdf-binary-edge-alpine

Don't need Alpine Linux support? please use this gem instead!

If you are using wkhtmltopdf on heroku, please use this gem instead!

Supported OS

Installation

In your Gemfile:

gem 'wkhtmltopdf-binary-edge-alpine', '~> 0.12.6.3', github: 'khalilgharbaoui/wkhtmltopdf-binary-edge-alpine'

Docker dependencies for Alpine Linux

Add this layer in your Dockerfile:

# Install dependencies for wkhtmltopdf
RUN apk add --update --no-cache --wait 10 \
  libstdc++ \
  libx11 \
  libxrender \
  libxext \
  libssl1.1 \
  ca-certificates \
  fontconfig \
  freetype \
  ttf-dejavu \
  ttf-droid \
  ttf-freefont \
  ttf-liberation && \
  apk add --update --no-cache --virtual .build-deps \
  msttcorefonts-installer && \

# Install microsoft fonts
  update-ms-fonts && fc-cache -f && \

# Clean up when done
  rm -rf /tmp/* && apk del .build-deps

Current wkhtmltopdf version:

0.12.6 For Ubuntu & Mac OS

0.12.6 with qt patches For Alpine Linux

Extracted from surnet/alpine-wkhtmltopdf:3.15.0-0.12.6-small docker image:

docker run --rm --entrypoint cat \
surnet/alpine-wkhtmltopdf:3.15.0-0.12.6-small \
/bin/wkhtmltopdf > ./libexec/wkhtmltopdf-alpine-linux-amd64

See: wkhtmltopdf release notes

Known Issues:

Image is shrunk due to a zoom bug in the wkhtmltopdf binary version 0.12.5.0 when on Alpine Linux.

Workaround is to set the zoom: to exacly 1.3.

See: https://github.com/wkhtmltopdf/wkhtmltopdf/issues/4036

And also see: https://github.com/wkhtmltopdf/wkhtmltopdf/issues/4036#issuecomment-493812493

Contribute

Please feel free to open a issue or pull request with suggestions.

Credits

Based upon the following repos: