10 Replies Latest reply on Feb 7, 2018 2:48 AM by try67

    PDF version 1.5 and higher (from Scanner) not able to view/download in browser

    DreamzLai91 Level 1

      I'm developing a vb.net web application. Recently I face a problem where the PDF file with version 1.5 and higher are not able to view/download through browser. When I click the link to view the PDF file, the browser will prompt a "File Download" message box, when I choose to open the PDF file, the adobe reader display this error "There was an error opening this document. The file is damaged and could not be repaired." Even if I choose "Save" to PC then open the PDF file, it still display the same error message.

       

      Please note that the sources for those PDF file is from scanner. If I'm using the Microsoft Word to save the document as PDF, it has no issue in viewing the PDF file no matter in what PDF version.

       

      The code I'm using for view attachment is as below:

      HTTPContext.Current.Response.ContentType = "APPLICATION/PDF"

      HTTPContext.Current.Response.AppendHeader("Content-Disposition", "Attachment; Filename=XXX.pdf")

      HttpContext.Current.Response.Flush()

      HttpContext.Current.Response.WriteFile(System.IO.FileInfo(FILE_PATH).FullName)

      HttpContext.Current.ApplicationInstance.CompleteRequest()

       

      Is there any issue with the code? Any solution to resolve this issue?