Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. pdf reports on asp.net web application

pdf reports on asp.net web application

Scheduled Pinned Locked Moved ASP.NET
databasecsharpasp-nethelp
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    bemahesh
    wrote on last edited by
    #1

    Hi, i have a asp.net web appplication. One of the pages includes report downloader. User is given a drop down menu to select different reports to download. Once they select a report and hit download button, downloader dialog box appears and let's user save report in PDF format. Report would be basically anything that SQL Stored procedure may return. Basically, i have the structure in place already. I found out on the web that I can use Crystal Report and tie that to the web form in order to generate PDF document as a report. If something other than pdf is generated (i.e. excel file), i can do something like this 'sb.Append(vbCrLf) 'Response.Clear() '' Response.ContentType = "Application/x-msexcel" 'Response.ContentType = "Application/x-msword" ''Response.OutputStream.Write(sb, 0, sb.Length) 'Response.AppendHeader("content-disposition", "attachment; filename=""" & filename & """") ''Write the file directly to the HTTP output stream. 'Response.AppendHeader("content-length", sb.Length) 'Response.Write(sb.ToString) 'Response.End() 'Response.Clear() where SB.append is string builder being tied to generate the report data. however, if i want pdf reports i can not just say "application/pdf". so, i ended up doing this Dim crReport As New ReportFile crReport.SetDataSource(dstMain) Dim strStream As New System.IO.BinaryReader(crReport.ExportToStream(CrystalDecisions.[Shared].ExportFormatType.PortableDocFormat)) Response.ClearContent() Response.ClearHeaders() Response.ContentType = "application/pdf" Response.BinaryWrite(strStream.ReadBytes(strStream.BaseStream.Length)) Response.Flush() Response.Close() where reportfile is a crystal report page that i added to my asp.net web application. My web application is generating pdf document. However, it is coming up blank without any data. "Dstmain" is the dataset that i am filling before this code gets executed from stored procedure Any help would be appreciated. Thanks Needy

    B 1 Reply Last reply
    0
    • B bemahesh

      Hi, i have a asp.net web appplication. One of the pages includes report downloader. User is given a drop down menu to select different reports to download. Once they select a report and hit download button, downloader dialog box appears and let's user save report in PDF format. Report would be basically anything that SQL Stored procedure may return. Basically, i have the structure in place already. I found out on the web that I can use Crystal Report and tie that to the web form in order to generate PDF document as a report. If something other than pdf is generated (i.e. excel file), i can do something like this 'sb.Append(vbCrLf) 'Response.Clear() '' Response.ContentType = "Application/x-msexcel" 'Response.ContentType = "Application/x-msword" ''Response.OutputStream.Write(sb, 0, sb.Length) 'Response.AppendHeader("content-disposition", "attachment; filename=""" & filename & """") ''Write the file directly to the HTTP output stream. 'Response.AppendHeader("content-length", sb.Length) 'Response.Write(sb.ToString) 'Response.End() 'Response.Clear() where SB.append is string builder being tied to generate the report data. however, if i want pdf reports i can not just say "application/pdf". so, i ended up doing this Dim crReport As New ReportFile crReport.SetDataSource(dstMain) Dim strStream As New System.IO.BinaryReader(crReport.ExportToStream(CrystalDecisions.[Shared].ExportFormatType.PortableDocFormat)) Response.ClearContent() Response.ClearHeaders() Response.ContentType = "application/pdf" Response.BinaryWrite(strStream.ReadBytes(strStream.BaseStream.Length)) Response.Flush() Response.Close() where reportfile is a crystal report page that i added to my asp.net web application. My web application is generating pdf document. However, it is coming up blank without any data. "Dstmain" is the dataset that i am filling before this code gets executed from stored procedure Any help would be appreciated. Thanks Needy

      B Offline
      B Offline
      bemahesh
      wrote on last edited by
      #2

      Please reply to my question if anyone has any idea ASAP. i wanted to solve this problem by mid day today. Urgent reply would be appreciated Thanks Needy

      I 1 Reply Last reply
      0
      • B bemahesh

        Please reply to my question if anyone has any idea ASAP. i wanted to solve this problem by mid day today. Urgent reply would be appreciated Thanks Needy

        I Offline
        I Offline
        Ista
        wrote on last edited by
        #3

        Addheader("Content-Disposition: Application/pdf"; 1 line of code equals many bugs. So don't write any!!

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups