We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

Generate PDF using jquery ajax

i am working with phalcon php framework. I want to send data displayed in a div tag(it is a result of a search)to controller function, and controller will generate pdf file. But, pdf file is not generating. Here is my view:

  var imenica = "Ja se zovem Nedim Omerbegovic";
        url: '<?php echo  $this->url->get("test/creatingpdf");?>',
        type: 'POST',
        dataType: '',
        data: {imenica:imenica},
        success: function(data){
            } ,
            error: function(){


and here is code for controller:

public function creatingpdfAction(){
    $string =$_POST['imenica'];

          $loader = new \Phalcon\Loader();
    "mpdf"=> "C:/wamp/www/phalcon1/mpdf/mpdf.php"

    //$string = "Ja se zovem Nedim Omerbegovic";
    $view = new \Phalcon\Mvc\View();
    $cont = $this->view->getRender('test', 'creatingpdf');
    //generisanje pdf dokumenta
    $pdf = new mpdf();
    $pdf->WriteHTML($cont, 2);
    $br = rand(0,100000);
    $ispis = "Pobjeda Rudet-Izvjestaj-".$br;
    $pdf->Output($ispis, 'I');

How can i see generated pdf file in this way of warking. Please, if anyone knows help me.

Hi there To generate pdf files using code is so difficult for me.However ,i usually do the pdf generating using this program: https://www.rasteredge.com/how-to/csharp-imaging/pdf-processing/ It's very convenient to process pdf files.Hope to help you.