2012-11-08 41 views
1

我想創建一個使用dompdf的pdf報告。該報告需要在第一頁的頂部有公司徽標以及每頁上的頁眉和頁腳。我已經找到解決方案,爲dompdf文件添加頁眉和頁腳elsewhereonstackoverflow。我遇到的問題是,該公司的標識必須是頁頭上面的第一頁上,在其他頁面dompdf與報告標題,然後頁眉和頁腳

像這樣

Company Logo 
- header 
- content here 
- footer 
------ 
- header 
- content here 
- footer 

不顯示是否有這樣做的任何方式使用dompdf?

+0

舊的問題,但...標題可以保持在同一位置嗎?或者它預計在第一頁上它會因標識而被推下來? – BrianS

回答

5

這是kludgey,但它的工作原理。通過使用固定定位和使用絕對定位的特殊頁面1標題創建標準標題,基本上可以僞造不同的標題。如果您按照正確的順序進行設置,則頁面1標題將顯示在標準標題的頂部,並將其隱藏起來。

<html> 
    <head> 
    <style> 
     @page { 
     margin: 0px; 
     } 
     @page :first { 
     margin-top: 100px; 
     } 
     body { 
     margin: 100px 20px 50px 20px; 
     } 
     #headerA { 
     position: fixed; 
     left: 0px; right: 0px; top: 0px; 
     text-align: center; 
     background-color: orange; 
     height: 90px; 
     } 
     #headerB { 
     position: absolute; 
     left: -20px; right: -20px; top: -200px; 
     text-align: center; 
     background-color: orange; 
     height: 190px; 
     } 
     #footer { 
     position: fixed; 
     left: 0px; right: 0px; bottom: 0px; 
     text-align: center; 
     background-color: orange; 
     height: 40px; 
     } 
    </style> 
    </head> 
    <body> 
    <div id="headerA"> 
     <h1>Widgets Express</h1> 
    </div> 
    <div id="headerB"> 
     <img class="logo" src="http://eclecticgeek.com/images/macro/ants.jpg" height="100" width="500"> 
     <h1>Widgets Express</h1> 
    </div> 

    <div id="footer"> 
     <p>Copyright, all rights reserved, yadda yadda</p> 
    </div> 

    <div id="content"> 
     ... 
    </div> 
    </body> 
</html>