Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Sending PDF to Browser
Message
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Titre:
Sending PDF to Browser
Divers
Thread ID:
01017212
Message ID:
01017212
Vues:
58
I have an asp.net application that has a feature to allow a user to see a pdf. The system does not know whether or not the pdf exists - so it does a file.exists() then calls the function to send the pdf to the browser.

On my test server here, it works fine. I have put it on a production webserver, and I get a corrupted pdf. Here's the code that does it;
        Private Sub fi_exportfiletopdf(ByVal pcFile As String, ByVal pckey As String)
            ' this method will redirect the user to a pdf
            ' the system will prompt them to open the file or save it
            ' the pdf is opened in a separate window
            Response.Clear()
            Response.Buffer = True
            Response.ContentType = "application/pdf"
            Response.AddHeader("content-disposition", "attachment;filename=" + pckey + ".pdf")

            Response.Charset = ""
            Me.EnableViewState = False
            Dim oFileStream As FileStream
            Dim FileSize As Long

            oFileStream = New FileStream(pcFile, FileMode.Open)
            FileSize = oFileStream.Length

            Dim Buffer(CInt(FileSize)) As Byte
            oFileStream.Read(Buffer, 0, CInt(FileSize))
            oFileStream.Close()

            Response.OutputStream.Write(Buffer, 0, FileSize)
            Response.Flush()
            Response.Close()



        End Sub
I can actually browse to the file directly, and it works fine - somehow in the code, the pdf is being corrupted on this box. Any ideas?
Wayne Myers, MCSD
Senior Consultant
Forte' Incorporated
"The only things you can take to heaven are those which you give away" Author Unknown
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform