在面板或div中将Rdlc报告显示为pdf [英] Showing Rdlc Report as pdf inside a panel or div

查看:54
本文介绍了在面板或div中将Rdlc报告显示为pdf的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,



我创建了一份RDLC报告。它工作正常。现在,我不需要显示报告,而是需要在面板或div中将此报告显示为pdf。我在google上进行大量搜索后可以在浏览器的整个页面上显示这个pdf但我需要这个pdf在面板或div内。



这是代码不能用于显示pdf。我使用了断点,发现文件流中没有任何内容,因为输出文件夹中没有pdf。如何在这个文件夹中创建这个pdf ??

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 ??

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()










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()

推荐答案

试用Google Doc Viewer。它非常简单易用!在您的网页中添加如下标记代码:



< iframe src =" http://docs.google.com/gview?url = http: //infolab.stanford.edu/pub/papers/google.pdf&embedded=true"风格= QUOT;宽度:600px的;高度:500像素;" frameborder =" 0">< / iframe>



然后您只需将自己的文档文件设置为url即可。查询字符串参数,就是这样!
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!


这篇关于在面板或div中将Rdlc报告显示为pdf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆