动态jsp页面转PDF输出到页面
最近工作中遇到不少问题。总结一下。这段代码主要功能是将一个生成JSP页面转发成PDF输出到页面 需要利用ITEXT String html = ServletUtils. forward(request,response, "/WEB-INF/jsp/depot/print/jhd.jsp"); //转发请求到jsp,返回解析之后的内容而不是输出到浏览器 //System.out.println(html); byte[] pdf = PDFUtils. html2pdf(html); response.setContentType( "application/pdf"); response.setHeader( "Content-Length",String. valueOf(pdf. length)); response.setHeader( "Connection", "keep-alive"); response.setHeader( "Accept-Ranges", "none"); response.setHeader( "X-Frame-Options", "DENY"); OutputStream out = response.getOutputStream(); out.write(pdf); out.flush(); public class