2016-07-05 3 views

답변

1

난 당신이

public function actionPdf() 
{ 
    $pdf = new Pdf([ 
     'mode' => Pdf::MODE_CORE, 
     'format' => Pdf::FORMAT_A4, 
     'orientation' => Pdf::ORIENT_PORTRAIT, 
     'destination' => Pdf::DEST_BROWSER, 
     'content' => $contents, 
     'filename' => 'Filename', 
     'cssFile' => '@vendor/kartik-v/yii2-mpdf/assets/kv-mpdf-bootstrap.css', 
     'cssInline' => '.modal-footer{text-align:left;}div.modal-body{padding:0px;}', 
     'options' => ['title' => 'Devis'], 
     'methods' => [ 
      'SetFooter'=>[$footer], 
     ] 
    ]); 
    Yii::$app->response->format = \yii\web\Response::FORMAT_RAW; 
    $headers = Yii::$app->response->headers; 
    $headers->add('Content-Type', 'application/pdf'); 
    return $pdf->render(); 
} 

이 당신이 PDF 컨트롤러에 예를 들어 kartik에서 cssFile 및 cssInline, 를 구성해야합니다 감사합니다 그리고 당신은 CSS에서 당신이 원하는 것을 할 공급 업체 폴더에이 파일로 이동 @vendor/kartik-v/yii2-mpdf/assets/kv-mpdf-bootstrap.css 그리고해야 필요한 스타일 (예 : #fff! important)은 'cssInline' => '.modal-footer{text-align:left;}div.modal-body{padding:0px;}',

1

그는 pdf 파일의 font-family 변경 방법을 묻습니다. 기본 글꼴 이름은 config_font.php에 있습니다. 이 파일에 사용자 지정 글꼴을 추가 할 수 있습니다.

$this->fontdata = array(... "pompadur" => array('R' => "Pompadur.ttf",), ...) 

붙여 넣기하여 HTML로 : style="font-family: Pompadur"

관련 문제