title: PHP, Codeigniter, Dompdf: HTML generating fine but exectuion time out whlie rederning PDF
body: <p>I have large amount of data that needs to be process and add as tables in PDF using Codeigniter. PDF contain some HTML elements, images, icons, and need lots of alignment using CSS.</p>
  
  <p>So, to achieve this goal I did some search and checked which PDF generation plugin will be suitable for me. So, rather than selecting FPDF, TCPDF or HTMLTOPDF, mPDF etc. I chosen DOMPDF as it is supporting most of the css styles and it serves my purpose as well.</p>
  
  <p>Initially, it was working fine as data was not much heavy and PDF with 10-20 pages was generating fine. But, as data gets increased and need to put about 35-45 pages in my PDF, system gets time out.</p>
  
  <p>So, I changed server settings and made "4GB of RAM with 1 CPU to 8GB of RAM with 4 CPUs". And, increased max_execution_time to 90, memory_limit to 384M but still DOMPDF not rendering large PDFs having pages more than about 35.</p>
  
  <p>I have set landscape mode to download PDF instead save it.</p>
  
  <p>Below is the PHP code in my controller of Codeigniter.</p>
  
  <pre><code>    $this-&gt;load-&gt;library('pdf');
  
      $teaminfo=$this-&gt;pdf_model-&gt;getTeamName($teamid);
      $data=array();
      if($teaminfo != false)
      {
          $teamname=$teaminfo-&gt;team_name;
          $data['teamname']=$teamname;
          $formateddate=date('F j, Y');
          $data['teammeetingdate']=$formateddate;
  
          //add code to get and pass the terms and replacement array
          $termsList=$this-&gt;getTermsArray($teamid);
          $data['searchterms']=$termsList['searchterms'];
          $data['replacement']=$termsList['replacement'];
  
          //get teammeeting roster
          $data['rosterlist']=$this-&gt;getRostertable($teamid);
  
          $personwisedata=$this-&gt;getteammemberData($teamid);
          $data['personwiseData']=$personwisedata;
  
          $kmresponse=$this-&gt;get_last_six_month_keymetrics_details_by_userid_without_owner($teamid);
          $data['noownerkmdata']=$kmresponse;
  
          //set pdf title
          $teamnametitle='My PDF Notes - '.$teamname.' '.date("m.d.Y"); 
          $pdftitle=$teamnametitle.'.pdf';
  
        $this-&gt;pdf-&gt;set_paper('a4', 'landscape');
        $this-&gt;pdf-&gt;set_option( 'enable_font_subsetting' , true );
        $this-&gt;pdf-&gt;load_view('backend/Pdf/teammeeting_pdf', $data);
        $this-&gt;pdf-&gt;render();
        $this-&gt;pdf-&gt;stream($pdftitle,array("Attachment" =&gt; 0));
      }
  </code></pre>
  
  <p>For small size PDFs it is working fine. But, when long PDF need to generate execution stops and showing error "Internal Server Error" on page.</p>
  
  <p>When I just print output on browser by putting exit, it works within a minute, but when I send that html to render on PDF and stream it, system stops execution.</p>
  
  <p>I tried to set max_execution_time and memory_limit through htaccess and ini_set but it not helped me.</p>
  
  <p>Hope so anyone will help me.</p>