' Tell the browser this is a PDF document so it will use an appropriate viewer. ' If the report has been exported in a different format, the content-type will
' need to be changed as noted in the following table:
' ExportType ContentType
' PDF "application/pdf" (needs to be in lowercase)
' RTF "application/rtf"
' TIFF "image/tiff" (will open in separate viewer instead of browser)
' HTML "message/rfc822" (only applies to compressed HTML pages that includes images)
' Excel "application/vnd.ms-excel"
' Excel "application/excel" (either of these types should work.
' Text "text/plain"
Response.Clear()
Response.ClearHeaders()
Response.ClearContent()
Response.ContentType = "application/pdf"
' IE & Acrobat seam to require "content-disposition" header being in the response. If you don't add it, the doc still works most of the time, but not always.
'this makes a new window appear: Response.AddHeader("content-disposition","attachment; filename=MyPDF.PDF");
Response.AddHeader( "content-disposition", "inline; filename=MyPDF.PDF" )
' Create the PDF export object
Dim pdf As New PdfExport
' Create a new memory stream that will hold the pdf output
Dim memStream As New System.IO.MemoryStream()
' Export the report to PDF:
pdf.Export(rpt.Document, memStream)
pdf.Export(rpt.Document, "C:\Test\file.pdf" )
' Write the PDF stream out
Response.BinaryWrite(memStream.ToArray())
' Send all buffered content to the client
Response.End()
The export to file works fine. Thanks, Cory Jorgensen Bitco Software
Private Sub Page_Load(ByVal sender As Object , ByVal e As System. EventArgs ) Handles _
MyBase.Load
Dim m_stream As New System.IO.MemoryStream()
Dim rpt As New rptCustEx()
rpt.Run()
Me.PdfExport1.Export(rpt.Document, m_stream)
m_stream.Position = 0
Response.AddHeader( "content-disposition" , "inline; filename=MyExport.pdf" )
Response.BinaryWrite(m_stream.ToArray())
End Sub