ymfhack

ymfhack

Thinking......

  • 财富值4935
  • 威望值170
  • 总积分7175

个人信息

  • 回答了问题 yii2 导出pdf
    use kartik\mpdf\Pdf;
    
    public function actionReport() {
        // get your HTML raw content without any layouts or scripts
        $content = $this->renderPartial('_reportView');
        
        // setup kartik\mpdf\Pdf component
        $pdf = new Pdf([
            // set to use core fonts only
            'mode' => Pdf::MODE_CORE, 
            // A4 paper format
            'format' => Pdf::FORMAT_A4, 
            // portrait orientation
            'orientation' => Pdf::ORIENT_PORTRAIT, 
            // stream to browser inline
            'destination' => Pdf::DEST_BROWSER, 
            // your html content input
            'content' => $content,  
            // format content from your own css file if needed or use the
            // enhanced bootstrap css built by Krajee for mPDF formatting 
            'cssFile' => '@vendor/kartik-v/yii2-mpdf/assets/kv-mpdf-bootstrap.min.css',
            // any css to be embedded if required
            'cssInline' => '.kv-heading-1{font-size:18px}', 
             // set mPDF properties on the fly
            'options' => ['title' => 'Krajee Report Title'],
             // call mPDF methods on the fly
            'methods' => [ 
                'SetHeader'=>['Krajee Report Header'], 
                'SetFooter'=>['{PAGENO}'],
            ]
        ]);
        
        // return the pdf output as per the destination setting
        return $pdf->render(); 
    }
    

    有啥特别的吗

  • 回复了 的回复

    还少个定义格式的方法,就完美了

    设置下来阿,加粗阿,合并阿,颜色阿啥啥的都写上

  • 还少个定义格式的方法,就完美了

  • 可以 但是供访问的最好是在 再多目录 你就要配置了

  • message/message/index 你感觉这个访问的应该是哪 你controller的目录 深了

  • 你如果安全过滤的话 就应该在 get 就转 int if(!is_numeric($page) || !is_numeric($pageSize)) 这俩参数就会变成正常 0 或者无就是默认值就是了

    model::find() 返回的是数据库链接对象 链式返回的都是

  • 回复了 的回答

    Yii应该也是可以用缓存的 但是你看目前Yii模板的解析方式和其他的两种的缓存的方式 就插一个找layout的地方阿

  • /**
         * @return bool whether this response is successful
         */
        public function getIsSuccessful()
        {
            return $this->getStatusCode() >= 200 && $this->getStatusCode() < 300;
        }
    
  • 2017-06-26 已签到
    连续签到1天,获得了5个金钱
副总裁 等级规则
7175/10000
资料完整度
60/100
用户活跃度
10/100

Ta的关注

8

Ta的粉丝

16

Ta的访客

66