我正在使用dompdf來生成字母,我想用各種不同的公司品牌紙品牌。爲此,我通過css獲取背景圖片。在底部看到示例圖像。然後,我設置適當的邊距以適合我要寫入白色空間的內容。不過,我只想讓這個信頭只顯示在第一頁上。目前它正在每頁上重複。我的CSS是這樣的:Dompdf:如何獲取背景圖片只顯示在第一頁
<html>
<head>
<meta charset="utf-8">
<title>{$pdf.title}</title>
<style type="text/css">
@page {
size: A4;
margin:0;
padding: 0;
}
body {
padding: {$branding.page_margin_top}cm {$branding.page_margin_right}cm {$branding.page_margin_bottom}cm {$branding.page_margin_left}cm;
font-size: 7pt;
font-family: helvetica !important;
background-image: url('{$base_url}pd-direct.png');
background-position: center center;
background-repeat: no-repeat;
font-size: 10pt;
}
#postal-address {
margin: 0cm;
margin-left: {$branding.address_offset_left}cm;
margin-top: {$branding.address_offset_top}cm;
margin-bottom: {$branding.address_offset_bottom}cm;
font-size: 10pt;
}
#date {
font-weight: bold;
}
</style>
</head>
<body>
<div id="page-body">
<div id="content">
{if $pdf.postal_address}
<div id="postal-address">
{$pdf.postal_address|nl2br}
</div>
{/if}
{$pdf.main_body}
</div>
</div>
</body>
</html>
我怎樣才能改變此背景圖像僅在由DOMPDF第一輸出頁顯示?
見當前HTML的渲染:http://eclecticgeek.com/dompdf/debug.php?identifier=ccfb2785f8a8ba3e1e459cbd283ad015
你試過'@頁:first'?據我記得,它適用於wkhtmltopdf - 我不確定它是否適用於dompdf。 – eithed
background-image在使用dompdf的@page上看起來不起作用。 –
在發佈我的答案建議'@page:first'之前沒有看到這些評論!您能否提供一些PHP代碼,以便人們可以更輕鬆地進行剪切/粘貼測試? – miken32