用PB的datawindow打印吧,我就是用的这个。只需要将PB的psdwc70.dll文件用regserv32进行注册一下就可以用,剩下的就是做datawindow了。源码如下:
<%@ page contentType="text/html; charset=GBK" %>
<%@ page import="chenzw.jdbcdriver.ViewQueryBean,chenzw.CommDictionary"%>
<%
  String birthnumber = CommDictionary.ifNull(request.getParameter("id"));
%>
<SCRIPT language="javascript">
function f_set()
{
  cszmPrinter.reset();
  cszmPrinter.InsertRow(0);
  cszmPrinter.setItem(1,"id","<%=birthnumber%>");
  cszmPrinter.print(true);
}
</SCRIPT>
<HTML>
<HEAD>
<TITLE>作废出生证明打印</TITLE>
</HEAD>
<BODY onload="f_set()" topMargin=0 leftMargin=0>
<OBJECT style='visibility: hidden' height="10" width="10" codeBase="../activex/psdwc70.dll" id=cszmPrinter name=cszmPrinter classid="CLSID:77771503-7777-1000-8000-080009AC61A9" >
<!--OBJECT height="100%" width="100%" codeBase="../activex/psdwc70.dll" id=cszmPrinter name=cszmPrinter classid="CLSID:77771503-7777-1000-8000-080009AC61A9" -->
    <PARAM VALUE=65536 NAME="_Version"></PARAM>
    <PARAM VALUE=20241 NAME="_ExtentX"></PARAM>
    <PARAM VALUE=3836 NAME="_ExtentY"></PARAM>
    <PARAM VALUE=2 NAME="_StockProps"></PARAM>
    <PARAM VALUE="" NAME=Caption></PARAM>
    <PARAM VALUE="d_blankout.pbd" NAME=SourceFileName></PARAM>
    <PARAM VALUE="d_blankout" NAME=DataWindowObject></PARAM>
    <PARAM VALUE="" NAME=LogId></PARAM>
    <PARAM VALUE="" NAME=LogPass></PARAM>
    <PARAM VALUE="" NAME=dbParm></PARAM>
    <PARAM VALUE=1 NAME=SuppressEvents></PARAM>
    <PARAM VALUE=1 NAME=VScrollBar></PARAM>
    <PARAM VALUE=1 NAME=HScrollBar></PARAM>
    <PARAM VALUE=1 NAME=HSplitScroll></PARAM>
    <PARAM VALUE=1 NAME=LiveScroll></PARAM>
</OBJECT>
</BODY>
</HTML>

解决方案 »

  1.   

    regsvr32文件在system目录下。
    希望你会用PB做简单的数据窗口!祝你好运
      

  2.   

    PrinterJob pj=PrinterJob.getPrinterJob();
          PageFormat pf=new PageFormat();
          Paper paper=new Paper();
          paper.setSize(int,int);
          pf.setPaper(paper);
          pj.setPrintable(this,pf);//实现Printable接口
          pj.print();