title: How to export HTML page into PDF using kartik mpdf in Yii2?
body: <p>I need to export my html file into Pdf format and save it into pdf folder . 
  So far i had done this .</p>
  
  <blockquote>
    <p>This is my html page saved as messagesend.php which need to be export .</p>
  </blockquote>
  
  <pre><code>  &lt;?php
      $rfp = \app\models\RfpMeta::find()-&gt;where(['rfp_id' =&gt; $rfp_id])-&gt;all();
  
      ?&gt;
  
  &lt;div style="display: inline-block;
       width: 85%;
       margin: 10px;
       border: 1px solid #ccc;
       "&gt;
      &lt;div style="width: 100%;*zoom: 1;"&gt;
          &lt;div style="padding: 15px 5px;height: 65px;width: auto;background-color: #3398d4;"&gt;
  
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;div style="margin: 5px;"&gt;&lt;/div&gt;
      &lt;div style="width: 100%;*zoom: 1;"&gt;
          &lt;div style="margin:10px 0;padding: 5px;"&gt;
              &lt;span style="margin-top:20px;margin-bottom:10px;font-family:inherit;font-weight:bold;line-height:1.1;color:#444;font-size: 18px;"&gt; Request For Proposal&lt;/span&gt;&lt;br&gt;&lt;br&gt;
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;div style="width: 100%;*zoom: 1;"&gt;
          &lt;div style="padding: 5px;"&gt;
               &lt;p  class="text-center" style="text-align:justify"&gt;Subject : &lt;?php echo $subject;
                                                  ?&gt;&lt;/p&gt;
                                                  &lt;br/&gt;
              &lt;p style="text-align:justify;"&gt;Dear &lt;?php 
                                                foreach ($model as $key ) {
                                                   echo  $key ." ". "/" ;                                              }
                                                  ?&gt;,&lt;/p&gt; &lt;br/&gt;
              &lt;p style="text-align:justify;"&gt; &lt;?php echo $message ?&gt;&lt;br&gt;
  
  
            &lt;table class="table table-hover table-striped table-bordered table-condensed"&gt;
              &lt;thead&gt;
                     &lt;tr&gt;
                      &lt;th class="text-center"&gt;Item&lt;/th&gt;
                      &lt;th class="text-center"&gt;Quantity&lt;/th&gt;
                      &lt;th class="text-center"&gt;Unit&lt;/th&gt;
                  &lt;/tr&gt;
              &lt;/thead&gt;
              &lt;?php
               foreach ($rfp as $each) {
                      $typ = $each-&gt;type;
                     if ($typ == 1)
                 {
                 $model = \app\models\RawMaster::findOne(['id'=&gt;$each['item']])-&gt;raw_name;
  
  
                 }
                 elseif ($typ ==2)
                 {
                 $model = \app\models\AssetMaster::findOne(['id'=&gt;$each['item']])-&gt;asset_name;
                 }
                 elseif ($typ == 3) {
               $model = \app\models\MachineMaster::findOne(['id'=&gt;$each['item']])-&gt;name;
                 }
  
                  ?&gt;
              &lt;tbody&gt;
                &lt;tr&gt;
                  &lt;td&gt; &lt;?= $model;?&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;?= $each['qty']?&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;?= $each['unit'] ?&gt;&lt;/td&gt;
              &lt;/tr&gt; 
  
          &lt;/tbody&gt;
          &lt;?php }
          ?&gt;
      &lt;/table&gt;
  
       &lt;p style="text-align:justify;"&gt;
                  Thank you.&lt;br&gt;
              &lt;/p&gt;
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;div style="width: 100%;*zoom: 1;"&gt;
          &lt;div style="padding: 5px;"&gt;
              &lt;br&gt;
              &lt;p style="text-align:justify;color:#777"&gt;If you want to  unsubscribe &lt;a href=""&gt;click here&lt;/a&gt;&lt;/p&gt;
              &lt;p style="font-size: x-small;text-align:justify;color:#777"&gt;
                  This e-mail and any files transmitted with it may contain privileged or confidential information.
                  It is solely for use by the individual for whom it is intended, even if addressed incorrectly. If you received this e-mail in error, please notify the sender; do not disclose, copy, distribute, or take any action in reliance on the contents of this information; and delete it from your system.
                  Any other use of this e-mail is prohibited.
  
                  Thank you for your compliance.
  
                  Copyright © 2016 by All rights reserved.
              &lt;/p&gt;
  
          &lt;/div&gt;
      &lt;/div&gt;
  
  &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Now below is my controller which i used to generate pdf .</p>
  
  <pre><code> use kartik\mpdf\Pdf;
  public function actionReport() {
  // get your HTML raw content without any layouts or scripts
  $content = $this-&gt;renderPartial('messagesend');
  
  // setup kartik\mpdf\Pdf component
  $pdf = new Pdf([
      // set to use core fonts only
      'mode' =&gt; Pdf::MODE_CORE, 
      // A4 paper format
      'format' =&gt; Pdf::FORMAT_A4, 
      // portrait orientation
      'orientation' =&gt; Pdf::ORIENT_PORTRAIT, 
      // stream to browser inline
      'destination' =&gt; Pdf::DEST_BROWSER, 
      // your html content input
      'content' =&gt; $content,  
      // format content from your own css file if needed or use the
      // enhanced bootstrap css built by Krajee for mPDF formatting 
      'cssFile' =&gt; '@vendor/kartik-v/yii2-mpdf/assets/kv-mpdf-bootstrap.min.css',
      // any css to be embedded if required
      'cssInline' =&gt; '.kv-heading-1{font-size:18px}', 
       // set mPDF properties on the fly
      'options' =&gt; ['title' =&gt; 'Krajee Report Title'],
       // call mPDF methods on the fly
      'methods' =&gt; [ 
          'SetHeader'=&gt;['Krajee Report Header'], 
          'SetFooter'=&gt;['{PAGENO}'],
      ]
  ]);
  
  // return the pdf output as per the destination setting
  return $pdf-&gt;render(); 
  </code></pre>
  
  <p>}</p>
  
  <p>It now show the following error . Error in below image .<a href="https://i.stack.imgur.com/rJCO4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rJCO4.png" alt="enter image description here"></a></p>
  
  <p>How can i generate Pdf now ? Also i am new to this so can you guys explain me little more ?</p>