Click here to Skip to main content
15,897,371 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hi,

I need to show a RDLC report in Acrobat PDF Viewer which should be integrated as activex control in a form in .net Windows Forms application.
Im using the same concept in web application, and the code for the same is as follows...

XML
dvpdf.Visible = true;
dvReport.Visible = false;
Warning[] warnings;
string[] streamIds;
string mimeType = string.Empty;
string encoding = string.Empty;
string extension = string.Empty;
byte[] bytes = this.ReportViewer1.LocalReport.Render("PDF", null, out mimeType, out encoding, out extension, out streamIds, out warnings);
String strfilename = System.IO.Path.GetRandomFileName();
using (FileStream fs = new FileStream(Server.MapPath("~/pdfoutput/") + strfilename + ".pdf", FileMode.Create))
{
fs.Write(bytes, 0, bytes.Length);
}
StringBuilder sb = new StringBuilder();
sb.Append("<object data='" + "pdfoutput/" + strfilename + ".pdf" + "' type='application/pdf' width='916' height='470'>");
sb.Append("</object>");
this.dvpdf.InnerHtml = sb.ToString();



from this it is showing the report in PDF format in Acrobat Reader which is installed on the machine.

Now, how it can be done in the windows forms application.

Please help me.

Thanks in advance. Regards
Sri
Posted
Updated 15-Mar-11 0:23am
v2
Comments
Sandeep Mewara 15-Mar-11 4:32am    
Do you mean export to PDF via code?
Sri9797 15-Mar-11 5:08am    
Hi Sandeep, thanks for your quick reply.
I'm able to show the rdlc report in ReportViewer1 and able to export it as pdf.
But, I want it to be shown in Acrobat Reader activex control.
I have added a COM component (axAcroPDF) to my forms toolbox and placed on a form besides ReportViewer1.

the exact current scenario is

ReportViewer1 is on "frmReport.cs [Design]" and the report is getting assigned to the report viewer through code like follows.

this.reportViewer1.LocalReport.ReportPath = Application.StartupPath + "\\Reports\\Legacy.rdlc";

now the rdlc is shown on the report viewer and able to export it.

----

the same way like above; I want my RDLC to be shown in Acrobat Reader activex (axAcroPDF).
in other words I want to show my RDLC in Acrobat Reader which is embedded in my "frmReport.cs [Design]"

can you give me an Idea or approach to get this done.

1 solution

You already know how to render the report as a PDF, so you're over halfway there.

You should have the ability to use the ActiveX component you're working with to pass in a file path and display a saved file.

Therefore, your approach should be:
1) generate a filepath
2) render the RDLC to PDF at that location
3) pass the path to the activex control in question.

Note that if you're just hacking in something not purposed for this you might be violating a use agreement (i.e., if you're just stubbing in an Adobe DLL, this is a no-no). There are 3rd party PDF controls for .NET, so you shouldn't have trouble getting one for cheap or free.

Cheers.
 
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