2016-08-23 128 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。您可以使用带有此内容的'