I am using crystal report of VS 2008. I want to open a crystal report in PDF even when it is loaded with out showing the crystal report . I also not want to show the save dialog box while opening in PDF. With code below the report is opening directly in PDF but showing the save dialog box. How should i suppress the save dialog box and open the report directly in PDF?

CrystalReport1 oRpt = new CrystalReport1();
            
            DataSet ds = new DataSet();
            SqlDataAdapter adp0 = new SqlDataAdapter("SELECT * from test2", con);
            adp0.Fill(ds);
            if (ds.Tables[0].Rows.Count > 0)
            {
                CrystalReportViewer1.SelectionFormula = "{test2.FirstName} = " + ds.Tables[0].Rows[0][0].ToString();
                CrystalReportViewer1.ReportSource = oRpt;
                
            }

            
            oRpt.Load(Server.MapPath("CrystalReport1.rpt"));
            ConnectionInfo connectionInfo = new ConnectionInfo();
            connectionInfo.DatabaseName = System.Configuration.ConfigurationSettings.AppSettings["DB"];
            connectionInfo.UserID = System.Configuration.ConfigurationSettings.AppSettings["UID"];
            connectionInfo.Password = System.Configuration.ConfigurationSettings.AppSettings["PWD"];
            connectionInfo.ServerName = System.Configuration.ConfigurationSettings.AppSettings["ServerName"];
            SetDBLogonForReport(connectionInfo, oRpt);
            System.IO.FileStream fs = null;
            long FileSize = 0;
            DiskFileDestinationOptions oDest = new DiskFileDestinationOptions();
            string ExportFileName = Server.MapPath("\\CrystalReport1.rpt") + "Export";
            oRpt.ExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
            oRpt.ExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;
            oDest.DiskFileName = ExportFileName;
            oRpt.ExportOptions.DestinationOptions = oDest;
            oRpt.Export();
            Response.Clear();
            Response.Buffer = true;
            Response.AddHeader("Content-Type", "application/pdf");
            Response.AddHeader("Content-Disposition", "attachment;filename=testing.pdf;");
            
            fs = new System.IO.FileStream(ExportFileName, FileMode.Open);
            FileSize = fs.Length;
            byte[] bBuffer = new byte[Convert.ToInt32(FileSize) + 1];
            fs.Read(bBuffer, 0, Convert.ToInt32(FileSize));
            fs.Close();
            Response.BinaryWrite(bBuffer);
            Response.Flush();
            Response.Close();

Please any one help me to figure it out.Thanks In advance
*Ranj*

I solved the problem.No need of this line of code
Response.AddHeader("Content-Disposition", "attachment;filename=testing.pdf;");

Thanks if any one tried 4 this

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.