Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="UTF-8">
- <title></title>
- </head>
- <body>
- <script src="https://code.jquery.com/jquery-1.12.1.min.js"></script>
- <script src="main.js"></script>
- <button type="button" onclick="GenerarPDF()">click</button>
- <div id="resulta"></div>
- </body>
- </html>
- function GenerarPDF() {
- $.ajax(
- {
- type: 'POST',
- url: 'pdf.php',
- data: {"saludo": "hola"}, //aquí le pasaré datos de controles de HTML
- success: function (result) {
- $('#resulta').html(result);
- }
- }
- );
- }
- <?php
- require_once('PDF/fpdf/fpdf.php');
- $saludo = $_POST['saludo'];
- $pdf = new FPDF('P', 'mm', 'Letter');
- $pdf->AddFont('Courier', '');
- $pdf->AddPage();
- $pdf->SetFont('Courier', '', 11);
- $pdf->Cell(50,10,$saludo);
- $pdf->Output();
Add Comment
Please, Sign In to add comment