简体   繁体   中英

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.

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.
  2. Convert the saved page to pdf and store in a directory.
  3. Email the pdf to user.

code so far

  1. saving page 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.

  1. convert page to pdf and store in directory

     $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

As for the title of the question: Download the latest windows installer from The wkhtmltopdf download site .

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? Can you call it from command line? Can you call it from PHP using static HTML files? etc. etc.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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