'Print generated pdf (with tcpdf) in an iframe after Ajax call

I'm using tcpdf to create pdf files with ajax call that send some data to pdf script for generating the pdf, then i would like to pass the pdf to iframe src

My tcpdf pdf creation ; last lines

    $p = header ("Content-Type: application/pdf");
    echo $pdf->Output('', 'S');

Ajax call

 var form = $("#submiEditCanevaForm");
        $.ajax({
            url: form.attr('action'),
            type: form.attr('method'),
            data: form.serialize(),
            success: function (data) {

                console.log(data);

                var blob = new Blob([data], { type: 'application/pdf' });
                var downloadUrl = URL.createObjectURL(blob);
                $('#pdf_file_edit').attr("src", downloadUrl);


   
            }


        });

enter image description here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source