javascript - 使用 Javascript 的 Laravel 4 render() PDF

标签 javascript html pdf dom laravel-4

我需要使用 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/

相关文章:

javascript - jquery ajax返回值和done函数

javascript - 如何更改 JSDoc 生成的输出的标题?

javascript - 如何从html中删除标签样式

html - 我怎样才能使这个 css webkit 从左到右过渡?

javascript - 如何停止自动在 iframe 中下载 PDF 而改为查看文件?

javascript - Ajax 数据与日期选择器事件不同步

javascript - 如何添加数组新键值(javascript)?

jquery - 修复标题问题 iOS

ios - 在IOS中为PDF文件设置密码

python - 如何将页码添加到pdf文件?