cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

PDF file download issue in google chrome and edge

rohan1607
Explorer
0 Kudos
1,140

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

Accepted Solutions (0)

Answers (0)