能不能给个例子呀?我用的是web打印,在页面上用js脚本就可以实现吧?谁有例子谢谢了!!

解决方案 »

  1.   

    小弟我现在也要用JAVA写一个打印的程序,不过我打印的东西很小,只要一个存折大小。可不可以教教我怎么打印。把你的例子给我看看。谢了。email:[email protected]
      

  2.   

    ebrightzhang:
    你的问题很简单!
    <html>
    <head>
    <META HTTP-EQUIV="pragma" CONTENT="no-cache">
    <META HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate">
    <META HTTP-EQUIV="expires" CONTENT="Mon, 23 Jan 1978 20:52:30 GMT">
    <meta http-equiv="Content-Type" content="text/html; charset=GBK">
    <title>无标题文档</title>
    <STYLE media=print>.Noprint {
    DISPLAY: none
    }
    .PageNext {
    PAGE-BREAK-AFTER: always
    }
    </STYLE>
    <style type="text/css">
    <!--.style2 {
    font-size: 18px;
    font-weight: bold;
    }
    body,td,th {
    font-size: 12px;
    }
    .style5 {
    font-family: "仿宋_GB2312";
    font-size: 14px;
    }
    .style6 {
    font-family: "黑体";
    font-weight: bold;
    }
    .style7 {
    font-size: 18px;
    font-style: italic;
    font-weight: bold;
    }
    .style8 {
    font-size: 14px;
    font-weight: bold;
    }
    .noUPAndBottomAndLeftBorder {
    border-top-width: 0px;
    border-bottom-width: 0px;
    border-left-width: 0px;
    }
    .noUPAndBottomBorder {
    border-top-width: 0px;
    border-bottom-width: 0px;
    }
    .style10 {
    font-size: 16px;
    font-weight: bold;
    }
    -->
    </style>
    </head><body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" style="border:0px">
    <center class=Noprint> 
    <table width="650" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td>
      <OBJECT id=WebBrowser height=0 width=0 
    classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2>
        <embed width="0" height="0"></embed></OBJECT>
        <INPUT name="button"  type=button onclick=document.all.WebBrowser.ExecWB(6,1) value=打印>
        <INPUT name="button2" type=button onclick=document.all.WebBrowser.ExecWB(6,6) value=直接打印>
        <INPUT name="button2" type=button onclick=document.all.WebBrowser.ExecWB(8,1) value=页面设置>
        <INPUT name="button2" type=button onclick=document.all.WebBrowser.ExecWB(7,1) value=打印预览>
    </td>
      </tr>
       要打印的内容
    </table>
    </body>
    </html>
    以上就是我使用打印的代码?谁能帮我实现分页呀?谢谢了?
      

  3.   

    <html>
    <head>
    <meta name=vs_targetSchema content='http://schemas.microsoft.com/intellisense/ie6'>
    <title>看看</title>
    <meta http-equiv='Content-Type' content='text/html; charset=gb2312'>
    <!--media=print 这个属性可以在打印时有效-->
    <style media=print>
    .Noprint{display:none;}
    .PageNext{page-break-after: always;}
    </style><style>
    .tdp
    {
        border-bottom: 1 solid #000000;
        border-left:  1 solid #000000;
        border-right:  0 solid #ffffff;
        border-top: 0 solid #ffffff;
    }
    .tabp
    {
        border-color: #000000 #000000 #000000 #000000;
        border-style: solid;
        border-top-width: 2px;
        border-right-width: 2px;
        border-bottom-width: 1px;
        border-left-width: 1px;
    }
    .NOPRINT {
     font-family: '宋体';
     font-size: 9pt;
    }</style></head><body >
    <center class='Noprint' >
      <p>
      <OBJECT  id=WebBrowser  classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2  height=0  width=0>
      </OBJECT>
      <input  type=button  value=打印          onclick=document.all.WebBrowser.ExecWB(6,1)>
      <input  type=button  value=直接打印  onclick=document.all.WebBrowser.ExecWB(6,6)>
      <input  type=button  value=页面设置  onclick=document.all.WebBrowser.ExecWB(8,1)>
    </p>
      <p>   
      <input  type=button  value=打印预览  onclick=document.all.WebBrowser.ExecWB(7,1)>
        <br/>
        </p>
      <hr align='center' width='90%' size='1' noshade>
    </center><table width='90%' border='0' align='center' cellpadding='2' cellspacing='0'  class='tabp'>
     <tr>
      <td colspan='3' class='tdp'>第1页</td>
        </tr>
     <tr>
       <td width='29%' class='tdp'>&nbsp;</td>
       <td width='28%' class='tdp'>&nbsp;</td>
          <td width='43%' class='tdp'>&nbsp;</td>
      </tr>
     <tr>
       <td colspan='3' class='tdp'>&nbsp;</td>
      </tr>
     <tr>
       <td colspan='3' class='tdp'><table width='100%'  border='0' cellspacing='0' cellpadding='0'>
            <tr>
              <td width='50%' class='tdp'><p>这样的报表</p>
              <p>对一般的要求就够了。</p></td>
              <td>&nbsp;</td>
            </tr>
          </table></td>
      </tr>
    </table>
    <hr align='center' width='90%' size='1' noshade class='NOPRINT' >
    <!--分页-->
    <div class='PageNext'></div>
    <table width='90%' border='0' align='center' cellpadding='2' cellspacing='0'  class='tabp'>
      <tr>
        <td class='tdp'>第2页</td>
      </tr>
      <tr>
        <td class='tdp'>看到分页了吧</td>
      </tr>
      <tr>
        <td class='tdp'>&nbsp;</td>
      </tr>
      <tr>
        <td class='tdp'>&nbsp;</td>
      </tr>
      <tr>
        <td class='tdp'><table width='100%'  border='0' cellspacing='0' cellpadding='0'>
            <tr>
              <td width='50%' class='tdp'><p>这样的报表</p>
                  <p>对一般的要求就够了。</p></td>
              <td>&nbsp;</td>
            </tr>
        </table></td>
      </tr>
    </table>
    </body>
    </html>
      

  4.   

    用Hibernate实现分页不是很简单,传两个参数进去就行了!
      

  5.   

    ufo5054492(郑洪勇学Java)大哥:hibernate如何实现打印分页,请指教?谢谢!!