2015-11-14 54 views
0

工作這是我的控制器代碼引導內部沒有PDF

public function actionPrint_death_certificate1() 
    { 

     $this->layout = 'certificate'; 


     $html = $this->render('test'); 
     require_once(Yii::$app->basePath . "/../vendor/mpdf/mpdf/mpdf.php"); 
     $mpdf=new mPDF(); 
     $mpdf->WriteHTML($html); 
     $mpdf->Output(); 

    } 

我的觀點

<div class="container"> 
    <div class="row"> 
     <div class="col-md-6"> 
     Heading1 
     </div> 
     <div class="col-md-6"> 
     Heading2 
     </div> 
    </div> 
</div> 

現在我得到在兩個不同的行標題1和heading2的PDF文件。引導不起作用。我錯過了什麼嗎?

return $this->render('test'); 

當我試過這一個它是工作和heading1和heading2是在一行。在PDF它不工作

+1

MPDF有限的CSS支持,並且極有可能引導的電網將在那裏工作。這樣做的老式方法與表:'

​​標題1​​Heading2
'。 – Beowulfenator

+1

很遺憾聽到 – Bloodhound

回答

0

我張貼在github上和MPDF人的問題告訴bootstrap不支持開箱即用的內部mpdf,你必須使用一些自定義樣式。 Github link

0

您可以使用函數$mpdf->WriteHtml($stylesheet, 1)到PDF中添加自定義樣式表,以獲取更多信息,您可以檢查此鏈接http://mpdf1.com/manual/index.php?tid=254

public function actionPrint_death_certificate1() 
{ 
    $this->layout = 'certificate'; 
    $html = $this->render('test'); 
    $stylesheet = file_get_contents('style.css'); 
    require_once(Yii::$app->basePath . "/../vendor/mpdf/mpdf/mpdf.php"); 
    $mpdf = new mPDF(); 
    $mpdf->WriteHTML($stylesheet, 1); 
    $mpdf->WriteHTML($html); 
    $mpdf->Output(); 
} 
+0

您好,感謝您的回覆。請檢查這個鏈接https://github.com/mpdf/mpdf/issues/66 – Bloodhound

0

從@Bloodhound後 - 該解決方案對我的作品以及

.col-xs-1, .col-sm-1, .col-md-1, .col-lg-1, .col-xs-2, .col-sm-2, .col-md-2, .col-lg-2, .col-xs-3, .col-sm-3, .col-md-3, .col-lg-3, .col-xs-4, .col-sm-4, .col-md-4, .col-lg-4, .col-xs-5, .col-sm-5, .col-md-5, .col-lg-5, .col-xs-6, .col-sm-6, .col-md-6, .col-lg-6, .col-xs-7, .col-sm-7, .col-md-7, .col-lg-7, .col-xs-8, .col-sm-8, .col-md-8, .col-lg-8, .col-xs-9, .col-sm-9, .col-md-9, .col-lg-9, .col-xs-10, .col-sm-10, .col-md-10, .col-lg-10, .col-xs-11, .col-sm-11, .col-md-11, .col-lg-11, .col-xs-12, .col-sm-12, .col-md-12, .col-lg-12 { 
    border:0; 
    padding:0; 
}