/**
  * @param $id
  * @throws CHttpException
  */
 public function actionPdf($id)
 {
     Yii::import('application.extensions.less.*');
     $lessc = new lessc();
     $lessc->checkedCompile(Yii::getPathOfAlias('webroot.less') . '/' . 'html2pdf.less', Yii::getPathOfAlias('webroot.css') . '/' . 'html2pdf.css');
     $model = $this->loadModel($id);
     if (!$model) {
         throw new CHttpException(404, 'Property not found');
     }
     $settings = InstructionToPdfSettings::model()->findByAttributes(['instructionId' => $id]);
     if (!$settings) {
         $settings = new InstructionToPdfSettings();
     }
     $pdf = new WKPDF();
     $pdf->setMargins(['top' => '40']);
     $pdf->addResource('css', Yii::getPathOfAlias('webroot.css') . '/' . 'html2pdf.css');
     $cssFiles = ['html2pdf.css'];
     /** @var $browser Browser */
     $browser = Yii::app()->browser;
     if ($browser->getBrowser() == Browser::BROWSER_FIREFOX && $browser->getVersion() >= 19) {
         $pdf->addResource('css', Yii::getPathOfAlias('webroot.css') . '/' . 'helvetica_html2pdf.css');
         $cssFiles[] = 'helvetica_html2pdf.css';
     }
     $pdf->set_html($this->renderPartial('instructionToPDF', ['model' => $model, 'settings' => $settings, 'pdf' => $pdf, 'cssFiles' => $cssFiles], true));
     $pdf->set_htmlHeader($this->renderPartial('instructionToPDF/header', ['model' => $model, 'settings' => $settings, 'pdf' => $pdf, 'cssFiles' => $cssFiles], true));
     $pdf->set_htmlFooter($this->renderPartial('instructionToPDF/footer', ['model' => $model, 'settings' => $settings, 'pdf' => $pdf, 'cssFiles' => $cssFiles, 'offices' => Office::model()->active()->findAll()], true));
     $pdf->set_orientation(WKPDF::$PDF_PORTRAIT);
     $pdf->render();
     $pdf->output(WKPDF::$PDF_EMBEDDED, null);
 }