MPDF generated pdf document is not downloading

Hi
I need to create a custom pdf using the MPDF(which suiteCRM uses) . If a button is selected on the accounts detail view it will make an AJAX request to download the generated pdf. but it is not downloading (I saw the coding of AOR Reports controller download pdf action both are same).

Below is my code

 require_once('modules/AOS_PDF_Templates/PDF_Lib/mpdf.php');
        $d_image = explode('?', SugarThemeRegistry::current()->getImageURL('company_logo.png'));


        $head = '<table style="width: 100%; font-family: Arial; text-align: center;" border="0" cellpadding="2" cellspacing="2">
                <tbody style="text-align: left;">
                <tr style="text-align: left;">
                <td style="text-align: left;">
                <p><img src="' . $d_image[0] . '" style="float: left;"/>&nbsp;</p>
                </td>
                <tr style="text-align: left;">
                <td style="text-align: left;"></td>
                </tr>
                 <tr style="text-align: left;">
                <td style="text-align: left;">
                </td>
                <tr style="text-align: left;">
                <td style="text-align: left;"></td>
                </tr>
                <tr style="text-align: left;">
                <td style="text-align: left;">
                <b>' . strtoupper($this->bean->name) . '</b>
                </td>
                </tr>
                </tbody>
                </table><br />';
        $stylesheet = file_get_contents(SugarThemeRegistry::current()->getCSSURL('style.css', false));

    try{

                $pdf=new mPDF('en','A4-L','','DejaVuSansCondensed');
                $pdf->setAutoFont();
                $pdf->WriteHTML($stylesheet,1);

                $pdf->WriteHTML($head,2);
                $pdf->WriteHTML('<div><h2 style="text-align: center; font-size: 25px; border: 1px solid #000;">Contacts</h2></div>',2);
                $pdf->Output('testdd.pdf', "D");

            }catch(mPDF_exception $e){
                echo $e;
            }
            die;


This is my AJAX request code


$('#modalSelectFields .btn-select').on('click', function () {
  
    $.ajax({
        type: "POST",
        url: "index.php?module=Accounts&action=Mtest&to_pdf=1",
       
        dataType: "json",
        success: function (data) {

        },
        error:function (error) {
            alert(error)
        }

    })
})

Please help me on this.

Thanks