PDF报告未在Internet Explorer中显示

时间:2014-12-02 06:21:19

标签: asp.net

在将数据保存到数据库之后的项目中,它将在新页面中显示报告(pdf)。它在所有浏览器上运行正常 IE .it将显示如下图enter image description here

代码

 private string CreateLE_ANEZ()
    {
        try
        {

            ReportDocument oRPT = new ReportDocument();
            oRPT.Load(System.Web.HttpContext.Current.Server.MapPath("Reports/LE-Einzel.rpt"));
            ReportDocument subreportArtikel = new ReportDocument();
            SubreportObject subreportObjectArtikel;
            subreportObjectArtikel = oRPT.ReportDefinition.ReportObjects["Subreport1"] as SubreportObject;
            subreportArtikel = subreportObjectArtikel.OpenSubreport("LE-Artikel-SubRepoert.rpt");
            CTemplate objTemp = new CTemplate();
            DataTable dtTemplate = objTemp.SelectLETemplate("ANEZ");
            oRPT.SetDataSource(dtTemplate);

            DataTable dtArtikelData = SelectLEArtikel();
            subreportArtikel.SetDataSource(dtArtikelData);
            #region set parameter values
            //AAddressen objCust = new AAddressen();
            //objCust=new CAddressen().SelectAddressen(AddressenID);
            CUsers objUser = new CUsers();
            objUser.UserID = UserID;
            AUsers objAUser = objUser.SelectUserProfile();
            CLand objLand = new CLand();
            objLand.ID = objAUser.Land;
            objLand.SelectLandById();
            objAUser.LandName = objLand.Lnd_Name;
            CUtilities objUtil=new CUtilities();                
            string strDate = LEDate.Day.ToString() + "." + LEDate.Month.ToString() + "." + LEDate.Year.ToString();
            string strLands = SelectLELand();

            /* Requirement No ::  18895       ::: Commented By Jyotheena Jose      :1/30/2014 11:21:17 AM
               string strSender = objAUser.Ort + " : " + strDate + " , " + " " + objAUser.FirmaName +  " " + objAUser.PLZ +" " + objAUser.Street + " , " + objAUser.FirstName + " " + objAUser.LastName;*/
            string strSender = objAUser.Ort + " : " + strDate + " , " + objAUser.FirmaName + ", " + objAUser.Street + ", " + objAUser.PLZ + " " + objAUser.Ort + " , " + objAUser.FirstName + " " + objAUser.LastName + " , " + objAUser.Position;
            string strLEDate = LEDate.ToString("yyyyMMdd") + "-";
            string strCum = "";
            string strNoCum = "";
            if (IsCumulation == "T")
                strCum = "X";
            else
                strNoCum ="X";

            switch (LENumber.Trim().Length)
            {
                case 1: strLEDate += "00" + LENumber;
                    break;
                case 2: strLEDate += "0" + LENumber;
                    break;
                default: strLEDate += LENumber;
                    break;
            }
            ParameterDiscreteValue pDescValue;
            ParameterFieldDefinitions pFielddDefs;
            ParameterFieldDefinition pFieldLoc = null;
            ParameterValues pValues = new ParameterValues();
            pFielddDefs = oRPT.DataDefinition.ParameterFields;
            pDescValue = new ParameterDiscreteValue();
            CreateParameterFields(pDescValue, pFielddDefs, pFieldLoc, pValues, "pLandList", strLands);
            CreateParameterFields(pDescValue, pFielddDefs, pFieldLoc, pValues, "pSender", strSender);
            CreateParameterFields(pDescValue, pFielddDefs, pFieldLoc, pValues, "pLEDate", strLEDate);
            CreateParameterFields(pDescValue, pFielddDefs, pFieldLoc, pValues, "pBemerkungen", Bemerk);
            CreateParameterFields(pDescValue, pFielddDefs, pFieldLoc, pValues, "pCum", strCum);
            CreateParameterFields(pDescValue, pFielddDefs, pFieldLoc, pValues, "pNoCum", strNoCum);
            CreateParameterFields(pDescValue, pFielddDefs, pFieldLoc, pValues, "pCumtext", Cumulation);
            #endregion

            string strFileName = "Pdf/" + UserID.ToString().Trim() + "Einzel.pdf";   

            if (!Directory.Exists(System.Web.HttpContext.Current.Server.MapPath("Pdf")))
                Directory.CreateDirectory(System.Web.HttpContext.Current.Server.MapPath("Pdf"));
            if (File.Exists(System.Web.HttpContext.Current.Server.MapPath(strFileName)))
                File.Delete(System.Web.HttpContext.Current.Server.MapPath(strFileName));
            oRPT.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, System.Web.HttpContext.Current.Server.MapPath(strFileName));
            return strFileName;
        }
        catch (Exception ex)
        {
            throw new Exception("CLE->CreateLE_ANEZ", ex);
        }
    }

在新页面之后(ViewPdf1.aspx)

rotected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Session["rpt"] == null)
                return;
            else
            {
                string strValues = Session["rpt"].ToString();
                string[] strData = strValues.Split(',');
                //Session.Remove("rpt");
                //ViewState["rpt"] = strData[1].Trim();
                //ViewState["LENo"] = strData[0].Trim();
                //string strUrl = ViewState["rpt"].ToString();
                string strUrl = strData[1].Trim();
                dvPdfLoader.InnerHtml = "<object data='" + strUrl + "' type='application/pdf'  width='100%' height='468px'></object>";
                string strQuery = Request.QueryString["s"];
                if (strQuery != null && CUtilities.Decrypt(strQuery.Trim()) == "mailsent")
                {
                    lblMessage.Text = "E-Mail erfolgreich gesendet";
                }
            }
        }
    }

请帮助解决此错误..

此致 Jithesh

1 个答案:

答案 0 :(得分:1)

这是解决方案:)

Internet Explorer 10&amp; 11被认为是微软专有浏览器的最佳版本; IE浏览器。使用Windows 8和Windows 7,您可以使用IE 10和IE 11.在这两次迭代中,一些用户报告面临一个问题,即每当他们尝试下载并打开PDF文件时,Internet Explorer都无法打开PDF文件

http://www.thewindowsclub.com/pdf-files-will-open-internet-explorer