title: How to make mPDF wait for my JS to finish
body: <p>I am working with mPDF and Highchart. Both are working, but sometimes the PDF is created before the chart has finished loading (the chart tooks about 2 secods to load). I was wondering if it is possible to delay the mPDF execution, so it waits for the chart.</p>
  
  <pre><code>var chart = new Highcharts.Chart({
    chart: {
      renderTo: 'RDBMS',
      plotBackgroundColor: null,
      plotBorderWidth: null,
      plotShadow: false,
      type: 'pie'
    },
    colors: ['#6495ED', '#FFA07A','#9ACD32','#9370DB','#87CEFA'],
    title: {
      text: 'Servidores por RDBMS'
    },
    tooltip: {
      pointFormat: '{series.name}: &lt;b&gt;{point.percentage:.1f}%&lt;/b&gt;'
    },
    plotOptions: {
      pie: {
        allowPointSelect: true,
        cursor: 'pointer',
        dataLabels: {
      enabled: true,
      format: '{point.y} &lt;br&gt; {point.percentage:.1f} %',
      style: {
        color: (Highcharts.theme &amp;&amp; Highcharts.theme.contrastTextColor) || 'black'
      }
        },
        showInLegend: true
      }
    },
    legend: {
      layout: 'vertical',
      align: 'right',
      verticalAlign: 'middle',
      borderWidth: 0
    },
    series: [{
      name: 'RDBMS',
      colorByPoint: true,
      data: [{
        name: 'Mysql',
        y: 40,        //Dado dinamico
        sliced: true,
        selected: true
      }, {
        name: 'Oracle',
        y: 6, //Dado dinamico
        sliced: true
      }, {
        name: 'SQL Server',
        y: 22,        //Dado dinamico
        sliced: true
      }, {
        name: 'DB2',
        y: 9, //Dado dinamico
        sliced: true
      }, {
        name: 'PostgreSQL',
        y: 1, //Dado dinamico
        sliced: true
      }]
    }]
  });
  
  var opts = chart.options;        
  opts = $.extend(true, {}, opts); 
  delete opts.chart.renderTo;      
  
  var strOpts = JSON.stringify(opts);
  
  $.post(
    'http://export.highcharts.com/',
    {
      content: 'options',
      options: strOpts ,
      type:    'image/jpg',
      width:   '100px',
      scale:   '1',
      constr:  'Chart',
      async:   true
    },
    function(data){
      var imgUrl = 'http://export.highcharts.com/' + data;
      $('#charts').append("&lt;img src='" + data + "' &gt;");
    }
  );
  </code></pre>
  
  <p>This is my code that creates my chart. I call this function at the end of my page, after a table.</p>
  
  <p>And this is what my page looks like <a href="https://i.stack.imgur.com/XbYtC.png" rel="nofollow noreferrer">printscreen</a> </p>