Click here to Skip to main content
15,908,173 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello ,

I have created a RDLC report .It's working fine. Now instead of showing the report i need to show this report as pdf inside a panel or a div. All i can do after a lot of searching on google is showing this pdf on the whole page in the browser but i need this pdf to be inside panel or div.

Here is the code that's not working for showing pdf. I used breakpoints and found that there is nothing inside file stream because there is no pdf inside output folder. how to create this pdf inside this folder ??
VB
On Error Resume Next
       Dim ds As New ds_ScaleWiseEmployeeDetails()
       Dim Department As Integer = 6

       Dim xFirst As String = "Select 0 EmpID , ' ' EmployeeName,' ' Designation,' ' Branch, ' ' BasicPay ,' 'GradePay,0 S.No, ' ' Section,'' Scale where 1=2"
       Dim da As New SqlDataAdapter(xFirst, ConfigurationManager.ConnectionStrings("PIMSConnectionString").ConnectionString)
       da.Fill(ds, "Employee")

       Dim xSecond As String = " Select ' ' Scale where 1=2"
       Dim da1 As New SqlDataAdapter(xSecond, con)
       da1.Fill(ds, "Scale")
       Dim dr1 As DataRow = ds.Tables("Scale").NewRow()
       dr1("Scale") = ""
       ds.Tables("Scale").Rows.Add(dr1)

       Dim x As String = "Select d.empid as EmpID ,p.post_name as Designation , mds.subDept as Branch ,d.BasicPay as BasicPay ,d.Gradepay as GradePay,mr.Section as Section,me.name as EmployeeName,ms.scale as Scale from details_employee d"
       x += " inner join master_post p on d.postId= p.unqId inner join master_dept_subs mds on d.subDeptID=mds.unqid "
       x += " inner join master_depts_subs_sections_for_Rajbhavan mr on d.sectionId = mr.unqid "
       x += " inner join master_employee me on d.empid=me.unqid"
       x += " inner join master_scale ms on d.scaleId=ms.unqid"
       x &= String.Format(" and d.deptID={0} order by joining_dt desc", Department)

       Dim table As DataTable = Dal.GettDS(x).Tables(0)
       For Each dr As DataRow In table.Rows
           ds.Tables("Employee").ImportRow(dr)
       Next
      

       Dim datasource1 As New ReportDataSource("ds_ScaleWiseEmployeeDetails_Employee", ds.Tables("Employee"))
       Dim datasource2 As New ReportDataSource("ds_ScaleWiseEmployeeDetails_Scale", ds.Tables("Scale"))
       ReportViewer1.LocalReport.DataSources.Clear()
       ReportViewer1.LocalReport.DataSources.Add(datasource1)
       ReportViewer1.LocalReport.DataSources.Add(datasource2)
       ReportViewer1.LocalReport.Refresh()



VB
Dim warnings As Warning()
       Dim streamIds As String()
       Dim mimeType As String = String.Empty
       Dim encoding As String = String.Empty
       Dim extension As String = String.Empty

       Dim bytes As Byte() = ReportViewer1.LocalReport.Render("pdf", Nothing, mimeType, encoding, extension, streamIds, warnings)

Using fs As New FileStream(Server.MapPath("~DataEntry/Reports/output/") + "MyReport.pdf", FileMode.Create)
          fs.Write(bytes, 0, bytes.Length)
      End Using


      Dim sb As New StringBuilder()
      sb.Append("<object data='" + "~/DataEntry/Reports/output/MyReport.pdf" + "' type='application/pdf' width='916' height='470'>")
      sb.Append("</object>")
      dvpdf.InnerHtml = sb.ToString()
Posted
Comments
[no name] 23-Sep-13 4:48am    
If you want to generate PDF report use ITextSharp.dll

1 solution

Try Google Doc Viewer. It's very simple to use and free! Add a markup code like the following in your webpage:

<iframe src="http://docs.google.com/gview?url=http://infolab.stanford.edu/pub/papers/google.pdf&embedded=true" style="width:600px; height:500px;" frameborder="0"></iframe>

Then you just need to set up your own document file to the "url" query string param and that's it!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900