我怎样才能得到这个:
File file = new File(doneDir + "\\" + batchName + "\\" + fileName);
byte[] by = new byte[(int) file.length()];
FileInputStream fis = new FileInputStream(file);
fis.read(by);
fis.close();
response.setContentType("application/pdf");
response.setHeader("Content-disposition", "attachment; filename=TheDocument." + "pdf");
response.getOutputStream().write(by);
response.getOutputStream().flush();
response.getOutputStream().close();
从我的 servlet doGet 或 doPost 到 pdf.js 函数:
var data = (byte array returned from servlet)
PDFJS.getDocument(data).then(function(pdf) {});
基于example https://mozilla.github.io/pdf.js/examples/,我会说,而不是
var data = (byte array returned from servlet)
PDFJS.getDocument(data).then(function(pdf) {});
我认为你应该使用:
PDFJS.getDocument(servlet_url).then(function(pdf) {
// you can now use *pdf* here
});
返回 PDF 文件的 servlet 对于客户端来说应该与服务器上的 PDF 文件没有什么不同,该示例使用PDFJS.getDocument('helloworld.pdf').then(...
所以这个函数显然需要一个 URL。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)