kaushik guru

kaushik guru

  • NA
  • 252
  • 30.5k

How to show pdf in asp.net webforms

Apr 14 2020 11:54 PM
I have converted the .rpt file to .pdf and now i want to show it as pop up after being generated
 
this i what i tried and i have am able to get the pdf file as string in a script file how to show that as pop up .
 
 private void getreport()
    {
        string sValue = ddlusers.SelectedItem.Text;
        if (ddlreports.Text == "User Group Report")
        {
            var clsPrepareFile = new clsPrepareFile(General.ConnString());
            dsUserMatrixReport = clsPrepareFile.UserGroupReport(sValue);
            if (dsUserMatrixReport != null && dsUserMatrixReport.Tables.Count > 1 && dsUserMatrixReport.Tables[0].Rows.Count > 0 && dsUserMatrixReport.Tables[1].Rows.Count > 0)
            //    if (dsUserMatrixReport != null )
            {
                dsUserMatrixReport.Tables[0].TableName = "Inward_Report1";
                dsUserMatrixReport.Tables[1].TableName = "UserStatus";
                var rptDocument = new ReportDocument();
                //rptDocument.SummaryInfo.ReportTitle = "Inward_Report_" + txtFromDate.Text.Replace("/", "") + "_" + txtToDate.Text.Replace("/", "");
                CrystalReportViewer1.Visible = true;
                //CrystalReportViewer1.ID = "Inward_Report_" + txtFromDate.Text.Replace("/", "") + "_" + txtToDate.Text.Replace("/", "");
                rptDocument.Load(Server.MapPath("~\\Report\\UserGroupReport.rpt"));
                rptDocument.SetDataSource(dsUserMatrixReport);
                Session.Add("CR_Session", rptDocument);
                CrystalReportViewer1.ReportSource = rptDocument;
                rptDocument.ExportToDisk(ExportFormatType.PortableDocFormat, @"D:/G3GeneratedPDF/UserGroupReport" + DateTime.Now.ToString("yyyyMMddHHmm") + ".pdf");
                string pdfshow = "<script language='javascript'>" + "window.open('D:/G3GeneratedPDF/UserGroupReport" + DateTime.Now.ToString("yyyyMMddHHmm") + ".pdf');</script>";

            }
 
 
 
Pls guide
 
 
 

Answers (1)