5


私はphpからhtml genに大きなページを持っていて、
htmlとcssで印刷ビューを作成したいので、
print.cssスタイルを使ってこのページを作成し、
いくつか質問があります:

  1. A4サイズのページの作り方
  2. すべてのページとページごとに境界線を作成する方法
  3. 任意のブラウザで固定サイズビューを作成する方法
  4. これを生成するためのphpクラスがありますか?

あなたの答えをありがとう:)

4

2 に答える 2

0

これはあなたを助けるかもしれません

<div id="printpage">  
 //blah blah
</div>  

<a href="#" onclick="printdiv()">Print</a>

function printdiv()
{
    //your print div data
    //alert(document.getElementById("printpage").innerHTML);
    var newstr=document.getElementById("printpage").innerHTML;

    var header='<header><div align="center"><h3 style="color:#EB5005"> Your HEader </h3></div><br></header><hr><br>'

    var footer ="Your Footer";

    //You can set height width over here
    var popupWin = window.open('', '_blank', 'width=1100,height=600');
    popupWin.document.open();
    popupWin.document.write('<html> <body onload="window.print()">'+ newstr + '</html>' + footer);
    popupWin.document.close(); 
    return false;
}
于 2013-09-12T08:00:07.557 に答える