Giter VIP home page Giter VIP logo

wkhtmltopdf-amd64-mac-os's Introduction

wkhtmltopdf for Mac

背景

  • 最近一朋友让我协助解决一个问题,将word文档转成pdf文档 事实上,这个是可以通过PhpWord这个包来完成的,但是在其中有个需求是, 将word模板文件中的一些文字替换为最终的值,做到最后,发现如果使用dompdf包来完成时, 对英文的文档是ok的,但是遇到中文就会乱码,在laravel的论坛中,发现了使用这个 https://github.com/barryvdh/laravel-snappy, 可以解决这个问题
  • 这个软件包有个以依赖:wkhtmltopdf
  • laravel-snappy 包中提示可以去https://github.com/KnpLabs/snappy#wkhtmltopdf-binary-as-composer-dependencies, 直接使用composer直接安装这个依赖,但这个包是支持debian操作系统的,我本地是mac环境
  • 为了解决这个依赖问题,只能去它的官网下载对应的版本:https://wkhtmltopdf.org
  • 在github上查看,还有一个仓库是有centos版本的,但找不到mac版本,于是我决定开一个仓库 用于存放mac版本的,便于其他人使用composer安装wkhtmltopdf的mac版本

安装

  • 它的系统架构是amd64
  • git clone https://github.com/suhanyujie/wkhtmltopdf-amd64-mac-os.git
  • 或者使用composer进行安装 composer require "suhanyu/wkhtmltopdf-amd64-mac-os":"*"
  • 安装后,laravel的使用路径:base_path('vendor/suhanyu/wkhtmltopdf-amd64-mac-os/bin/wkhtmltopdf')
  • 到项目根目录下,给可执行权限
chmod +x vendor/suhanyu/wkhtmltopdf-amd64-mac-os/bin/wkhtmlto*

使用

$snappyPdf = new \Knp\Snappy\Pdf(base_path('vendor/suhanyu/wkhtmltopdf-amd64-mac-os/bin/wkhtmltopdf'));
$snappyPdf->generateFromHtml('<h1>test html</h1>', 'output.pdf');

问题

  • composer安装时,如果提示:but these conflict with your requirements or minimum-stability.

可以在composer.json文件加上以下选项:

"minimum-stability": "dev",
"prefer-stable": true

参考

wkhtmltopdf-amd64-mac-os's People

Contributors

suhanyujie avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.