Opening the PDF file at client side.

Posted on 2011-02-20
Last Modified: 2012-05-11
I am working on a web application. I have to generate a report in PDF at client side.
Below is my code. It is trying to create the report in server. But it has to create the PDF file at client side.

Can anyone suggest me what changes I need to make to this code.
protected void lnkPdf_Click(object sender, EventArgs e)
            byte[] result = null;
            result = GetReport("AssetTolReport.rpt", CEReportFormat.PDF);//DataTest
            string currentDir = "";
            string tmpReportName = "AssetTolerance" + DateTime.Now.Ticks.ToString() + ".PDF";
            FileStream fs = new FileStream(Path.Combine(currentDir, tmpReportName), FileMode.Create, FileAccess.Write);
            fs.Write(result, 0, result.Length);

        /// <summary>
        /// To convert the crystal report to PDF
        /// </summary>
        /// <param name="reportName"></param>
        /// <param name="reportFormat"></param>
        /// <returns><see cref="result"/></returns>
        public byte[] GetReport(string reportName, CEReportFormat reportFormat) 
            SessionInfo sessionInfo = Utility.GetSessionInfo();
            byte[] result = null;
            string acctId = txtAccount.Text;
            DataSet ds = new DataSet();
            ds = WebUIController.GetAssetToleranceDataSet(acctId);
            ds.Tables[0].TableName = "GPQ_ACCT";               
            result = ReportHelper.ExecuteReport(sessionInfo,reportName, reportFormat, ds);
            return r

Open in new window

Question by:GouthamAnand
LVL 21

Accepted Solution

Dale Burrell earned 500 total points
ID: 34939252
Just to be clear you definitely have to *create* the PDF document on the server, but I am assuming you want to deliver it to the client? Also not sure what Process.Start() does?

In which case you do the following:

String FileName = "YourFileName.pdf";
byte[] FileData = ; // Your File Data

Response.ContentType = "application/pdf";
Response.AppendHeader("Content-Disposition", "attachment; filename=" + FileName);

Author Closing Comment

ID: 34939454
Thanks a lot

Featured Post

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit If you want to manage em…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question