我正在使用Spring MVC框架。和PDFJS.version ='1.1.215'。 想以PDF.JS显示PDF内容。 PDF内容位于服务器端,所以我认为不能在jsp上使用PDF的URL ...
控制器来源
@RequestMapping("/viewer.do")
public BufferedOutputStream viewer(... svo
, HttpServletRequest request
, HttpServletResponse response
, ModelMap model) throw Exception{
FileInputStream fis = null;
BufferedOutputStream bos = null;
try{
File pdfFile = new File("C:\\test.pdf");
response.setContentType("application/pdf");
fis = new FileInputStream(pdfFile);
int size = fis.available();
byte[] buf = new byte[size];
int readCount = fis.read(buf);
response.flushBuffer();
bos = new BufferedOutputStream(response.getOutputStream());
bos.write(buf, 0, readCount);
bos.flush();
} catch (Exception e){}
return bos;
}
想在pdf.js中显示此pdf流请帮帮我。