Javascript with PHP to generate a PDF

Asked

Viewed 295 times

0

I have a dynamic table on Javascript. I need to send to the PHP all items that have been added to it and generate a PDF with class mPDF.

Could someone help.

HTML/Javascript code: https://jsfiddle.net/Zharor/sumt8603/

PHP code:

<?php
$item = utf8_encode($_POST['item']);<br>
$descricao = utf8_encode($_POST['descricao']);<br>
$unidade = utf8_encode($_POST['unidade']);<br>
$pedido = utf8_encode($_POST['pedido']);<br>

//PEGA O ARQUIVO MODELO<br>
$pdf = file_get_contents("modelo.html");<br>

//SUBSTITUI COM OS DADOS FORNECIDOS<br>
$pdf = str_replace("#item","$item",$pdf);<br>
$pdf = str_replace("#descricao","$descricao",$pdf);<br>
$pdf = str_replace("#unidade","$unidade",$pdf);<br>
$pdf = str_replace("#pedido","$pedido",$pdf);<br>

//SOLICITA A CLASS MPDF<br>
require_once("mpdf/mpdf.php");<br>

//INSTANCIA A CLASS MPDF<br>
$mpdf = new mPDF( );<br>

//ESCREVE O PDF<br>
$mpdf->WriteHTML($pdf);<br>
ob_clean();<br>

//SAIDA DO PDF NO NAVEGADOR<br>
$mpdf->Output();<br>
?>

I’m wearing Bootstrap 3.3.7

  • It has to be next to the server ? It can’t be next to the client ? I have this reply and that another on generate PDF using the library jsPDF.

  • do not send to the server no, I just want you to create a pdf with the items that are in the table, can you help me in this jsPDF ? thanks for the reply

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.