Advertisement
Guest User

Untitled

a guest
Feb 28th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. Response.Clear()
  2. Response.ContentType = result.MimeType 'this is always "application/pdf"
  3. Response.Cache.SetCacheability(HttpCacheability.Private)
  4. Response.Expires = -1
  5. Response.Buffer = True
  6. Response.AddHeader("Content-Disposition", String.Format("{0};FileName={1}", "attachment", fileName))
  7. Response.BinaryWrite(result.DocumentBytes)
  8. Response.End()
  9.  
  10. Protected Sub ButtonPDF_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnPDF.Click
  11.  
  12. DownloadReportPDF(Me.RadGrid1.SelectedValue.ToString())
  13.  
  14. Dim strMessage As String = "alert('Printed PDF Sheet.');"
  15. ScriptManager.RegisterStartupScript(Me, Me.GetType, "MyScript", strMessage, True)
  16.  
  17. End Sub
  18.  
  19. Protected Sub DownloadReportPDF(ByVal releaseMasterId As String)
  20. 'Service call to generate report source
  21. Dim service As New TelerikReportLibrary.ReportServices.PPSReportService
  22. Dim source As Telerik.Reporting.TypeReportSource = service.GetReportSource(releaseMasterId)
  23.  
  24. 'Render PDF and download
  25. Dim reportProcessor As New ReportProcessor()
  26. Dim result As RenderingResult = reportProcessor.RenderReport("PDF", source, Nothing)
  27.  
  28. Dim fileName As String = result.DocumentName + "_" + releaseMasterId + "." + result.Extension
  29.  
  30. Response.Clear()
  31. Response.ContentType = result.MimeType 'this is always "application/pdf"
  32. Response.Cache.SetCacheability(HttpCacheability.Private)
  33. Response.Expires = -1
  34. Response.Buffer = True
  35. Response.AddHeader("Content-Disposition", String.Format("{0};FileName={1}", "attachment", fileName))
  36. Response.BinaryWrite(result.DocumentBytes)
  37. Response.End()
  38.  
  39. End Sub
  40.  
  41. <asp:linkButton ID="btnPDF" CssClass="btn btn-default" runat="server" Width="115px">
  42. <i class="fa fa-file-text" title="Edit"></i> PDF
  43. </asp:linkButton>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement