用WebBrowser 打印设置网页时,它的字体不太合适,并且还会自动加上网址页眉之类的东西。
怎么设置字体大小?
和不打印页眉、页脚和网址?
网上看了几个文章,都不行

解决方案 »

  1.   

    把你打印的页面源代码贴出来分析一下,42025833 欢迎加入java交流群
      

  2.   

    How to print custom headers and footers for a WebBrowser control in Internet Explorer
    http://support.microsoft.com/kb/267240
      

  3.   

    <html>
    <head><title>打印</title></head>
    <script>
    function fn01()
    {
     try
     {
     var Wsh=new ActiveXObject("WScript.Shell");
     HKEY_Key="header";
     Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,"");
     HKEY_Key="footer";
     Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,"");
     }
     catch(e){}
     document.getElementById("div1").style.display="none";
     document.all.WebBrowser.ExecWB(7,1);
     document.getElementById("div1").style.display="block";
    }
    function fn02()
    {
     try
     {
     var Wsh=new ActiveXObject("WScript.Shell");
     HKEY_Key="header";
     Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,"");
     HKEY_Key="footer";
     Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,"");
     }
     catch(e){}
     document.getElementById("div1").style.display="none";
     document.all.WebBrowser.ExecWB(6,1);
     document.getElementById("div1").style.display="block"; 
    }
    </script>
    <body>
    <OBJECT   id=WebBrowser   classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2   height=0   width=0></OBJECT> 
    <div id="sp1">这里填写打印内容<br>
      <br>
      <br>
      <br>
      <br>
      <br>
      <br>
      <br>
      <br>
      <br>
      <br>
      <br>
      <br>
      <br>
      <br>
      <br>
      <br>这里填写打印内容
    </div> 
    <div id="div1"> 
      <input   type=button   value=打印           onclick=fn02()>     
      <input   type=button   value=页面设置   onclick=document.all.WebBrowser.ExecWB(8,1)>                       
      <input   type=button   value=打印预览   onclick=fn01()> 
    </div>
    </body>
    </html>
      

  4.   

    去除页眉页脚还有一个办法:<object   id="factory"   style="display:none"   viewastext   classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814"   codebase="http://www.meadroid.com/scriptx/ScriptX.cab#Version=5,60,0,360"></object>   
      <script   defer>   
      function   window.onload()   {   
          factory.printing.header   =   ""   
          factory.printing.footer   =   ""   
          factory.printing.leftMargin   =   0.75   
          factory.printing.topMargin   =   1.5   
          factory.printing.rightMargin   =   0.75   
          factory.printing.bottomMargin   =   1.5   
          }   
      </script>   
        
      <p><input     type="button"   value="打印本页"   
        onclick="factory.printing.Print(false)">   
        <input     type="button"   value="页面设置"   
        onclick="factory.printing.PageSetup()">