Bootstrap类未在Laravel 5.2中的barryvdh PDF中加载

时间:2016-10-10 12:27:20

标签: laravel-5.2 dompdf laravel-snappy

我使用barryvdh PDF生成我的发票模板的PDF。

要创建发票模板,我已经在laravel中创建了一个刀片并在其中应用了bootsrap css。

加载该刀片时,加载bootstrap类看起来是正确的。但是当我生成PDF时,它需要我的style.css但Bootstrap类不会加载。

这是我的lump_sum_invoice_template_1.blade.php

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title page-title></title>
    <link href='https://app.dayjibe.com/app/styles/fonts.googleapis.css' rel='stylesheet' type='text/css'>
    <link href="css/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://app.dayjibe.com/app/styles/style.css" rel="stylesheet">
</head>
<body class="bodyopacity" landing-scrollspy id="page-top">
<!-- Main view  -->
<div>
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-lg-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">

                    </div>
                    <div class="ibox-content">
                        <div class="row">
                            <div class="col-lg-8">
                                <div class="form-group" >
                                    <div class="col-sm-2">
                                        <img src="###LOGOPATH###" style="width:100px;height:50px;margin-top:2em;" />
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row" style="margin-top:1em;">
                            <div class="col-sm-4" style="float:right; " >
                                <div class="form-group" style="clear:both;line-height:0;" >
                                    <div class="col-sm-3" style="width:115px;text-align:right;">
                                        <strong>Invoice Date:</strong>
                                    </div>
                                    <div class="col-sm-4 input-group" style="text-align:left;">
                                        ###INVOICEDATE###
                                    </div>
                                </div>
                                <div class="form-group" style="clear:both;">
                                    <div class="col-sm-3" style="width:115px;text-align:right;">
                                        <strong>Project#:</strong>
                                    </div>
                                    <div class="col-sm-4" style="padding-left:0;padding-right:0;text-align:left;">
                                        ###PROJECTNUMBER###
                                    </div>
                                </div>
                                <div class="form-group" style="clear:both;padding-top:0.5em;" >
                                    <div class="col-sm-3" style="width:115px;text-align:right;">
                                        <strong>Invoice#:</strong>
                                    </div>
                                    <div class="col-sm-4" style="padding-left:0;padding-right:0;text-align:left;">
                                        ###INVOICENUMBER###
                                    </div>
                                </div>
                                <div class="form-group" style="clear:both;padding-top:0.5em;" >
                                    <div class="col-sm-3" style="width:115px;text-align:right;">
                                        <strong>Due Date:</strong>
                                    </div>
                                    <div class="col-sm-4 input-group" style="text-align:left;">###DUEDATE###
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row" style="margin-top:1em;">
                            <div class="col-lg-8" >
                                <div class="form-group" >
                                    <div class="col-sm-2">
                                        <label class="control-label">###CLIENT###</label>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row" style="margin-top:1em;">
                            <div class="col-lg-8" >
                                <div class="form-group" >
                                    <div class="col-sm-2">
                                        <label class="control-label">###CLIENTADDRESS###</label>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row" style="margin-top:1em">
                            <div class="col-sm-8 input-group" >
                                <div class="col-sm-8 input-group date" style="float:left;text-decoration:underline;margin-left:2em;">
                                    <strong>Professinal Service from&nbsp;###INVOICEFROMDATE###&nbsp;&nbsp;to&nbsp;&nbsp;###INVOICETODATE###</strong>
                                </div>
                            </div>
                        </div>
                        <div class="row" style="margin-top:2em;">
                            <table class="table table-bordered" style="width:90%;margin-left:2em;" >
                                <thead>
                                <tr>
                                    <th class="col-sm-1" rowspan="2" style="text-align:center;vertical-align:center;">Contract Type</th>
                                    <th class="col-sm-2" rowspan="2" style="text-align:center;vertical-align:center;" >Phase Name</th>
                                    <th class="col-sm-1" rowspan="2" style="text-align:center;">Contract Amount</th>
                                    <th class="col-sm-2" colspan="2" style="text-align:center;" >Previously Invoice</th>
                                    <th class="col-sm-2" colspan="2" style="text-align:center;">Current Period</th>
                                    <th class="col-sm-2" colspan="2" style="text-align:center;">Current Balance</th>
                                </tr>
                                <tr>
                                    <th class="col-sm-1" style="text-align:center;">% OR Unit</th>
                                    <th class="col-sm-1" style="text-align:center;">Amount</th>
                                    <th class="col-sm-1" style="text-align:center;">% OR Unit</th>
                                    <th class="col-sm-1" style="text-align:center;">Amount</th>
                                    <th class="col-sm-1" style="text-align:center;">% Unit</th>
                                    <th class="col-sm-1" style="text-align:center;" >Amount</th>
                                </tr>
                                </thead>
                                <tbody>
                                <tr>
                                    <td colspan="9" style="text-align:center;vertical-align:center;"><strong>###INVOICEDATA###</strong></td>
                                </tr>
                                <tr ng-show="projectInvoice.PhaseData.total_phase_data.length > 0">
                                    <td class="col-sm-1" colspan="2" ><strong>Totals for Phases</strong></td>
                                    <td class="col-sm-1" style="text-align:right;">$###CONTRACT-TOTAL-AMOUNT###</div></td>
                        <td class="col-sm-1" ></td>
                        <td class="col-sm-1" style="text-align:right;">$###CONTRACT-TOTAL-PREVIOUS-AMOUNT###</td>
                        <td class="col-sm-1" ></td>
                        <td class="col-sm-1" style="text-align:right;">$###CONTRACT-TOTAL-CURRENT-PERIOAD-AMOUNT###</td>
                        <td class="col-sm-1" ></td>
                        <td class="col-sm-1" style="text-align:right;">$###CONTRACT-TOTAL-CURRENT-BALANCE-AMOUNT###</td>
                        </tr>
                        <tr>
                            <td colspan="8"><strong>TOTAL AMOUNT DUE THIS INVOICE</strong></td>
                            <td>###INVOICETOTALDUE###</td>
                        </tr>
                        </tbody>
                        </table>
                    </div>
                    <div class="row" style="margin-top:2em;">

                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</div>

</body>
</html>

这是我的laravel代码

return PDF::loadView('InvoiceTemplates/lump_sum_invoice_template_1')->save(public_path().'/lump_sum_invoice_template_1.pdf')->stream('download.pdf');

1 个答案:

答案 0 :(得分:0)

Dompdf(包括0.7.0)并不足以支持Bootstrap使用的CSS。

即将推出的0.7.1版本应解决其中许多不足之处。

支持更新发布到Dompdf问题跟踪器#631