protected void LinkButton7_Click(object sender, EventArgs e) { AddOPDMedicalRegistrationInvoiceBL objAddOPDMedicalRegistrationInvoiceBL = new AddOPDMedicalRegistrationInvoiceBL(); string invoiceId = objAddOPDMedicalRegistrationInvoiceBL.AddOPDMedicalRegistrationInvoice(Convert.ToInt32(Session["receptionistId"].ToString()), opdMedicalTestRegistrationId); string patientName = ds.Tables[0].Rows[GridView1.SelectedIndex][1].ToString(); string patientId = ds.Tables[0].Rows[GridView1.SelectedIndex][0].ToString(); PrintOPDMedicalTestRegistrationInvoiceBL objPrintOPDMedicalTestRegistrationInvoiceBL = new PrintOPDMedicalTestRegistrationInvoiceBL(); byte[] file = objPrintOPDMedicalTestRegistrationInvoiceBL.PrintOPDMedicalTestRegistrationInvoice(invoiceId, patientName, patientId, testDate, testTime, medicalTestList); Response.Clear(); Response.ContentType = "application/pdf"; Response.AddHeader("Content-Disposition", "attachment; filename=OPDMedicalTestRegistrationInvoice.pdf"); Response.ContentType = "application/pdf"; Response.Buffer = true; Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.BinaryWrite(file); Response.End(); Response.Close(); }