0

我在浏览器中打开 pdf 文件时遇到性能问题。打开时间非常长。我们的 pdf 文件是扫描图像。那么是否有任何替代解决方案。这是我的示例代码。

response.setContentType("application/pdf");
response.setContentLength((int) file.length());
FileInputStream in = new FileInputStream(file);
OutputStream out = response.getOutputStream();
// Copy the contents of the file to the output stream
byte[] buf = new byte[1024];
int count = 0;
while ((count = in.read(buf)) >= 0) {
out.write(buf, 0, count);
}
in.close();
out.close();

在这里,我正在将外流渲染到浏览器。

4

0 回答 0