Wkhtmltopdf Download Location ((NEW))

4 views
Skip to first unread message

Jessia Defrancisco

unread,
Jan 20, 2024, 5:21:19 PM1/20/24
to geldcarliper

wkhtmltopdf and wkhtmltoimage are open source (LGPLv3) command line tools to render HTML into PDF and various image formats using the Qt WebKit rendering engine. These run entirely "headless" and do not require a display or display service.

I added PDFkit to my gemfile and the appropriate config options to my
application.rb. I then tried to see if a could get a pdf version of one
of the pages in my app and I got the following action controller
exceptionNo wkhtmltopdf executable found at /usr/local/bin/wkhtmltopdf
>> Install wkhtmltopdf by hand or try running `pdfkit --install-wkhtmltopdf`I tried installing using the commandpdfkit --install-wkhtmltopdfthis didn't go smoothly and I had to add the directory and change some
permissions but I got it installed. I'm still getting a permission
denied exception but as far as I can tell the file is rwx for allIt kind of feels like I have drifted down the wrong path completely with
this. If anyone has any pointers they would be greatly appreciated
--
Posted via -forum.com/.

wkhtmltopdf download location


DOWNLOADhttps://t.co/vma700xUBc



Thanks you so much for your reply. My development environment is snow
leopard and then I deploy to a ubuntu server. To be honest I'm just
trialling stuff at moment but strangely ran into problems getting
things working on snow leopard. I actually figured out what was going
on but I will definitely be looking at your advice when it comes to
deploying to ubuntu.Basically I figured out that the problem was due where/how the gem is
installed under RVM. I checked where the gem was installed which was/Users/conor/.rvm/gems/ruby-1.9.2-p0/bundler/gems/PDFKit-652209dI then ran the command recommended in the POST_INSTALL readme in tis
directory export TO=`which pdfkit sed 's:/pdfkit:/wkhtmltopdf:'` && pdfkit
--install-wkhtmltopdfwhich installed wkhtmltopdf to/Users/conor/.rvm/gems/ruby-1.9.2-p0/bin/wkhtmltopdfI then set the configuration for PDFKit to point to this path in my
application.rb #pdfkit
config.middleware.use "PDFKit::Middleware"
PDFKit.configure do config
config.wkhtmltopdf =
'/Users/conor/.rvm/gems/ruby-1.9.2-p0/bin/wkhtmltopdf'
endEverything seems to be working so far

David, Conor,I tried to install via the method mentioned by Conor above and when I
generate a PDF, it comes up blank. I also try running from the command
line and I also get a blank PDF. It's really strange, when I installed
the first time (into the default location) and I ran from command line,
I got it to work with "wkhtmltopdf www.google.com goof.pdf" but it
hasn't worked since. I have a new MacBook, running rvm with ruby 1.8.7
and rails 3.Any thoughts you have would be greatly appreciated. I'm wondering if I
somehow need to do a complete delete after the various attempts at
installation, but I don't see anything else to delete aside from the
wkhtmltopdf file in use/local/bin or the rvm directory. Have either of
you had to install the 64 bit version?Thanks,
Nick

I think that you are right and the problem lies with your installation
of wkhtmltopdf given your command line problems. Maybe try uninstalling
wkhtmltopdfapt-get remove wkhtmltopdfand then installing via PDFKitpdfkit --install-wkhtmltopdfor manuallySorry, I know this isn't much help!
Nick Burdick wrote in post #964978:

Thanks for replying guys,I tried to revert back to my system Ruby (out of RVM) and installing
pdfkit via Gem install. Then in installed wkhtmltopdf with pdfkit as
stated above. It runs from the command line, but it still creates a
blank pdf. It's funny, the pdfs open but there is just no content. I'm
stumped.

In my application.rb file I have put this: config.middleware.use PDFKit::Middleware
PDFKit.configure do config
config.wkhtmltopdf = '/usr/local/bin/wkhtmltopdf'
endNow this is SUPPOSED to allow me to add a .pdf extension to my URL's to
get a PDF version of the page, however, when I do that, from that point
on I get ALL pages as pdf. ie. if I then click on a link in the PDF, it
generates another pdf file of the next page, etc.If I try and just go to a page without the PDF, it continues to generate
PDFs until I stop the server.Anyone else have this problem?These are the relevant gems installed:
wkhtmltopdf-binary (0.9.5.1)
pdfkit (0.5.0)
wkhtmltopdf 0.9.9

Anyway, so I tried downloading the program from this website but I ran into a few problems. First of all, from the list on the side, what should I download? I just see a bunch of random numbers and file extensions that don't mean anything to me. I tried the top one on the list and the one called "wkhtmltopdf.dmg".

Secondly, once I download the file, how do I install and use the program? It seems that on most files I have downloaded, it gives me a .dmg file. I don't know what a .dmg file is, but usually when I download stuff I just somehow know what to click on and suddenly the program is running. In this case, the .dmg file doesn't lead to anything, and I think I am expected to go into the terminal and work some magic. I tried using terminal but I just don't understand how it works. I was able to "cd" my way to the folder containing the file I downloaded. Then I tried running the commands that the link above told me to run: wkhtmltopdf www.myhomepage.com myhomepage.pdf. However, I keep getting wkhtmltopdf: command not found.

This is basically the same as before. Just now I was required to enter my username and password for the secure site. I put the resulting PDF inside a Reports folder which is located a level above of my current location in the tree structure of folders.

wkHTMLtoPDF is an open-source and cross-platform tool that can convert HTML pages to PDF. This is a command-line utility and it is pretty easy to use. The syntax for using the tool is fairly simple, enter the name wkhtmltopdf, followed by the URL of the web page, and the name of the PDF that you want to create, like so.

Warning! Version in debian/ubuntu repos have reduced functionality (because it compiled without the wkhtmltopdf QT patches), such as adding outlines, headers, footers, TOC etc. To use this options you should install static binary from wkhtmltopdf site or you can use this script.

By default, PDFKit will run wkhtmltopdf with quiet option turned on, since in most cases output is not needed and can cause excessive memory usage and corrupted results. If need to get wkhtmltopdf output you should pass verbose=True to API calls:

wkhtmltopdf - the location of the wkhtmltopdf binary. By default pdfkit will attempt to locate this using which (on UNIX type systems) or where (on Windows).

  • meta_tag_prefix - the prefix for pdfkit specific meta tags - by default this is pdfkit-
Example - for when wkhtmltopdf is not on $PATH:

If you are getting strange results in PDF or some option looks like its ignored you should try to run wkhtmltopdf directly to see if it produces the same result. You can get CLI command by creating pdfkit.PDFKit class directly and then calling its command() method:

Make sure that you have wkhtmltopdf in your $PATH or set via custom configuration (see preceding section). where wkhtmltopdf in Windows or which wkhtmltopdf on Linux should return actual path to binary.

This error means that PDFKit was unable to process an input. You can try to directly run a command from error message and see what error caused failure (on some wkhtmltopdf versions this can be cause by segmentation faults)

Documents can also be created from io.Readers, and written to io.Writers to facilitate use in a server environment.If multiple readers are used, these will be written to temporary files. Each document creates its own temporarydirectory, so should be safe for concurrent use. If only a single reader is used, this will be piped to wkhtmltopdf.

If a single reader is provided, this is piped to wkhtmltopdf through stdin. If multiplereaders are provided, the contents are written to a temporary directory and used from there.The location of the temporary directories can be changed by setting the TempDir variable.

I have installed the drupal Print module, but have not been successful in getting wkhtmltopdf to work. The drupal print documentation is outdated and despite of a number of request to update it, it still is outdated.

I'm trying to run wkhtmltopdf (from here) from a PHP script. I can successfully call wkhtmltopdf-amd64 directly via SSH. But when calling it from PHP via exec, it always fails with exit code 127. The path is correct, so that isn't the issue. I can successfully use exec to call ls and id etc, so the problem seems to be specific to calling wkhtmltopdf-amd64.

Hi Jeremy,
This is very helpful, thank you. Could you provide steps/recommendations to download and build the latest libpng library on Amazon Linux 2 so that more recent versions of wkhtmltopdf can be used?

On Ubuntu 16.04 or 18.04 Enupal Snapshot doesn't need that you have installed wkhtmltopdf in the server, it just needs the full path of the wkhtmltopdf and wkhtmltoimage bin files. We can download it via the command line and get the full path from there.

Of course, you can run these manually on your Homestead server after provisioning, or on any other Ubuntu 20.04 install. But by putting it in after.sh, it should survive updates to your Homestead environment. Your wkhtmltopdf setup is now persistent and ready-to-go every time.

Last thing, make sure your project is using the right version of wkhtmltopdf. By default, laravel-snappy looks in /usr/local/bin/wkhtmltopdf, which is where this gets installed. SSH into your environment and verify the location and version:

In some cases you might want to display the PDF in an Iframe, as opposed to a full page PDF. You can do this with a PDF you created, or any other PDF saved in your server.Iframe displays is good for inline displays, inside other HTML content.What you need is again - the absolute path to the pdf location.

Note that if you are producing a PDF via ms, the table of contents will appear at the beginning of the document, before the title. If you would prefer it to be at the end of the document, use the option pdf-engine-opt: --no-toc-relocation.

df19127ead
Reply all
Reply to author
Forward
0 new messages