网页中调用word实现的打印

来源:互联网 发布:python编程实践 数据 编辑:程序博客网 时间:2024/05/01 03:54

网页中调用word实现打印功能时,可以用word另存为指定xml或网页形式,然后再通过java的response输出流写。主要是contenttype和header如何写。

1。word另存为htm(比如为C:/test.htm)

response.setContentType("application/msword; charset=GB2312");
response.setHeader("Content-Disposition", "filename=test.htm".getBytes(), "ISO8859-1"));
response.getWriter().write(XXX);  //写对应InputStream

2。word另存为xml(比如为C:/test.htm)

response.setContentType("application/msword; charset=UTF-8");
response.setHeader("Content-Disposition", "filename=test.htm".getBytes(), "ISO8859-1"));
response.getWriter().write(XXX);  //写对应InputStream