Coder Social home page Coder Social logo

bardbess / wkhtmltopdf_binary_gem Goto Github PK

View Code? Open in Web Editor NEW

This project forked from zakird/wkhtmltopdf_binary_gem

0.0 1.0 0.0 1.17 GB

Ruby gem containing easily installable access to wkhtmltopdf application

Home Page: https://rubygems.org/gems/wkhtmltopdf-binary

License: Apache License 2.0

Ruby 100.00%

wkhtmltopdf_binary_gem's Introduction

Installation and usage

Install in your Gemfile as usual

gem 'wkhtmltopdf-binary'

In many environments, this is all you need to do. This gem installs a binary stub that tries to determine which wkhtmltopdf binary will work on your system, and point to the packaged binary that most closely matches.

In some environments, invoking this binary will result in an error, saying the needed permissions are not available. This is because wkhtmltopdf-binary ships with gzipped binaries for many platforms, and then picks the appropriate one upon first use and unzips it into the same directory. So if your ruby gem binaries are installed here:

/usr/lib/ruby/versions/2.6/bin/

The various wkhtmltopdf-binaries will be installed here:

/usr/lib/ruby/versions/2.6/lib/ruby/gems/2.6.0/gems/wkhtmltopdf-binary-0.12.5.1/bin/

Giving write access whatever user is running your program (e.g. web server, background job processor), e.g. your own personal user in a dev environment, will fix the problem. After the binary is uncompressed, write access can be revoked again if desired.

chmod -R 777 /usr/lib/ruby/versions/2.6/lib/ruby/gems/2.6.0/gems/wkhtmltopdf-binary-0.12.5.1/bin/

Gem Development

Extracting binaries

Hints for extracting binaries from https://wkhtmltopdf.org/downloads.html (dpkg and rpm2cpio is available on Homebrew).

Debian/Ubuntu

dpkg -x wkhtmltox_0.12.5-1.trusty_amd64.deb .

CentOS

rpm2cpio wkhtmltox-0.12.5-1.centos7.x86_64.rpm | cpio -idmv

Archlinux/manjaro

tar -xf wkhtmltox-0.12.6-1.archlinux.x86_64.tar.xz

macOS

xar -xf wkhtmltox-0.12.5-1.macos-cocoa.pkg
cat Payload | gunzip -dc | cpio -i

Compression

Binaries should be compressed with gzip --best after extracting. The matching binary will be extracted on first execution of bin/wkhtmltopdf.

Testing with Docker

Make sure you have Docker and Docker Compose installed (see https://docs.docker.com/compose/install/ for more information).

There are Dockerfiles for the supported Linux based distributions under .docker. You can build them all with docker-compose build and run each individually with e.g. docker-compose run ubuntu_18.04.

There also is a rudimentary minitest test that simply invokes docker-compose run for each distribution and expects to see the output of wkhtmltopdf --version. Just run rake to run it.

You can clean up after testing with docker-compose down --rmi all.

wkhtmltopdf_binary_gem's People

Contributors

adamhunter avatar ahteshamtariq avatar artero avatar brissenden avatar butzopower avatar chriscz avatar dmitry avatar entretechno-jeremiah avatar filospateam avatar fraunigai avatar gabetax avatar j-miyake avatar jeroenj avatar jjb avatar joergschiller avatar juansegimenez avatar jvdp avatar kostadin avatar lostapathy avatar marzapower avatar ownadi avatar pedrofurtado avatar pitluga avatar rafaeldev avatar reiz avatar rylwin avatar tbugai avatar tsolar avatar unixmonkey avatar zakird avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.