我需要使用 Javascript Apis 从 HTML View 渲染创建一个 PDF
这是我在 PHP Laravel 4 中的代码
$con = Contrato::find($id);
$html = (string) View::make('contratos.contratopdf')->with('con',$con)->render();
return PDF::load(utf8_decode($html), 'A5', 'landscape')->show();
在 View 中我有这个脚本
<script src="http://test.rentacar.cl/js/lib/jquery.signaturepad.min.js"></script>
此 js 在普通 HTML 中更改 Dom,但当我在 PDF 中显示时不起作用。
谢谢!!
最佳答案
PhantomJS 运行良好,看看这个包:https://github.com/jonnnnyw/php-phantomjs
此处提供完整文档:http://jonnnnyw.github.io/php-phantomjs/
例子:
<?php
use JonnyW\PhantomJs\Client;
$client = Client::getInstance();
$request = $client->getMessageFactory()->createCaptureRequest('http://google.com');
$response = $client->getMessageFactory()->createResponse();
$file = '/path/to/save/your/screen/capture/file.jpg';
$request->setCaptureFile($file);
$client->send($request, $response);
关于javascript - 使用 Javascript 的 Laravel 4 render() PDF,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29414114/