I want to send some html content via jQuery to tcpdf and create an pdf. I have this in my index.php:
$('#test').click(function() {
   var result='hello';
    $.ajax({
     type: 'POST',
     url: 'pdf.php',
     data: {result: result},         
    });
})
and the pdf.php:
<?php
$result = '';
 if(isset($_POST['result'])) {
    $result = $_POST['result'];
 }
require_once('tcpdf/tcpdf.php');
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetTitle('Production sheet');
$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH);
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
$pdf->SetFont('helvetica', '', 9);
$pdf->AddPage();
$html = '
      <h1>TEST</h1> 
      <table>
      <tr><td>'.$result.'</td></tr>           
      </table>       
      ';
$pdf->writeHTML($html, true, 0, true, 0);
$pdf->lastPage();
$pdf->Output('test.pdf', 'I');
?>
If I define variable result ($result = "Hello";) and i run directly pdf.php it's working perfect. It seems that for some reason my post isn't taken by pdf.php... Some ideas?
Thank you!
 
     
    