使用 wkhtmltopdf
安装
示例代码
import pdfkit
pdfkit.from_url('https://wkhtmltopdf.org/docs.html', 'out.pdf')
# pdfkit.from_file('test.html', 'out.pdf')
# pdfkit.from_string('Hello!', 'out.pdf')
2. php
<?php
include './vendor/autoload.php';
use mikehaertl\wkhtmlto\Pdf;
if (empty($_GET['url'])) {
die();
}
$pdf = new Pdf($_GET['url']);
$pdf->send();