在PHP中使用wkhtmltopdf可以通过以下方法:
使用exec()函数调用wkhtmltopdf命令行工具来生成PDF文件。例如:exec('wkhtmltopdf input.html output.pdf');使用shell_exec()函数调用wkhtmltopdf命令行工具来生成PDF文件。例如:shell_exec('wkhtmltopdf input.html output.pdf');使用PHP的exec()或shell_exec()函数来执行包含wkhtmltopdf命令的shell脚本文件。例如,创建一个shell脚本文件(如convert.sh):#!/bin/bashwkhtmltopdf input.html output.pdf然后在PHP中执行该脚本文件:
shell_exec('./convert.sh');无论使用哪种方法,都需要确保服务器上已安装了wkhtmltopdf,并且PHP有权限执行该命令。


