title: yii2 basic printing a page in pdf
body: <p>please help. 
  Hallo all, Am on verge of finishing a project created using yii2 basic. my problem is, I want to print a using with pdf as its output. I have tried yii2 mpdf and yii2-pdf without any success. I want to place the print button in the index.php of a view file. here's is my code snippet located at index view file.</p>
  
  <pre><code>&lt;?= Html::a('&lt;i class="fa glyphicon glyphicon-hand-up"&gt;&lt;/i&gt;Property report',['/propertydetails/report'],
          [
           'class'=&gt;'btn btn-danger',
           'target'=&gt; '_blank',
           'data-toggle'=&gt;'tooltip',
           'title'=&gt;'Generate the pdf']); ?&gt; 
  </code></pre>
  
  <p>And here's my controller</p>
  
  <pre><code>use kartik\mpdf\Pdf;
  
  //function for reports
  public function actionReport()
  {
      //get your html raw content without layouts
     // $content = $this-&gt;renderPartial('view');
      //set up the kartik\mpdf\Pdf component
      $pdf = new Pdf([
          'content'=&gt;$this-&gt;renderPartial('view'),
          'mode'=&gt; Pdf::MODE_CORE,
          'format'=&gt; Pdf::FORMAT_A4,
          'orientation'=&gt;Pdf::ORIENT_POTRAIT,
          'destination'=&gt; Pdf::DEST_BROWSER,
          'cssFile' =&gt; '@vendor/kartik-v/yii2-mpdf/assets/kv-mpdf-bootstrap.min.css',
          'cssInline'=&gt; '.kv-heading-1{font-size:18px}',
          'options'=&gt; ['title'=&gt; 'Paki Properties Reports'],
          'methods'=&gt; [
                 'setHeader'=&gt;['Generated on: '.date("r")],
                 'setFooter'=&gt;['|page {PAGENO}|'],
                  ]
          ]);
      return $pdf-&gt;render();
  }
  </code></pre>
  
  <p>when I click the button I get this error</p>
  
  <pre><code> PHP Notice – yii\base\ErrorException
  </code></pre>
  
  <p>Undefined variable: model</p>
  
  <pre><code>1. in C:\wamp\www\pakiSystems1\views\propertydetails\view.php at line 9
  123456789101112131415161718
  
  &lt;?php
  
  use yii\helpers\Html;
  use yii\widgets\DetailView;
  
  /* @var $this yii\web\View */
  /* @var $model app\models\Propertydetails */
  
  $this-&gt;title = $model-&gt;propertyId;
  $this-&gt;params['breadcrumbs'][] = ['label' =&gt; 'Propertydetails', 'url' =&gt; ['index']];
  $this-&gt;params['breadcrumbs'][] = $this-&gt;title;
  ?&gt;
  &lt;div class="propertydetails-view"&gt;
  
      &lt;h1&gt;&lt;?= Html::encode($this-&gt;title) ?&gt;&lt;/h1&gt;
  
      &lt;p&gt;
          &lt;?= Html::a('Update', ['update', 'id' =&gt; $model-&gt;propertyId], ['class' =&gt; 'btn btn-primary']) ?&gt;
  
  2. in C:\wamp\www\pakiSystems1\vendor\yiisoft\yii2\base\View.php – yii\base\View::renderPhpFile() at line 247
  3. in C:\wamp\www\pakiSystems1\vendor\yiisoft\yii2\base\View.php – yii\base\View::renderFile() at line 149
  4. in C:\wamp\www\pakiSystems1\vendor\yiisoft\yii2\base\Controller.php – yii\base\View::render() at line 398
  5. in C:\wamp\www\pakiSystems1\controllers\PropertydetailsController.php – yii\base\Controller::renderPartial() at line 77
  71727374757677787980818283
  
      public function actionReport()
      {
          //get your html raw content without layouts
         // $content = $this-&gt;renderPartial('view');
          //set up the kartik\mpdf\Pdf component
          $pdf = new Pdf([
              'content'=&gt;$this-&gt;renderPartial('view'),
              'mode'=&gt; Pdf::MODE_CORE,
              'format'=&gt; Pdf::FORMAT_A4,
              'orientation'=&gt;Pdf::ORIENT_POTRAIT,
              'destination'=&gt; Pdf::DEST_BROWSER,
              'cssFile' =&gt; '@vendor/kartik-v/yii2-mpdf/assets/kv-mpdf-bootstrap.min.css',
              'cssInline'=&gt; '.kv-heading-1{font-size:18px}',
  </code></pre>
  
  <p>any help I will highly appreciate. Thanks in advance</p>