• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 604
  • Last Modified:

Opening the PDF file at client side.

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

1 Solution
Dale BurrellDirectorCommented:
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);
GouthamAnandAuthor Commented:
Thanks a lot
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now