I work in Phalcon framework. I have a search form and empty div tag where i want my search results to appear. So, when i end my search i want to create pdf from that view. But, when i try this I only print the first state of a view in pdf file without search result. Here is my controller function:

     public function dajPdfAction(){
// Creates the autoloader
$loader = new \Phalcon\Loader();

array( "mpdf"=> "C:/wamp/www/phalcon1/mpdf/mpdf.php" ) );

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

<?php use Phalcon\Tag; ?> <?php echo Phalcon\Tag::javascriptInclude("https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js", false); echo Phalcon\Tag::javascriptInclude("javascript/jquery.js"); echo Phalcon\Tag::stylesheetLink("css/test.css"); echo Phalcon\Tag::stylesheetLink("https://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css", false); echo Phalcon\Tag::javascriptInclude("https://code.jquery.com/ui/1.10.3/jquery-ui.js", false);


<script type="text/javascript">


//atr = $(".klasa").attr("id");
//alert("Id je: " + atr)

// alert('<?php echo $this->url->get("public/img");?>/spinner1.gif'); $("#poruka").dialog(); var imena=new Array(); $("#loader").fadeIn('600'); $("#loader").append("<p id='poruka1'>Ovdje idu rezultati vase pretrage...</p>"); $.ajax({ url: '<?php echo $this->url->get("test/getAllKorisnik"); ?>', type: 'POST', dataType: 'json', success: function(data){ for (i=0; i<data.length; i++) { imena.push(data[i]); } $( "#nesto" ).autocomplete({ source: imena }); }, error: function(){ alert("Neuspjesan JSON zahtjev!"); }


var n = $(this).val();
    case '1':
    case '2':
     case '3':

} });

//ajax poziv za sve korisnike

$('#search').click(function(){ var visina = $(document).height(); $(document).scrollTop(visina*0.5); //alert("Visina je:" + visina); var dodatak = $('#nesto').val(); //$("#loader").addClass('loading'); $("#loader").empty(); $("#loader").append("<div id='lltest'> <div>"); //alert("Unio si: " + dodatak); //$("#loader").fadeIn("200"); var ime = $('#nesto').val(); var prezime = $('#prez').val(); var email = $('#email').val();

    url: '<?php echo  $this->url->get("test/getKorisnik");?>',
    type: 'POST',
    dataType: 'json',
    data: {ime:ime, prezime:prezime, email:email},
    success: function(data){
        if (data==null) {
            $("#loader").append("<div id='greska'> </div>");

        $("#loader").append("<p id='naslov'>Rezultat pretrage:</p><hr />");
        $("#loader").append("<table id='tab' border='1'/>");
        $("#loader table").append("<tr><th class='zag'>Ime</th><th class='zag'>Prezime</th><th class='zag'>Adresa stanovanja</th><th class='zag'>Email</th></tr>");

        for (i=0; i<data.length; i++) {
            //$("#loader").append("<p class='izlaz'>Ime: " + data[i].ime + "</p>" + "<p class='izlaz'>Prezime: " + data[i].prezime + "<br />");

            $("#loader table").append("<tr><td class='sadr'>" + data[i].ime + "</td><td class='sadr'>" + data[i].prezime + "</td><td class='sadr'>" + data[i].adresa + "</td>"+
            "<td class='sadr'>" + data[i].email + "</td></tr>");   



    error: function(){

  // $("#loader").empty();

}) ;



<p id="poruka" style="display:none">Dobro dosli na pretragu artikala.</p> <p style="padding-left:20px;">Choose search category: <select id="opcije"> <option value="1" selected="1">Packing list</option> <option value="2">Artupal</option> <option value="3">Paket</option> <option value="4">Micro</option> <option value="5">Palete</option> <option value="6">Jedinicno</option> </select></p> <div id="1" class="wrapper" style=""> <div class="steps"> <fieldset class="step"> <legend>Search form Packing List</legend> <p> <label for="name">Name</label> <?php $opt = array('name', 'id'=>'nesto', 'size'=>'20'); $buttopt = array('Show', 'id'=>'dugme','class'=>'klasa'); $topt1 = array('surname', 'id'=>'prez', 'size'=>'20'); $topt2 = array('email', 'id'=>'email', 'size'=>'20'); ?> <?php echo Tag::textField($opt) ?> </p> <p> <label for="surname">Surname</label> <?php echo Tag::textField($topt1) ?>

</p> <p> <label for="email">Email</label> <?php echo Tag::textField($topt2) ?> </p>

<input type="image" id="search" src="/phalcon1/public/img/pretraga.jpg"/> </fieldset> </div>


<div id="2" class="wrapper" style="display: none;"> <div class="steps"> <fieldset class="step"> <legend>Search form Artupal</legend> <p> <label for="name">Param1</label> <?php $opt = array('name', 'id'=>'nesto', 'size'=>'20'); $buttopt = array('Show', 'id'=>'dugme','class'=>'klasa'); $topt1 = array('surname', 'id'=>'prez', 'size'=>'20'); $topt2 = array('email', 'id'=>'email', 'size'=>'20'); ?> <?php echo Tag::textField($opt) ?> <p> <p> <label for="surname">Param2</label> <?php echo Tag::textField($topt1) ?>

</p> <p> <label for="email">Param3</label> <?php echo Tag::textField($topt2) ?> </p>

<input type="image" id="search" src="/phalcon1/public/img/pretraga.jpg"/> </fieldset> </div>


<?php echo Tag::form("test/dajPdf"); ?>

<p> <?php echo Tag::submitButton("OK") ?> </p>