title: HTML2PDF 504 Gateway Timeout
body: <p>I am trying to convert HTML 2 PDF with <a href="https://github.com/spipu/html2pdf" rel="nofollow noreferrer">this</a> library and its converting fine as per my expectations.</p>
  
  <p>However, When I convert with more data, its giving me an error saying <strong>504 Gateway Timeout</strong>. Here is the error screenshot what I am getting. </p>
  
  <p><a href="https://i.stack.imgur.com/DpdzP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DpdzP.png" alt="enter image description here"></a></p>
  
  <p>In local server its working fine. I have the same server in my local and my live (Linux). The only problem is I am getting when I try to produce PDF with long data on live server.</p>
  
  <p>I researched and found out that to increase php execution time and other settings. Hence I try to put below code in my <strong>.php</strong> file. </p>
  
  <pre><code>ini_set('max_execution_time', 60000);
  ini_set('post_max_size','128M');
  ini_set('upload_max_filesize','128M');
  </code></pre>
  
  <p>I even try to set <code>max_execution_time</code> to <code>0</code> and <code>-1</code> but yet its not working for me. After setting this values, I even printed the updated values with <code>phpinfo()</code>, the values are overwriting but I am having the same <strong>502 Gateway timeout</strong> error. Here is small chunk of code just in case you want to see. </p>
  
  <pre><code>&lt;?php
  
  ini_set('max_execution_time', 60000);
  ini_set('post_max_size','20M');
  ini_set('upload_max_filesize','8M');
  
  require_once dirname(__FILE__) . '/vendor/autoload.php';
  require_once dirname(__FILE__) . '/templateInfo.php';
  
  use Spipu\Html2Pdf\Html2Pdf;
  use Spipu\Html2Pdf\Exception\Html2PdfException;
  use Spipu\Html2Pdf\Exception\ExceptionFormatter;
  use technobrave\brochuresettings\Models\Brochuresettings as BS;
  use Technobrave\Transactions\Models\Transactions as TR;
  use Technobrave\Offices\Models\Offices;
  use technobrave\themesettings\Models\ThemeSetting as TS;
  use Technobrave\Team\Models\Team;
  
  
  
  class generateTemplate {
  
  
  
      public $theme = "";
  
      public $theme_settings = array();
  
      public function __construct($templateId, $resolution , $theme ,$pdf_sections = array(),$openFile = false, $finalPdfFile = null) {
  
          $this-&gt;getBrochureTransactionData = BS::first();
          $this-&gt;getPdfSection = $pdf_sections;
          $this-&gt;theme_settings = TS::first();
          $this-&gt;theme = $theme;
          $this-&gt;baseUrl = url(Config::get('cms'));
          $this-&gt;teamPageName = $this-&gt;baseUrl . '/our-team';
          $this-&gt;capabilitiesPageName = $this-&gt;baseUrl . '/capabilities';
          $this-&gt;getFooterText = $this-&gt;getFooterText();
          $getTeamId = (isset($_GET['teamId']) &amp;&amp; !empty($_GET['teamId'])) ? $_GET['teamId'] : "";
          $this-&gt;uniquePath = __DIR__ . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR;
          $templatePath = __DIR__ . DIRECTORY_SEPARATOR . 'regency_template' . DIRECTORY_SEPARATOR . $getTeamId . DIRECTORY_SEPARATOR . $templateId . '.php';
          $templateInfoText = new templateInfo($templateId, $this-&gt;uniquePath, $getTeamId);
          $this-&gt;customImagePath = $this-&gt;uniquePath;
  
          foreach ($templateInfoText-&gt;defaultValues as $key =&gt; $value) {
              $this-&gt;{$key} = $value;
          }
  
  
          $template = file_get_contents($templatePath);
  
  
  
          try 
          {
  
              $html2pdf = new Html2Pdf('L','A4', 'en', true, 'UTF-8', array(0, 0, 0, 0));
              $html2pdf-&gt;Addfont('perpetua');
              $html2pdf-&gt;Addfont('montserratbold');
              $html2pdf-&gt;Addfont('montserratmedium');
              $html2pdf-&gt;Addfont('montserratregular');
              $html2pdf-&gt;Addfont('montserratsembold');
              $html2pdf-&gt;Addfont('montserratitalic');
              $html2pdf-&gt;writeHTML($template, false);
  
              $html2pdf-&gt;Output('regency_corporate_brochure.pdf', 'D');
  
  
          } catch (Html2PdfException $e) {
              $formatter = new ExceptionFormater($e);
              echo $formatter-&gt;getHtmlMessage();
          }
  
      }
  }
  </code></pre>
  
  <p>I tried to preview how my HTML is generating and its generating without any error. </p>
  
  <pre><code>$html2pdf-&gt;writeHTML($template, true); 
  </code></pre>
  
  <p>So basically I am facing server issue here as per my understanding so far. </p>
  
  <p>Can someone guide me what should I do from here on to solve this issue. </p>