Giter Site home page Giter Site logo

zakird / wkhtmltopdf_binary_gem Goto Github PK

View Code? Open in Web Editor NEW
179.0 179.0 343.0 1.34 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 People

Contributors

adamhunter avatar ahteshamtariq avatar bobvanoorschot avatar brissenden avatar butzopower avatar chriscz avatar cromega avatar dmitry avatar edgardoburgos94 avatar elyalvarado avatar entretechno-jeremiah avatar filospateam avatar fraunigai avatar gabetax avatar haegin avatar jeroenj avatar joergschiller avatar lostapathy avatar marzapower avatar mikekosulin avatar motomasini avatar ownadi avatar pedrofurtado avatar qwlong avatar rafaeldev avatar sriram2520 avatar tbugai avatar unixmonkey avatar willnet avatar zakird avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

wkhtmltopdf_binary_gem's Issues

"Could not find 'wkhtmltopdf-binary'" error

I just updated my project's Gemfile to pull the latest version of this gem from GitHub. I then bundle installed, which installed the binary:

> which wkhtmltopdf
/Users/jacobevelyn/.gem/ruby/2.0.0/bin/wkhtmltopdf

However, when I try to use the binary, I get this:

> wkhtmltopdf --version
/Users/jacobevelyn/.rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/dependency.rb:298:in `to_specs': Could not find 'wkhtmltopdf-binary' (>= 0) among 814 total gem(s) (Gem::LoadError)
    from /Users/jacobevelyn/.rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/dependency.rb:309:in `to_spec'
    from /Users/jacobevelyn/.rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_gem.rb:53:in `gem'
    from /Users/jacobevelyn/.gem/ruby/2.0.0/bin/wkhtmltopdf:22:in `<main>'

Any ideas as to where I might be going wrong?

Idea: Ship `upx`-compressed executables?

Using upx on shipped wkhtmltopdf binaries drastically reduces their size. Each of the binaries (linux x86, linux x86_64, darwin x86) reduces to about 15MB. And with modern CPUs the decompression time doesn't matter - but there is less I/O involved.

Can a binary for ubuntu 20.04 be added?

I'm getting an error that says:

Invalid platform, must be running on Ubuntu 16.04/18.04/20.04 CentOS 6/7/8, Debian 9/10, or intel-based Cocoa macOS (missing binary: /home/johnjin0000/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/wkhtmltopdf-binary-0.12.6/bin/wkhtmltopdf_ubuntu_20.04_amd64)

But I am using an ubuntu 20.04 machine, so it would be nice if a binary for 20.04 can be added

Syntax error: word unexpected (expecting ")")

In production server (ubuntu 14.04) getting this error

$ wkhtmltopdf http://www.google.com google.pdf

/usr/local/rvm/gems/ruby-2.5.1/gems/wkhtmltopdf-binary-0.12.4/bin/wkhtmltopdf_linux_x86: 1: /usr/local/rvm/gems/ruby-2.5.1/gems/wkhtmltopdf-binary-0.12.4/bin/wkhtmltopdf_linux_x86: Syntax error: word unexpected (expecting ")")

Any help? @zakird

Missing binary for Ubuntu 19.04

Invalid platform, must be running on Ubuntu 14.04/16.04/18.04 CentOS 6/7, Debian 8/9, or intel-based macOS (missing binary: /home/deploy/runnersconnect/shared/vendor/bundle/ruby/2.6.0/gems/wkhtmltopdf-binary-0.12.5/bin/wkhtmltopdf_ubuntu_19.04_amd64). (RuntimeError)

Had to uninstall this gem and go for manual solution.

wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.bionic_amd64.deb
sudo dpkg -i wkhtmltox_0.12.5-1.bionic_amd64.deb
sudo apt -f install

license blurb lines cause an error

The error in mac-os with ruby 2.0.0:

 * wkhtmltopdf_binary_gem Copyright 2013 The University of Iowa
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy
 * of the License at http:/
bin/wkhtmltopdf:13: unknown regexp option - l
bin/wkhtmltopdf:13: syntax error, unexpected '/', expecting :: or '[' or '.'
bin/wkhtmltopdf:15: syntax error, unexpected keyword_elsif, expecting end-of-input
elsif RbConfig::CONFIG['host_os'] =~ /darwin/

Runtime error on Windows 7

Error is happening when render pdf: "pdf_name" is called inside the controller.

RuntimeError at /reports/1/print
Bad wkhtmltopdf's path: bundler: command not found: which
Install missing gem executables with `bundle install`

Gems I am using - rails 4.2, wkhtmltopdf-binary 0.9.9.3, wicked_pdf 0.11.0.
I have tried upgrading gem to latest version pointing to Github master branch but that doesn't help.

wkhtmltopdf binary

Failed to extract binary

Error: PDF could not be generated!
 Command Error: /var/lib/gems/2.5.0/gems/wkhtmltopdf-binary-0.12.5/bin/wkhtmltopdf:34:in `initialize': Permission denied @ rb_sysopen - /var/lib/gems/2.5.0/gems/wkhtmltopdf-binary-0.12.5/bin/wkhtmltopdf_ubuntu_18.04_amd64 (Errno::EACCES)

A RoR app is using wkhtmltopdf-binary to generate PDFs from a web page. It was "bundle upgrade" upgraded earlier today and I started getting this error. I was able to HACK around the error by extracting the .gz file manually:

cd /var/lib/gems/2.5.0/gems/wkhtmltopdf-binary-0.12.5/bin/
gunzip wkhtmltopdf_ubuntu_18.04_amd64.gz

I'm also going to freeze the Gemfile file for my other servers to 0.12.4.

gem 'wkhtmltopdf-binary', '0.12.4'
  • I haven't tested locking the Gemfile yet.

Missing libpng12 in Amazon Linux2

Error on Amazon Linux 2.
error while loading shared libraries: libpng12.so.0: cannot open shared object file: No such file or directory

I resolved like this.

This is current code.
wkhtmltopdf_binary_gem/bin/wkhtmltopdf

           # CentOS 6 doesn't have `/etc/os-release`.
           if (os.empty? && File.read('/etc/centos-release').start_with?('CentOS release 6')) ||
               os.start_with?('amzn_')
             os = 'centos_6'
           end

I changed the code like this.

           if os.start_with?('amzn_2')
             os = 'centos_7'
           end

           # CentOS 6 doesn't have `/etc/os-release`.
           if (os.empty? && File.read('/etc/centos-release').start_with?('CentOS release 6')) ||
               (os.start_with?('amzn_') && !os.start_with?('amzn_2'))
             os = 'centos_6'
           end

New binary is a need to install the dependent libraries

Ubuntu 14.04 64-bit

sudo apt-get install libjpeg62 libfontconfig-dev

Ubuntu 14.04 32-bit

sudo apt-get install libjpeg-dev libfontconfig-dev

CentOS 7.0

sudo yum install libjpeg libpng12 libXrender libXext fontconfig

CentOS 6.3 64-bit

sudo yum install libjpeg libpng libXrender libXext fontconfig

CentOS 6.3 32-bit

wkhtmltopdf_linux_x86 -V
#=> wkhtmltopdf_linux_x86: error while loading shared libraries: libjpeg.so.8: cannot open shared object file: No such file or directory

sudo yum install libjpeg.so.8
#=> No package libjpeg.so.8 available.

Dependent libraries for 32-bit does not exist in the standard RPM repositories of CentOS.

I've tried creating a symlink, but it doesn't work:

ln -s /usr/lib/libjpeg.so.62 /usr/lib/libjpeg.so.8

wkhtmltopdf_linux_x86 -V
#=> /path/to/wkhtmltopdf_linux_x86: /usr/lib/libjpeg.so.8: version `LIBJPEG_8.0' not found (required by /path/to/wkhtmltopdf_linux_x86)
#=> /path/to/wkhtmltopdf_linux_x86: /lib/libc.so.6: version `GLIBC_2.15' not found (required by /path/to/wkhtmltopdf_linux_x86)

Do you have a solution?

Upgrade process and v1.2.2 pre release

The currently bundled version of wkhtmltopdf is v1.2.1. Since last week a lot of web hosts have disabled SSLv3 because of the POODLE attack.
wkhtmltopdf v1.2.1 (and earlier) still use SSLv3 by default. This has been changed in the current testing release (v1.2.2.testing).

I was having a look to create a patch with the updated (testing) binaries so we could use this pre version in our app right now (since we rely on assets deliverd over https with SSLv3 disabled). Is there any good way to update the bundled binaries? It seems that the osx one can be extracted from the pkg, but I have no idea how to do that for the linux binaries. One option is to start a vagrant box for each required release and extract the binary from there but would that be enough? It would be nice if there was some more information on how to udpate the binaries.

RUBY_PLATFORM on JRuby is 'java'

Currently the gem is using RUBY_PLATFORM to get the OS, so it can pick the right binary. On JRuby, this is always "java", because it's the only way we can differentiate gems for our platform:

$ jruby -e 'p RUBY_PLATFORM'
"java"

This prevents commands from working:

$ wkhtmltopdf 
RuntimeError: Invalid platform. Must be running linux or intel-based Mac OS.
  <main> at /Users/headius/projects/jruby/lib/ruby/gems/shared/gems/wkhtmltopdf-0.1.2/bin/wkhtmltopdf:8
    load at org/jruby/RubyKernel.java:1022
  <main> at /Users/headius/projects/jruby/bin/wkhtmltopdf:23

However we do support the (arguably more reliable) RbConfig::CONFIG['host_os'] which should work the same way for you:

$ jruby -e 'p RbConfig::CONFIG["host_os"]'
"darwin"

Changing the bin script to use this value instead of RUBY_PLATFORM would allow the gem to work on JRuby:

$ wkhtmltopdf ; echo $?
0
--- lib/ruby/gems/shared/gems/wkhtmltopdf-0.1.2/bin/wkhtmltopdf	2019-04-26 11:06:09.000000000 -0500
+++ lib/ruby/gems/shared/gems/wkhtmltopdf-0.1.2/bin/wkhtmltopdf-old	2019-04-26 11:05:41.000000000 -0500
@@ -1,10 +1,8 @@
 #!/usr/bin/ruby
 
-platform = RbConfig::CONFIG['host_os']
-
-if platform =~ /linux/
+if RUBY_PLATFORM =~ /linux/
   executable = 'wkhtmltopdf_linux_386'
-elsif platform =~ /darwin/
+elsif RUBY_PLATFORM =~ /darwin/
   executable = 'wkhtmltopdf_darwin_386'
 else
   raise "Invalid platform. Must be running linux or intel-based Mac OS."

πŸ‘

Dead repos ?

Do we need to use another gem or installing manually the new version ?

Thanks for your work.

Error while trying to install

Hello.

I am trying to install the gem. When I give
" gem install wkhtmltopdf_binary",
it gives me the error.
"NoMethodError: undefined method `size' for nil:NilClass" . And the installation files. Same when I try with bundler as well.

CHANGELOG, please

It would be nice to know what changes between two versions and at least if the version number follows semantic versioning...

doesn't work on Alpine

I'm using docker image ruby:2.6.3-alpine and this gem didn't work. To work, you have to install by apk add wkhtmltopdf

How to bump binary version?

From https://wkhtmltopdf.org/downloads.html I can see that OSX version comes in 32bit and 64bit .pkg and can be extracted from it.
For linux, there are individual files for ubuntu and debian 32 and 64 bit, and I guess we can extract the binary out of one?

Can someone write a script or instructions on how to extract these?
I can help with a PR for 0.12.5

20.04 support

I saw the changelog that it was added support for Ubuntu 20.04, but there is no binaries for this version on bin directory and I am getting some errors, for now I am duplicating the version 18.04 -> 20.04 directly in gem directory.

The version for 16.04 works perfectly on Ubuntu 18.04 and 20.04 (at least the amd64), and debian binaries also should work for ubuntu, so I suggest using same binary for then instead of using a 15~17mb for each ubuntu/debian version, and adding a hash to define wich binary to use should do the work.

Error with 0.12.6 Binary.

I'm hosting a website on PlatformSH which uses this gem to install the appropriate binary. It was updated to 0.12.6 and suddenly I got this error message:

Error generating document: Failed to generate PDF: /app/.global/gems/wkhtmltopdf-binary-0.12.6/bin/wkhtmltopdf:28:in `': undefined method `match?' for /deepin/:Regexp (NoMethodError) Did you mean? match from /app/.global/bin/wkhtmltopdf:22:in `load' from /app/.global/bin/wkhtmltopdf:22:in `'

No other code was changed apart from the binary version. I'm using a Drupal module called entity_print that uses the library phpwkhtmltopdf but the maintainer of that library did not think the issue was in that library but likely related to this gem.

Reverting to 0.12.5.4 fixed it for me.

Missing Support for Oracle Linux 7.8

Hello!

I'm trying to install Wkhtmltopdf on an Oracle Linux 7.8 (Fedora) Docker Container. After running

yum install xvfb -y
yum install libfontconfig -y
yum install wkhtmltopdf -y

Everything install fine. But then when I got to test wkhtmltopdf with wkhtmltopdf http://google.com google.pdf I get a runtime error.

/opt/app/vendor/bundle/ruby/2.6.0/gems/wkhtmltopdf-binary-0.12.5.4/bin/wkhtmltopdf:45:in `<top (required)>': Invalid platform, must be running on Ubuntu 14.04/16.04/18.04 CentOS 6/7/8, Debian 8/9/10, or intel-based macOS (missing binary: /opt/app/vendor/bundle/ruby/2.6.0/gems/wkhtmltopdf-binary-0.12.5.4/bin/wkhtmltopdf_ol_7.8_amd64). (RuntimeError)

Details on OS

NAME="Oracle Linux Server"
VERSION="7.8"
ID="ol"
ID_LIKE="fedora"
VARIANT="Server"
VARIANT_ID="server"
VERSION_ID="7.8"
PRETTY_NAME="Oracle Linux Server 7.8"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:oracle:linux:7:8:server"
HOME_URL="https://linux.oracle.com/"
BUG_REPORT_URL="https://bugzilla.oracle.com/"

ORACLE_BUGZILLA_PRODUCT="Oracle Linux 7"
ORACLE_BUGZILLA_PRODUCT_VERSION=7.8
ORACLE_SUPPORT_PRODUCT="Oracle Linux"
ORACLE_SUPPORT_PRODUCT_VERSION=7.8

Gem size 0.12.5

new version of gem much bigger than previous one

0.12.5 - November 07, 2019 (238 MB)
0.12.4 - June 11, 2018 (45.1 MB)

0.12.5 totally unreal use it on heroku

Gem installation failing on AWS EC2 instance

I am getting following error when during my application deployment on Amazon EC2. I tired upgrading the gem version to latest: 0.9.9.3. Still the same error persists. However, I could manually install the gem on EC2 instance using gem install command. Can you please confirm that this issue is related to AWS EC2 installation scripts alone? My other gems are installing fine though.


Gem::RemoteFetcher::FetchError: bad response backend read error 503 (https://rubygems.global.ssl.fastly.net/gems/wkhtmltopdf-binary-0.9.9.1.gem)
An error occurred while installing wkhtmltopdf-binary (0.9.9.1), and Bundler
cannot continue.
Make sure that gem install wkhtmltopdf-binary -v '0.9.9.1' succeeds before
bundling.
ERROR: bundle install failed!

Windows platforms?

Is there any way we can make this work on Windows?
wkhtmltopdf has Windows packages. Am I missing something here?

Missing support for Gentoo Linux

Invalid platform, must be running on Ubuntu 14.04/16.04/18.04 CentOS 6/7/8, Debian 8/9/10, or intel-based macOS
(missing binary: /shared/bundled_gems/ruby/2.5.0/gems/wkhtmltopdf-binary-0.12.5.4/bin/wkhtmltopdf_eygl_2016.06_amd64). (RuntimeError)

cat /etc/os-release:

NAME="Engine Yard Gentoo Linux"
ID=eygl
ID_LIKE=gentoo
VERSION_ID=2016.06
BUILD_ID=2016.06.018.final
PRETTY_NAME="Engine Yard Gentoo/Linux"
ANSI_COLOR="1;32"
HOME_URL="http://www.engineyard.com/"
SUPPORT_URL="https://support.cloud.engineyard.com/"
BUG_REPORT_URL="https://support.cloud.engineyard.com/

nfs errors indirectly caused by wkhtmltopdf

Our nfs server has been showing errors such as this:

rpc.mountd[2538]: authenticated mount request from OurNFSserver:864 for /homesrv/kalyptorisk.com (/homesrv)
rpc.mountd[2538]: can't stat exported dir /homesrv/kalyptorisk.com: No such file or directory

coming from servers using wkhtmltopdf_binary_gem. This is most likely an upstream problem from an earlier version of https://github.com/wkhtmltopdf/wkhtmltopdf -- It looks like it has been fixed in version 0.12.4

Missing binary for archlinux/manjaro

Missing binary forarchlinux/manjaro

Invalid platform, must be running on Ubuntu 14.04/16.04/18.04 CentOS 6/7/8, Debian 8/9/10, or intel-based macOS (missing binary: /home/yan/code/.asdf/installs/ruby/2.6.5/lib/ruby/gems/2.6.0/gems/wkhtmltopdf-binary-0.12.5.4/bin/wkhtmltopdf_manjaro__amd64

What do I need to make it work?

Can't deploy with capistrano

Hey there!

I'm having trouble using this gem with capistrano. I'm getting this error:

Bundler::GemNotFound: Could not find wkhtmltopdf-binary-0.12.5.4 in any of the sources

Any clue as to what could be causing this or a way to fix it?

Fillable PDFs generated from HTML form seem to stop working correctly after 0.12.3

Issue description
When generating fillable PDF from an HTML form, the fields are not editable via Adobe Acrobat in versions >0.12.3.

Expected or desired behavior
That fields are fillable in the PDF document.

System specifications
wkhtmltopdf 0.12.3 (with patched qt)

platform/distribution and version :
MacOSX 10.15.x

My current solution is to pin the version to 0.12.3.

Update to Version 0.12.1

The stable release has been bumped to 0.12.1 and includes a number of important features. Is this a fairly straight-forward thing to build or is there a lot of leg-work involved?

The current release of this gem bundles 0.9.9 which dates from 2010.

Please add support for debian 10 (buster)

It would be nice to support Debian 10 as this is the latest stable since 6 July 2019.

This is now the default distro/version for the official ruby images >= 2.6.5 to there is likely to be high demand as people update their dependencies in the coming weeks and months.

Happy to start a pr but I assume that only the maintainer/s are trusted to commit new binary files?

Not work in Alpine Linux

I'm using Docker image ruby:2.4-alpine and have installed this gem successful. I've found the binary files here /bundle/gems/wkhtmltopdf-binary-0.12.3.1/bin but when I try to cd to that path and enter ./wkhtmltopdf, and nothing to show. And I tried to change to Ubuntu (Docker image ruby:2.4) and it worked by showing Usage for wkhtmltopdf with same steps above.

Could you please suggest me what I'm wrong? Thanks!

Create README

README should explain how to install gem, and what the binary's dependencies are depending on their distribution.

Could not allocate register file

wkhtmltopdf http://www.google.com google.pdf
Loading pages (1/5)
2010-07-12 18:32:45.620 wkhtmltopdf_darwin_386[828] WARNING: _wrapRunLoopWithAutoreleasePoolHandler got kCFRunLoopExit, but there are no autorelease pools in the stack.
Could not allocate register file: 22

ruby 1.8.7 (2010-01-10 patchlevel 249) [i686-darwin8.11.1]
mac osx tiger 10.4.11

Adding binary into pure Ruby project

I'm currently trying to make use of the wicked_pdf gem, however, I'm not using Rails. I installed the /wkhtmltopdf_binary_gem but still don't see any binary in the bin folder. Would it make sense to install this manually into bin?

Screen Shot 2019-06-04 at 11 20 53 AM

I'm using PDFtk, I can maybe download the binary into the folder manually. What is suggested in this case?

I see that the path is ~/.rvm/gems/ruby-2.5.3/gems/wkhtmltopdf-binary-0.12.4/bin/wkhtmltopdf should I set the executable path to this?

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.