majid / phptopdf
此包已被放弃,不再维护。未建议替代包。
laravel 4.2 包,用于将 html 或 php 转换为 pdf,此包还具有获取 URL 并返回由指定 URL 生成的 pdf 的功能。这是一个在线服务,因此您需要互联网连接才能使用此包。
dev-master
2014-11-23 17:30 UTC
Requires
- php: >=5.4.0
- illuminate/support: 4.2.*
This package is not auto-updated.
Last update: 2022-02-01 12:41:53 UTC
README
安装
将此包添加到您的 composer.json 中,并运行 composer update。 "Majid/phptopdf": "dev-master"
将 ServiceProvider 添加到 providers 数组中
app/config/app.php
'Majid\Phptopdf\PhptopdfServiceProvider'
然后前往 phptopdf 注册页面 进行注册,这是免费的。然后从网站获取 API_KEY,并将其粘贴到下面提到的文件的第五行。
your_project_path/vendor/phptopdf/src/Majid/Phptopdf/phptopdf.php
$my_html = '<HTML>'; $my_html .= "<link rel=\"stylesheet\" href=\"http://phptopdf.com/bootstrap.css\">"; $my_html .= "<div>". $my_html .= "what ever html element and php function which has html element output you can use here like below" $my_html .= "<div/>" $math_var = (2+3) * 7; $my_html .= "<div>". $my_html .= $math_var; $my_html .= "<div/>" $my_html .= '</HTML>'; $pdf_options = array( "encoding" => 'UTF-8', "source_type" => 'html', "source" => $my_html, "action" => 'save', "save_directory" => app_path().'/../public/files/pdf', "file_name" => 'factor.pdf' ); Phptopdf::phptopdf($pdf_options);
如您所见,phptopdf 函数是 phptopdf 库中可用的函数,我只是将所有这些函数汇总到我的类中,您可以使用以下方式使用所有这些函数
Phptopdf::phptopdf Phptopdf::phptopdf_url Phptopdf::phptopdf_html
查看 phptopdf.com 了解函数参数和正确语法。
Phptopdf::phptopdf($pdf_options);
最后,您可以阅读 phptopdf 官方网站 了解更多文档。##许可证 此包由 Majid Abdolhosseini 创建,并使用 MIT 许可证发布。