rposborne/wkhtmltopdf-heroku

Heroku-18 stack support

Closed this issue · 36 comments

Can we expect support on Heroku-18 stack?

As per my test, Heroku-18 is unable to print image in PDF document.

Please see #37 for instructions to add a buildpack to get this working on cedar-18

I'm adding more to this issue, since we bumped to Heroku-18, the PNG images are not rendered properly, while the JPEG are rendering fine.

image

We've tried multiple things:

  • Update the gem to the latest version
  • Move from wkhtmltopdf-binary to wkhtmltopdf-heroku (It's now our default test scenario)
  • Install additional packages with Aptfile that have been removed with Heroku-18, The following list:
libpng12-0
libpng12-dev
libmagickwand-6.q16-2
libmagickcore-6.q16-2
libmagickcore-6.q16-2-extra

None of the solution worked.

I've opened a ticket on Heroku, it has not been helpful for now.

image

Is someone experiencing the same issue? Would love to get some help on the matter. I've confirmed that the issue is linked to Cedar-18, we moved back to Cedar-16 and the issue is still happening.

I'm facing a similar issue with Font Awesome in PDF's since the upgrade to 18. I have a staging and production environment both on the 18 stack. The staging app is working fine but the production isn't. They are identical in setup ¯_(ツ)_/¯

@Erowlin been looking through these issue trackers all morning and trying stuff out. What works for Wicked_pdf_image_tag + heroku 18 is to use local files. If possible for your solution (static images), you can do what i did.

Change all
=wicked_pdf_image_tag 'https://s3-us-west-2.amazonaws.com/xxx/stamp.png', :class => "bottom-image" to
=wicked_pdf_image_tag 'logos/stamp.png', :class => "bottom-image"

HTTPS resources are problematic because of missing symbols in SSL libraries. After running bash on a one-off dyno and issuing a command manually I can see this:

QSslSocket: cannot resolve CRYPTO_num_locks                  ] 10%
QSslSocket: cannot resolve CRYPTO_set_id_callback
QSslSocket: cannot resolve CRYPTO_set_locking_callback
QSslSocket: cannot resolve sk_free
QSslSocket: cannot resolve sk_num
QSslSocket: cannot resolve sk_pop_free
QSslSocket: cannot resolve sk_value
QSslSocket: cannot resolve SSL_library_init
QSslSocket: cannot resolve SSL_load_error_strings
QSslSocket: cannot resolve SSLv3_client_method
QSslSocket: cannot resolve SSLv23_client_method
QSslSocket: cannot resolve SSLv3_server_method
QSslSocket: cannot resolve SSLv23_server_method
QSslSocket: cannot resolve X509_STORE_CTX_get_chain
QSslSocket: cannot resolve OPENSSL_add_all_algorithms_noconf
QSslSocket: cannot resolve OPENSSL_add_all_algorithms_conf
QSslSocket: cannot resolve SSLeay
QSslSocket: cannot call unresolved function CRYPTO_num_locks
QSslSocket: cannot call unresolved function CRYPTO_set_id_callback
QSslSocket: cannot call unresolved function CRYPTO_set_locking_callback
QSslSocket: cannot call unresolved function SSL_library_init
QSslSocket: cannot call unresolved function SSLv23_client_method
QSslSocket: cannot call unresolved function sk_num
QSslSocket: cannot call unresolved function SSLv23_client_method1%
QSslSocket: cannot call unresolved function SSL_library_init
QSslSocket: cannot call unresolved function SSLv23_client_method
QSslSocket: cannot call unresolved function SSL_library_init

However, after extracting wkhtmltopdf from wkhtmltox_0.12.5-1.bionic_amd64.deb the command succeeded.

A temporary solution is to use http instead of https. An ideal solution would be to ship an updated binary but I think it'd be better to make it part of a buildpack instead of a gem.

What do you think?

Just for your info: I have a fork that was updated to Heroku-18. Please take a look at https://github.com/gregnavis/wkhtmltopdf-heroku.

@rposborne could you possibly separate releases into two different stacks, eg. v2.12.5.0-heroku-18 and v2.12.5.0-heroku-16 based on @gregnavis changes

I have verified that the fork by @gregnavis works, but the PDF generated is different in the way it looks, since the binary is changed.

@gregnavis Your fix solved an issue that I have been banging my head against for 2 days now. Thank you!

@gregnavis @abhishek77in happy to have a new linage of the gem for heroku 18 with a different build.

I'll be happy to accept a PR.

To @gregnavis point, absolutely this gem could be a build pack. But build packs weren't a thing when this gem was made :)

@rposborne, wow, is that somewhere in the 50s? 😉 On a more serious note, thanks for the info, didn't realize the gem is that old.

@gregnavis Let us know if you plan to create a PR, otherwise I will just use your commit to create it :).

We've been having this issue for a long time, and it's most likely that this commit will fix it. We're stuck on heroku-16 for now 😿

@Erowlin have you tried wkhtmltopdf-buildpack? I personally haven't yet but it seems it should enable you to remove the wkhtmltopdf-heroku gem and add the binary to the slug during the build process.

@Erowlin have you tried wkhtmltopdf-buildpack? I personally haven't yet but it seems it should enable you to remove the wkhtmltopdf-heroku gem and add the binary to the slug during the build process.

I have, but the PNG are not loading with this buildpack. I've tried many things (Changing the folder, the way we load assets / precompile, changing the CDN settings), I could not make PNG work.

Thanks @gregnavis! Works great. Would be great to upgrade this repo with new binary :)

We upgraded to 18 last night, and are experiencing this issue in production this morning. We're using the wkhtmltopdf gem, not this one. I'd be glad to make that change. However, this issue isn't closed and I don't see any merges, so I'm not sure what the states of this repo and issue are.

Add libssl1.0.0 to your Aptfile, it made the difference for us.

This will install an updated version of the library (1.0.2n-1ubuntu5.3) - the heroku-18 version is 1.0.2n-1​ubuntu5.2

Add libssl1.0.0 to your Aptfile, it made the difference for us.

This will install an updated version of the library (1.0.2n-1ubuntu5.3) - the heroku-18 version is 1.0.2n-1​ubuntu5.2

Fixed our issue with missing images

Are there any plans to merge @gregnavis 's fork into this?

@gregnavis could you create a pull request?

Add libssl1.0.0 to your Aptfile, it made the difference for us.

This will install an updated version of the library (1.0.2n-1ubuntu5.3) - the heroku-18 version is 1.0.2n-1​ubuntu5.2

@andreas-venturini Heroku-18 claims to have this version already: See https://devcenter.heroku.com/articles/stack-packages#installed-ubuntu-packages

@andreas-venturini Heroku-18 claims to have this version already

Correct, the version has since been updated. However, I found it does still not work without the override - not entirely sure why. Did it work for you?

@andreas-venturini You are correct. For some reason not apparent to me, by adding libssl1.0.0 to the aptfile it works, even though it is already installed.

Here is the output

-----> Apt app detected
-----> Reusing cache
-----> Updating apt caches
       Hit:1 http://archive.ubuntu.com/ubuntu bionic InRelease
       Get:2 http://archive.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]
       Get:3 http://apt.postgresql.org/pub/repos/apt bionic-pgdg InRelease [41.3 kB]
       Get:4 http://archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]
       Get:5 http://apt.postgresql.org/pub/repos/apt bionic-pgdg/main amd64 Packages [242 kB]
       Get:6 http://archive.ubuntu.com/ubuntu bionic-security/main amd64 Packages [427 kB]
       Get:7 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages [776 kB]
       Get:8 http://archive.ubuntu.com/ubuntu bionic-updates/universe amd64 Packages [1,191 kB]
       Fetched 2,855 kB in 1s (2,305 kB/s)
       Reading package lists...
-----> Fetching .debs for libxrender1
       Reading package lists...
       Building dependency tree...
       0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 11 not upgraded.
       Need to get 0 B/18.7 kB of archives.
       After this operation, 0 B of additional disk space will be used.
       Download complete and in download only mode
W: --force-yes is deprecated, use one of the options starting with --allow instead.
-----> Fetching .debs for libssl1.0.0
       Reading package lists...
       Building dependency tree...
       0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 11 not upgraded.
       Need to get 0 B/1,088 kB of archives.
       After this operation, 0 B of additional disk space will be used.
       Download complete and in download only mode
W: --force-yes is deprecated, use one of the options starting with --allow instead.
-----> Installing libssl1.0.0_1.0.2n-1ubuntu5.3_amd64.deb
-----> Installing libxrender1_1%3a0.9.10-1_amd64.deb

@rposborne @pallymore do you have an idea of what direction you'll be taking for supporting Heroku-18? Merging @gregnavis's fork? Is the buildpack mentioned in #37 still necessary? Are we just waiting for someone to open a PR with @gregnavis's changes?

@jordan-brough I'm testing out the binaries in @gregnavis 's fork. also I'm trying to build one from scratch myself.

tested @gregnavis 's binary - seems to be working fine. No additional buildpack is needed.

Before that branch is released to rubygems, please try:

gem 'wkhtmltopdf-heroku', branch: '2.12.5.0-heroku18', git: 'https://github.com/rposborne/wkhtmltopdf-heroku.git'

👍 That version is working for me on Heroku-18 without any buildpack or other changes. Thank you!

@pallymore are you planning to release that update to rubygems?

Done - it seems to be working for me. 🎉
Thanks folks!

Add libssl1.0.0 to your Aptfile, it made the difference for us.

This will install an updated version of the library (1.0.2n-1ubuntu5.3) - the heroku-18 version is 1.0.2n-1​ubuntu5.2

This works for me.
Thanks a lot!

I use asp.net core app. And I'm facing with the same issue.
How can I resolve error. I try to add gemfile and aptfile, but I think I did something wrong...
In details I created question in stackoverflow, please help me)

I use asp.net core app. And I'm facing with the same issue.
How can I resolve error. I try to add gemfile and aptfile, but I think I did something wrong...
In details I created question in stackoverflow, please help me)

Hi - I'm not familiar with .NET - are you using Ruby packages in your .NET app? (is that possible?)
if you are not using this package you will need to install those dependencies on heroku via buildpacks (assuming your app runs on heroku)

if you are using Windows this package is not going to work for you.

I use asp.net core app. And I'm facing with the same issue.
How can I resolve error. I try to add gemfile and aptfile, but I think I did something wrong...
In details I created question in stackoverflow, please help me)

Hi - I'm not familiar with .NET - are you using Ruby packages in your .NET app? (is that possible?)
if you are not using this package you will need to install those dependencies on heroku via buildpacks (assuming your app runs on heroku)

if you are using Windows this package is not going to work for you.

I'm using asp.net core that cross platforms app. Of course I'm using heroku. And part of issue with pdf converter I solved by adding to docker file installation dependency. And now I can get pdf file, but without images. Also about buildpacks can you share which one I must add, and which order must be?

I use asp.net core app. And I'm facing with the same issue.
How can I resolve error. I try to add gemfile and aptfile, but I think I did something wrong...
In details I created question in stackoverflow, please help me)

Hi - I'm not familiar with .NET - are you using Ruby packages in your .NET app? (is that possible?)
if you are not using this package you will need to install those dependencies on heroku via buildpacks (assuming your app runs on heroku)
if you are using Windows this package is not going to work for you.

I'm using asp.net core that cross platforms app. Of course I'm using heroku. And part of issue with pdf converter I solved by adding to docker file installation dependency. And now I can get pdf file, but without images. Also about buildpacks can you share which one I must add, and which order must be?

Hi - this package is not going to solve that problem for you (it's for Ruby apps only)

Please open a ticket over at https://github.com/wkhtmltopdf/wkhtmltopdf instead.

I use asp.net core app. And I'm facing with the same issue.
How can I resolve error. I try to add gemfile and aptfile, but I think I did something wrong...
In details I created question in stackoverflow, please help me)

Hi - I'm not familiar with .NET - are you using Ruby packages in your .NET app? (is that possible?)
if you are not using this package you will need to install those dependencies on heroku via buildpacks (assuming your app runs on heroku)
if you are using Windows this package is not going to work for you.

I'm using asp.net core that cross platforms app. Of course I'm using heroku. And part of issue with pdf converter I solved by adding to docker file installation dependency. And now I can get pdf file, but without images. Also about buildpacks can you share which one I must add, and which order must be?

Hi - this package is not going to solve that problem for you (it's for Ruby apps only)

Please open a ticket over at https://github.com/wkhtmltopdf/wkhtmltopdf instead.

Thank you(