【问题标题】:yii2 css is not working with pdf creation?yii2 css 不适用于 pdf 创建?
【发布时间】:2023-04-10 20:58:01
【问题描述】:

我正在使用 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 有正确的看法。

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

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

【问题讨论】:

  • 我有同样的问题我的 css 在 pdf 转换器时无法正常工作。我正在使用 pdf 插件
  • 我将添加我的代码..请帮助我,我是 yii2 的新手
  • stackoverflow.com/questions/36832306/… 在此链接上发布了我的问题...请帮助我,我是 yii2 的新手

标签: php html css pdf yii2


【解决方案1】:
  1. 您是否已将 CSS 内联?
  2. Is the CSS you expect allowed by mPDF?

基本上,yii2-pdfmPDF 库的一个薄包装。如果通过<link 需要样式,它将不包含您的样式,仅当它们作为<style 标记包含时。

【讨论】:

    猜你喜欢
    • 2020-11-02
    • 2017-03-03
    • 2017-09-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-09-24
    • 2018-05-21
    • 1970-01-01
    相关资源
    最近更新 更多