我正在使用dompdf
生成pdf
,但它正在给一些wiered error
调用未定义的方法Dompdf \ Renderer \ TableCell :: _ border_1px solid black()在TableCell.php(第97行)
我能用简单的html生成pdf
(相同的php code
)
下面是我的代码
<?php
use Dompdf\Dompdf;
$html2 = '<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Todo</title>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">
<script type="text/javascript" src="https://ajax.aspnetcdn.com/ajax/knockout/knockout-3.3.0.js"></script>
<script type="text/javascript" src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<style>
p, strong {
font-weight: 500 !important;
}
body{
overflow-x: hidden;
}
.table-bordered>tbody>tr>td, .table-bordered>tbody>tr>th, .table-bordered>tfoot>tr>td, .table-bordered>tfoot>tr>th, .table-bordered>thead>tr>td, .table-bordered>thead>tr>th{
border-width:3px;
border-style:outset;
}
.table>thead:first-child>tr:first-child>td{
border-width:3px;
border-style:outset;
}
.table>thead:first-child>tr:first-child>th {
border-width:3px;
border-style:outset;
}
.table>thead:first-child>tr:first-child>th {
border-width:3px;
border-style:outset;
}
</style>
</head>
<body style="padding:40px 20px 20px 150px;">
<div id="divModel" style="max-width: 1000px;">
<h1 style="text-align: center;"> Proforma Invoice</h1>
<table class="table table-bordered table-responsive">
<thead>
<tr>
<td style="border-top-style:1px solid black !important;" rowspan="3" ><b>DOLPHIN SYSTEM TECHNOLOGIES</b><p>NO 6 Electronic Plaza,Shop No 322122-Dec-20173rd Floor,3rd Cross,P.R.LaneDelivery NoteMode/Terms of PaymentS.P.Road,BangaloreGSTIN/UIN: 29ABUPU2335F1Z5Suppliers Ref.Other Reference(s)E-Mail : [email protected]</p></td>
<td style="width: 800px; "><p>Invoice No.e-Sugann No.</p><br>221</td>
<td style="width: 500px; text-align: right;"><p>Dated</p><br>22-Dec-2017</td>
</tr>
<tr>
<td style="width: 500px;height: 100px;"><p>Delivery Note.</p></td>
<td style="width: 500px; text-align: right;"><p>Mode/Terms of Payment</p></td>
</tr>
<tr>
<td style="width: 500px; "><p>Suppliers Ref.</p></td>
<td style="width: 500px; text-align: right;"><p>Other Reference(s)</p></td>
</tr>
<tr>
<td rowspan="3" style="border-bottom-style:none !important"><p>Buyer</p><b>Alliance Fitness Consultancy</b><p>No 187,New No 3,T R S Lane, Nagarthpet,</p><p>Bangalore-560002</p><p>State Name: Karnataka, Code : 29</p><p>GSTIN/UIN29AHYPM5388E1ZG</p>
</td>
<td style="width: 500px;height: 100px;"><p>Buyers Order No</p></td>
<td style="width: 500px; text-align: right;"><p>Dated</p></td>
</tr>
<tr>
<td style="width: 500px; "><p>Despatch Document No</p></td>
<td style="width: 500px; text-align: right;"><p>Delivery Note Date</p></td>
</tr>
<tr>
<td style="width: 800px; "><p>Despatched through</p></td>
<td style="width: 500px; text-align: right;"><p>Destination</p></td>
</tr>
<tr>
<td style="width: 500px; text-align: right;border-top-style:none !important"><p></p></td>
<td colspan="2" style="width:500px;border-left-style:none !important;text-align:right;"><p>Terms Of Delivary</p></td>
</tr>
</thead>
</table>
<table class="table table-bordered" style="margin-top: -20px;">
<thead>
<tr>
<th style="width: 5px;">Sl NO</th>
<th>Description of Goods</th>
<th style="width: 10px;">HSN/SAC</th>
<th style="width: 10px; text-align: right;">Quantity</th>
<th style="width: 10px; text-align: right">Rate</th>
<th style="width: 10px; text-align: right;">Per</th>
<th style="width: 10px; text-align: right">Amount</th>
</tr>
<tr>
<th style="width: 5px;">1</th>
<th>Side Board<br><br><br>CGST<br>SGST</th>
<th style="width: 10px;"></th>
<th style="width: 10px; text-align: right;">1 NOS</th>
<th style="width: 10px; text-align: right">4,000.00</th>
<th style="width: 10px; text-align: right;">N0s</th>
<th style="width: 10px; text-align: right">4,000.00<br> <br> 360.00<br>360.00</th>
</tr>
<tr>
<th style="width: 5px;"></th>
<th>Total</th>
<th style="width: 10px;"></th>
<th style="width: 10px; text-align: right;">1 N0S</th>
<th style="width: 10px; text-align: right"></th>
<th style="width: 10px; text-align: right;"></th>
<th style="width: 10px; text-align: right"> 4,720.00</th>
</tr>
<tr>
<th colspan="7"><p>Amount Chargeable (in words)</p><b>INR Four Thousand Seven Hundred Twenty Only</b></th>
</tr>
<tr>
<th style=" border-bottom-style:none !important;">HSN/SAC</th>
<th style="width: 10px;border-bottom-style:none !important">Taxable Value</th>
<th colspan="2" style="width: 10px; text-align: right;">Central Tax</th>
<th colspan="2" style="width: 10px; text-align: right;">State Tax</th>
<th style="width: 10px;border-bottom-style:none !important; text-align: right">Total<br>Tax Amount</th>
</tr>
<tr>
<th style="border-top-style:none !important"></th>
<th style="width: 10px;border-top-style:none !important">Taxable Value</th>
<th style="width: 10px; text-align: right;">Central Tax</th>
<th style="width: 10px; text-align: right">Rate</th>
<th style="width: 10px; text-align: right;">State Tax</th>
<th style="width: 10px; text-align: right">Total<br>Tax Amount</th>
<th style="width: 10px;border-top-style:none !important; text-align: right"></th>
</tr>
<tr>
<th></th>
<th style="width: 10px;">4000.00</th>
<th style="width: 10px; text-align: right;"></th>
<th style="width: 10px; text-align: right">360.00</th>
<th style="width: 10px; text-align: right;"></th>
<th style="width: 10px; text-align: right">360.00</th>
<th style="width: 10px; text-align: right">720.00</th>
</tr>
<tr>
<th>Total</th>
<th style="width: 10px;">4000.00</th>
<th style="width: 10px; text-align: right;"></th>
<th style="width: 10px; text-align: right">360.00</th>
<th style="width: 10px; text-align: right;"></th>
<th style="width: 10px; text-align: right">360.00</th>
<th style="width: 10px; text-align: right">720.00</th>
</tr>
<tr>
<th colspan="7" style=" border-bottom-style:none !important;padding-bottom: 100px;"><p>Tax Amount (in words)</p><b>INR Seven Hundread And Twenty Only</b></th>
</tr>
<tr>
<th colspan="2" style="border-top-style:none !important">
<p>Declaration</p>
<p>We declare that this invoice shows <br> the actual price of thegoods described <br>and that all particulars are true and <br>correct</p></th>
<th colspan="7">
<p>for DOLPHIN SYSTEM TECHNOLOGIES</p>
<p><br>Authorised Signatory</p>
</th>
</tr>
</thead>
</table>
</div>
</body>
</html>';
$dompdf = new Dompdf();
$dompdf->loadHtml($html2);
// (Optional) Setup the paper size and orientation
$dompdf->setPaper('A4', 'landscape');
// Render the HTML as PDF
$dompdf->render();
// Output the generated PDF to Browser
//$dompdf->stream();
//$dompdf->render();
$output = $dompdf->output();
$publicPath = public_path();
$filePath = $publicPath.'/generated_pdf/downlaod.pdf';
file_put_contents($filePath, $output);
?>
问题出在这里:
<td style="border-top-style:1px solid black !important;"
你没有在这里使用正确的CSS语法,这就是为什么Dompdf renderer会给你错误的原因。你应该做这样的事情来使它工作:
<td style="border-top-style: solid"