网页中调用word实现的打印

    技术2022-05-11  172

    网页中调用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


    最新回复(0)