on 2021 Nov 18 7:20 AM
We are facing this odd issue with PDF files in our storefront, when the file is saved/download from the browser it results in an error and the file is not saved. The error is "Failed - Network error" and only happens in Google Chrome and Microsoft Edge. The file downloads fine from Internet Explorer and Firefox.
We have also tried loading a PDF file from local file system but when it is displayed from the application, the save/download fails with the same issue.
Here is the code that retrieves a PDF from local file system -
private void printPDF(final HttpServletResponse response) throws IOException {
File f = new File("C:\\file\\file.pdf");
InputStream is = new FileInputStream(f);
byte[] pdfData = is.readAllBytes();
is.close();
response.setContentType("application/pdf");
response.setHeader("Content-disposition", "inline; filename=file.pdf");
response.setContentLength(pdfData.length);
response.addHeader("Transfer-Encoding", "identity");
response.setHeader("Pragma", "must-revalidate");
response.setHeader("Cache-Control", "no-cache, must-revalidate, post-check=0, pre-check=0");
response.getOutputStream().write(pdfData);
response.getOutputStream().close();
}
Has anyone faced this issue with Google Chrome and Microsoft Edge ?
Hybris version 2005
Request clarification before answering.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.