Guest User

Untitled

a guest
Jun 22nd, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <title></title>
  6. </head>
  7. <body>
  8.  
  9. <script src="https://code.jquery.com/jquery-1.12.1.min.js"></script>
  10. <script src="main.js"></script>
  11.  
  12. <button type="button" onclick="GenerarPDF()">click</button>
  13. <div id="resulta"></div>
  14.  
  15. </body>
  16.  
  17. </html>
  18.  
  19. function GenerarPDF() {
  20.  
  21. $.ajax(
  22. {
  23. type: 'POST',
  24. url: 'pdf.php',
  25. data: {"saludo": "hola"}, //aquí le pasaré datos de controles de HTML
  26.  
  27. success: function (result) {
  28. $('#resulta').html(result);
  29. }
  30. }
  31. );
  32. }
  33.  
  34. <?php
  35.  
  36. require_once('PDF/fpdf/fpdf.php');
  37.  
  38. $saludo = $_POST['saludo'];
  39.  
  40.  
  41. $pdf = new FPDF('P', 'mm', 'Letter');
  42. $pdf->AddFont('Courier', '');
  43. $pdf->AddPage();
  44. $pdf->SetFont('Courier', '', 11);
  45. $pdf->Cell(50,10,$saludo);
  46. $pdf->Output();
Add Comment
Please, Sign In to add comment