简体   繁体   English

如何使用Windows 7 OS在Wamp上安装wkhtmltopdf

[英]how to install wkhtmltopdf on wamp with windows 7 os

Am working on this invoice page with textboxes where users enter numbers into them to get their orders. 我在带有文本框的发票页面上工作,用户可以在其中输入数字以获取订单。 Now I use wamp on Windows 7 OS and I am trying to convert the page after the user have entered their figures to pdf and save it in a folder then output it in another window for viewing. 现在,我在Windows 7 OS上使用了wamp,在用户将其数字输入为pdf之后,我试图将页面转换为pdf并将其保存在文件夹中,然后在另一个窗口中输出以进行查看。

So far I have not been able to do much and it's driving me crazy for the past 2 weeks. 到目前为止,我还不能做很多事情,在过去的两周里,这使我发疯。 Please, I need suggestions, really appreciate it. 请,我需要建议,非常感谢。

Here is what I want and need to do: 这是我想要和需要做的:

  1. Save the page as it is in html including the values in the text boxes. 将页面保存为html格式,包括文本框中的值。
  2. Convert the saved page to pdf and store in a directory. 将保存的页面转换为pdf并存储在目录中。
  3. Email the pdf to user. 通过电子邮件将pdf发送给用户。

code so far 到目前为止的代码

  1. saving page html 保存页面html

     function printPDF() { var h = '<style></style>'+$('#article').html(); var html = '<html><body><scr'+'ipt>'; html += 'var form = document.createElement("form");'; html += 'form.setAttribute("method","post");'; html += 'form.setAttribute("action","/ajax/pdf/");'; html += 'var h = document.createElement("input");'; html += 'h.setAttribute("type","hidden");'; html += 'h.setAttribute("name","html");'; html += 'h.setAttribute("value","'+escape(h)+'");'; html += 'form.appendChild(h);'; html += 'document.body.appendChild(form);'; html += 'form.submit();'; html += '</sc'+'ript></body></html>'; var w = window.open('',''); w.document.write(html); w.document.close(); } 

but the problem is that it has to open a new window everytime and i dont want that i want it to be submitted at the background via ajax/jquery, secondly the created html document doesnt have the values in the textboxes they are all cleard. 但是问题是它每次都必须打开一个新窗口,我不希望我希望它通过ajax / jquery在后台提交,其次,创建的html文档在文本框中没有所有被清除的值。

  1. convert page to pdf and store in directory 将页面转换为pdf并存储在目录中

     $filepath = '/www/html/'; $pdfpath = '/www/pdf/'; $filename = date('YmdHisu'); $html = urldecode($_POST['html']); file_put_contents($filepath.$filename.'.html',$html); $pdfcmd = 'wkhtmltopdf.sh '.$filepath.$filename.'.html '.$pdfpath.$filename.'.pdf --disable-javascript'; exec($pdfcmd); if ($fd = fopen($pdfpath.$filename.'.pdf','r')) { $fsize = filesize($pdfpath.$filename.'.pdf'); header('Content-type: application/pdf'); header('Content-length: '.$fsize); header('Cache-control: private'); while(!feof($fd)) { $buffer = fread($fd, 2048); echo $buffer; } fclose($fd); } unlink($filepath.$filename.'.html'); 

have also used a wrapper i got for wkhtmltopdf but none seems to work 也用过我给wkhtmltopdf的包装器,但似乎都没有用

As for the title of the question: Download the latest windows installer from The wkhtmltopdf download site . 至于问题的标题:从wkhtmltopdf下载站点下载最新的Windows安装程序。

Please ask a lot more specific question. 请提出更多具体问题。 To me this looks like you are looking for a ready made solution to use rather than an answer to a specific question. 对我来说,这似乎是您在寻找现成的解决方案以供使用,而不是针对特定问题的答案。 Try going through the problems you are facing one step at a time and every time you encounter a problem, ask a specific question. 尝试一次解决您面临的问题,每次遇到问题时,请提出一个具体问题。

Start with something like: Can you install wkhtmltopdf? 首先开始:您可以安装wkhtmltopdf吗? Can you call it from command line? 您可以从命令行调用它吗? Can you call it from PHP using static HTML files? 您可以使用静态HTML文件从PHP调用它吗? etc. etc. 等等等

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM