0

I'm trying to install wkhtmltopdf on my Mac using the following command:

brew install wkhtmltopdf

However, when I try to run wkhtmltopdf command through the terminal, I encounter an error like this:

zsh: command not found: wkhtmltopdf

Then, I also tried to download wkhtmltopdf from here, choosing the one for macOS. It downloaded a file named wkhtmltox-0.12.6-2.macos-cocoa.pkg, but I don't know how to install that file because its extension is .pkg.

Can someone help me deal with this issue?

0

1 Answer 1

2

For installing pkg in macOS, see the post Installing .pkg with terminal?

The accepted answer by user nohillside suggests the following command:

sudo installer -pkg /path/to/package.pkg -target /

It also notes :

The target is a "device" (see the man page for details or run installer -dominfo). Here / is the main drive, it also accepts devices like "/Volumes/Macintosh HD", or /dev/disk0.


The poster has installed the package using the following command:

sudo installer -pkg wkhtmltox-0.12.6-2.macos-cocoa.pkg -target /usr/local/bin

Reference : How To Install and Run wkhtmltopdf on Mac OsX 10.7.3 for use in a PHP Application.

4
  • Yes, I've checked the post regarding how to install .pkg files, but I'm not sure which path to use for wkhtmltopdf. Can you give me some guidance?
    – Tri
    Commented Apr 27 at 15:14
  • 1
    The answer says you give the name of a device/disk. However, there may be an easier method. Note that the latest version dates from 2020 and that the Github repository has the message "This repository has been archived by the owner on Jan 2, 2023. It is now read-only. " This package doesn't seem to be maintained any more. There are also some warnings about installing the pkg file as a package, so be very careful with my answer, try first the above easier method.
    – harrymc
    Commented Apr 27 at 15:38
  • I've solved the issue now following your advice. I installed the wkhtmltopdf pkg file I downloaded using the command you suggested, and for the target I used /usr/local/bin as mentioned in this answer: stackoverflow.com/a/10931279/8070090 So the full command in my case is: sudo installer -pkg wkhtmltox-0.12.6-2.macos-cocoa.pkg -target /usr/local/bin Thank you for your help; I think you need to edit your answer a bit for the target path, and I will accept your answer. Thanks again.
    – Tri
    Commented Apr 28 at 0:52
  • 1
    @Tri: Done as requested. Glad that the problem is now solved.
    – harrymc
    Commented Apr 28 at 8:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .