0

I have a Crystal Report that I'm trying to export as a stream as a PDF. I'm able to view it in the Crystal Report Viewer in the browser, but when I open the PDF in a new tab in Chrome, I get an error stating it failed to load the PDF. Whenever I run it on my server, I get the error, but I do not get the error running locally. Do you know what could cause this?

        Dim expStream As Stream = CurReport.ExportToStream(expFormatType)
        expStream.Seek(0, SeekOrigin.Begin)
        Dim abyBuffer As Byte() = New Byte(expStream.Length - 1) {}
        expStream.Read(abyBuffer, 0, expStream.Length)
        expStream.Dispose()
        expStream = Nothing

        Response.Buffer = True
        Response.Clear()
        Response.ContentType = "application/pdf"
        Response.AddHeader("content-disposition", "inline; filename=" & rptFile)
        Response.AddHeader("content-length", abyBuffer.Length.ToString())
        Response.OutputStream.Write(abyBuffer, 0, abyBuffer.Length) ' Send to client
        Response.Flush() ' Finalize

        HttpContext.Current.ApplicationInstance.CompleteRequest()
1
  • Compare the responses between dev & live via your browser dev tools. Have the browser save it to a file instead of opening it, then open it with a text editor, and check for anything that shouldn't be in there, like error messages. Commented Sep 23 at 13:21

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.