Select phantomJS-将页面从客户端发送到侦听phantomJS的服务器

Select phantomJS-将页面从客户端发送到侦听phantomJS的服务器,select,phantomjs,Select,Phantomjs,我有一个表单,在提交后,客户端将获得结果页面,其中包含客户端选择的内容,并显示每个项目的图片。我想将此页面导出为PDF。在我的服务器上运行phantomJs,我的想法是修改生成的页面,使其能够发送到侦听phantomJs的服务器上 我在客户端呈现的页面中包含的代码: <input type="submit" id="export-pdf" value="send" name="submit"> <script> $('input#export-pdf').click(f

我有一个表单,在提交后,客户端将获得结果页面,其中包含客户端选择的内容,并显示每个项目的图片。我想将此页面导出为PDF。在我的服务器上运行phantomJs,我的想法是修改生成的页面,使其能够发送到侦听phantomJs的服务器上

我在客户端呈现的页面中包含的代码:

<input type="submit" id="export-pdf" value="send" name="submit">

<script>
$('input#export-pdf').click(function(){

    var html = $("body").html();
    var data = { html: html };
    $.post("http://server_IP/create-pdf.php", data);
});                             
</script>

$('input#export pdf')。单击(函数(){
var html=$(“body”).html();
var data={html:html};
$.post(”http://server_IP/create-pdf.php“,数据);
});                             
create-pdf.php(在服务器上):


到目前为止,我没有得到任何pdf…我做错了什么?。。。。
感谢您的帮助

我对此不确定,但您可以在调用时尝试使用js api。
exec(“phantomjs rasterize.js tmp.html tmp.pdf”)

我停止使用phantomjs进行渲染,现在我通过mPDF php库进行渲染

<?php
$html = $_POST['html'];
file_put_contents("tmp.html", $html);
exec("phantomjs tmp.html tmp.pdf");
$pdf = file_get_contents("tmp.pdf");
header("content-type: application/pdf");
echo $pdf;
exit;
?>