amazonlinux / amazon-linux-2023

Amazon Linux 2023
https://aws.amazon.com/linux/amazon-linux-2023/
Other
501 stars 38 forks source link

[Package Request] - wkhtmltopdf #570

Closed skoloCFD closed 6 months ago

skoloCFD commented 6 months ago

What package is missing from Amazon Linux 2023? Please describe and include package name. wkhtmltopdf

Is this an update to existing package or new package request? New request

Is this package available in Amazon Linux 2? If it is available via external sources such as EPEL, please specify. Yes

Any additional information you'd like to include. (use-cases, etc) Used to converting HTML to PDF

rbpltr commented 6 months ago

It looks like wkhtmltopdf has been archived by its owner. However, I have been successfully using the Alma Linux 9 wkhtmltox packages with Amazon Linux 2023.

For example:

dnf install -y https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6.1-3/wkhtmltox-0.12.6.1-3.almalinux9.$(uname -m).rpm
wkhtmltopdf --version
stewartsmith commented 6 months ago

Given that it's archived upstream, this isn't something we are going to look at bringing into AL2023, as the maintenance burden is likely high given its interaction with web content.

Going to add the Won't Fix tag here so that others can find it if needed.

This may be a candidate for someone to create a maintain a COPR repository for.

thanhhiep206 commented 3 months ago

@rbpltr i still get errors after install wkhtmltox in Amazon linux 2023. can you help me?, i don't know in amz 2023 wkhtmltopdf-binary still load wkhtmltopdf_centos_7_amd64 /home/ec2-user/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/wkhtmltopdf-binary-0.12.6.5/bin/wkhtmltopdf_centos_7_amd64: error while loading shared libraries: libssl.so.10: cannot open shared object file: No such file or directory

rbpltr commented 3 months ago

@thanhhiep206 Those errors aren't related to the binary I suggested installing. It looks like you're trying to run something that relies on a binary in a Ruby gem. I don't know how to fix that issue.

briri commented 2 weeks ago

we're running into the same issue you mention above except mine complains about libjpeg.so. @thanhhiep206 did you ever get around it?

FactorGFC commented 1 week ago

@briri @thanhhiep206 Have you find a solution for this issue? I've tried everything I can even with the fact of not having access to the AWS servers terminal, all I've done is testing via workflow installing packages and/or .config files on the .ebextensions but none of them have been succesful.

briri commented 1 week ago

@FactorGFC unfortunately no. We ended up replacing the code that was using wkhtmltopdf with puppeteer and headless chrome.

We were starting to find that some of our other application dependencies were going to start having trouble as well since you're also locked at node 16 on Amazon Linux 2. So we decided to put in the effort.

On the server side: We had to install a ton of packages (around 90) to support puppeteer and chrome which feels bad, but at least they're rpm so will get updated during normal server patching.

Once the packages were installed we need to run npm install puppeteer followed by npx puppeteer browsers install chrome@stable which will install chrome into a .cache/puppeteer/chrome/linux-[version] from the dir you run it in. This will install the latest stable version of chrome that (I assume) works with the version of puppeteer installed.

We setup the above to be run when we do application dependency updates (e.g. npm upgrade). We create a sim link to the actual chrome executable for the latest version so that the app doesn't have to worry about the specific linux version.

Everything seems to be working ok (we just deployed to prod today! 😅)

On the application side: We are running a Rails app, so we have Capistrano managing that npx command and the sim linking mentioned above.

We swapped out the wicked_pdf gem which was a wrapper for wkhtmltopdf for grover a wrapper around puppeteer. This took some effort but it wasn't too bad. We found that the margin and font handling differed a bit from wkhtmltopdf, so we had to do some tedious tweaking to get the final PDFs to match.

We've noticed that this new approach takes almost twice as long to generate the PDF (compared to wkhtmltopdf). I suspect that this is overhead of launching chrome. We have also found that our simple PDF went from an average size of 50kb to 250kb!

We are going to experiment with the npx puppeteer browsers install command to see if there's a lighter footprint executable we can use.

FactorGFC commented 1 week ago

@briri @thanhhiep206 @thanhhiep206 Friends we got it working on our project mounted on Amazon Linux 2023 (aws beanstalk) with Ruby 3.2.2

What we did is: 1) Added container commands that execute on deploy inside file 01_deploy.config in the .ebextensions folder like this

        install_missing_libraries:
          command: "sudo dnf install -y https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6.1-3/wkhtmltox-0.12.6.1-3.almalinux9.$(uname -m).rpm"

2) Added the excecution path for the library just installed inside the config/initializers/wicked_pdf.rb

        # enable_local_file_access: true <-- comment this line
        exe_path: '/usr/local/bin/wkhtmltopdf'

Doing it this way allows us to prepare all of our instances with AWS's newer Linux versions, hoping it works in the future with this workarounds.