yii2 css无法使用pdf创建?

时间:2016-01-04 16:35:14

标签: php html css pdf yii2

我正在使用yii2并希望将我的html视图转换为pdf格式,因为我已经使用了 mPDF yii2 install

在我的控制器动作中,我这样做:

public function actionPdf(){
    Yii::$app->response->format = 'pdf';
     $this->layout = '//print';
    return $this->render('myview', []);
} 

当我从行动中移除Yii::$app->response->format = 'pdf';这一行时。我总是用css得到正确的观点。 view without pdf

但是当我使用Yii::$app->response->format = 'pdf';这个用于pdf生成时,我只得到没有css的pdf视图。

我已将CSS文件包含在布局中。我应该怎样做才能获得正确的pdf视图?

1 个答案:

答案 0 :(得分:0)

  1. 您是否已将CSS内联?
  2. Is the CSS you expect allowed by mPDF?
  3. 基本上,yii2-pdfmPDF库周围的薄包装。如果<link需要您的样式,则不会包含您的样式,前提是它们包含在<style代码中。

相关问题