brizandt
brizandt

Reputation: 401

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

I've written a PHP/MySQL application that utilizes wkhtmltopdf to generate reports from data entered into the database. The client asked that I also install it to run as a standalone on a Mac that he has. Currently have the PHP/MySQL portion running without difficulty using XAMMP, but am having incredible difficulty getting wkhtmltopdf even installed on the system.

I have zero experience with Macs, and despite five hours of Googling and trying different approaches, I cannot even copy the most recent wkhtmltopdf .i386 into the /usr folder. Oddly, the laptop doesn't have a /usr/local/bin folder.

Unless I've missed it, I can't find simple instructions on how to get this thing working and would greatly appreciate any help that could be offered.

Upvotes: 40

Views: 95284

Answers (8)

Arefe
Arefe

Reputation: 12397

The command works for me fine:

brew install --cask wkhtmltopdf

Upvotes: 2

adjwilli
adjwilli

Reputation: 9688

If you have Homebrew installed run: brew install wkhtmltopdf

That will also install wkhtmltoimage.

Alternatively, you can download the compiled binaries from http://wkhtmltopdf.org/downloads.html and place them somewhere in your path like /usr/local/bin. If you plan on running your script in another environment like a server or App Engine, this is the way to go.

Upvotes: 41

Kabubless
Kabubless

Reputation: 121

I was struggling to install wkhtmltopdf but after some research this helped me to install it on a MAC OSx

brew install wkhtmltopdf --cask

Upvotes: 1

Arefe
Arefe

Reputation: 12397

You will need to run the command in the terminal before the PDF creation:

brew cask install wkhtmltopdf

When I create the PDF, I get this log in the server:

2020-05-31 17:20:10.657  INFO 11168 --- [io-8080-exec-10] c.g.jhonnymertz.wkhtmltopdf.wrapper.Pdf  : Initialized with {xvfbConfig=null, wkhtmltopdfCommand='/usr/local/bin/wkhtmltopdf'}
2020-05-31 17:20:20.166  INFO 11168 --- [io-8080-exec-10] c.g.jhonnymertz.wkhtmltopdf.wrapper.Pdf  : PDF successfully generated with: /usr/local/bin/wkhtmltopdf -B 0 -L 0 -R 0 -T 0 --page-width 148 --page-height 212 /var/folders/0c/_vpt6xnj71ng91nm9kk5jw3w0000gn/T/java-wkhtmltopdf-wrapper6721963b-6a8c-4260-9ac6-a545920d1ab117331429448032181725.html -

Upvotes: 2

prikha
prikha

Reputation: 1853

Homebrew only has wkhtmltopdf-0,9,9 and it fails with QT patched options by default. So if you need HEAD version with fully suppoorted options just

  • Grab yourself a copy of fresh wkhtmltopdf
  • Open it and drag to Applications
  • Then cd /usr/local/bin && ln -s /Applications/wkhtmltopdf.app/Contents/MacOS/wkhtmltopdf wkhtmltopdf

Upvotes: 77

John F
John F

Reputation: 429

For anyone trying to use mikehaertl\wkhtmlto\Pdf with MAMP make sure you install the latest version for Mac http://wkhtmltopdf.org/downloads.html and define the binary parameter.

$options = array(
    'page-size' => 'Letter',
    'orientation' => 'portrait',
    'binary' => '/usr/local/bin/wkhtmltopdf'
);

$pdf = new Pdf($options);

Upvotes: 5

yuяi
yuяi

Reputation: 2715

This seems to have easy to install packages:

http://wkhtmltopdf.org/downloads.html

I successfully installed the OS X 10.6+ (Cocoa) 64-bit on my OSX 10.9.4 by simply running the pkg. Using it for the PDFKit Rails gem.

Upvotes: 15

prodigitalson
prodigitalson

Reputation: 60413

Lion (10.7) doesnt make /usr/local anymore, but you can create it.

If the package you want doesnt have a an installer for the binaries then you'll have to compile from source. Im which case all the instructions you need should be available from the download site for the package.

The other option would be to see if its available in any of the OS X package managers (Fink, MacPorts, Homebrew). If it is you could install everything that way. I can say its not in the MacPorts repository - i checked :-)

UPDATE: Homebrew seems to have it...

Upvotes: 0

Related Questions