2016-08-23 81 views
0

我被困在一個地方。我有一個HTML頁面,但我只想在打印頁面上打印一個DIV,並將其另存爲PDF格式,並保存按鈕。在A4頁面上打印並保存爲PDF

<div class="abc"> 
    Here are some words 
    <div class="def"> 
     Some more words 
     <div class="ghi"> 
      This is I want for print on A4 page and save as PDF but like my letterhead with logo and other detail like microsoft word have header and footer. I want to header and footer add in header.php and footer.php but only on print and save as PDF. And this div class in the middle of letter. 
      <button>Click for print</button> 
      <button>Click to save as PDF</button> 
     </div> 
    </div> 
</div> 

我想打印版本,信頭
非常感謝提前。

回答

0

你需要一個單獨的工具來從HTML創建PDF,它需要在服務器端。 PHP的可能的解決方案在Convert HTML + CSS to PDF with PHP?

如果你真的不需要 PDF,但只有一個打印版本進行了討論,我會建議使用CSS媒體查詢打印。你可以很容易地隱藏所有不需要的部分,並使用瀏覽器打印按鈕:

@media print { 
    button { display: none; } 
} 
+0

感謝您的回覆,但我不知道@media print。 我可以有一些編碼嗎? – djmhim

+0

已經*是編碼。這是CSS。您可以使用帶有此內容的'