如何在 Mac OsX 10.7.3 上安装和运行 wkhtmltopdf 以在 PHP 应用程序中使用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10375168/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-24 22:02:25  来源:igfitidea点击:

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

phpmacoswkhtmltopdf

提问by brizandt

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.

我编写了一个 PHP/MySQL 应用程序,它利用 wkhtmltopdf 从输入到数据库中的数据生成报告。客户要求我也安装它以在他拥有的 Mac 上独立运行。目前使用 XAMMP 可以毫无困难地运行 PHP/MySQL 部分,但是即使在系统上安装 wkhtmltopdf 也遇到了令人难以置信的困难。

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.

我对 Mac 的体验为零,尽管使用了五个小时的谷歌搜索并尝试了不同的方法,但我什至无法将最新的 wkhtmltopdf .i386 复制到 /usr 文件夹中。奇怪的是,笔记本电脑没有 /usr/local/bin 文件夹。

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.

除非我错过了它,否则我找不到有关如何使这件事正常工作的简单说明,并且非常感谢可以提供的任何帮助。

回答by prikha

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

Homebrew 只有 wkhtmltopdf-0,9,9 并且默认情况下它会失败并带有 QT 补丁选项。因此,如果您需要具有完全支持选项的 HEAD 版本

  • 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
  • 给自己一份新鲜的 wkhtmltopdf
  • 打开它并拖动到应用程序
  • 然后 cd /usr/local/bin && ln -s /Applications/wkhtmltopdf.app/Contents/MacOS/wkhtmltopdf wkhtmltopdf

回答by adjwilli

If you have Homebrew installed: brew install Caskroom/cask/wkhtmltopdf

如果您安装了 Homebrew: brew install Caskroom/cask/wkhtmltopdf

回答by yuяi

This seems to have easy to install packages:

这似乎有易于安装的软件包:

http://wkhtmltopdf.org/downloads.html

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.

我通过简单地运行 pkg 在我的 OSX 10.9.4 上成功安装了 OS X 10.6+ (Cocoa) 64 位。将它用于 PDFKit Rails gem。

回答by John F

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

对于尝试将 mikehaertl\wkhtmlto\Pdf 与 MAMP 一起使用的任何人,请确保为 Mac http://wkhtmltopdf.org/downloads.html安装最新版本并定义二进制参数。

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

$pdf = new Pdf($options);

回答by prodigitalson

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

Lion (10.7)/usr/local不再制作,但您可以创建它。

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 :-)

另一种选择是查看它是否在任何 OS X 包管理器(Fink、MacPorts、Homebrew)中可用。如果是这样,您可以以这种方式安装所有内容。我可以说它不在 MacPorts 存储库中 - 我检查了 :-)

UPDATE: Homebrew seems to have it...

更新:Homebrew 似乎有它......