Google地图显示在rdlc报告中,但导出为PDF / word /打印时不显示

时间:2019-01-24 12:34:23

标签: javascript c# google-maps rdlc

我想在rdlc报告中显示google地图,因此我在javascript函数下面使用了在rdlc报告中显示google地图。

Sys.WebForms.PageRequestManager.getInstance().add_endRequest(function () {
                call();
            });

            function call() {
                var s = "<tr valign='top'>"
                s += "<td></td><td class='A37959b3e303f40f197f27f2a3c7bbe2017cl' colspan='5'>";
                s += "<div class='A37959b3e303f40f197f27f2a3c7bbe2017'><div id='dvMap' style='width: 550px; height: 367px'></div></div>";
                s += "</td>";
                s += "</tr>";
                var length = $('#VisibleReportContentctl00_ContentPlaceHolder1_ucRptVwr_rvData_ctl10 table div:contains("Goods Receipt")').length;
                if (length > 0) {
                    $('#VisibleReportContentctl00_ContentPlaceHolder1_ucRptVwr_rvData_ctl10 table div:contains("Goods Receipt")').parent().parent().parent().parent().append(s);
                    FindDeviceLocation();
                }

            }

            function FindDeviceLocation() {
                if (document.getElementById("dvMap") != null) {
                    if (navigator.geolocation) {
                        navigator.geolocation.getCurrentPosition(function (p) {
                            var latLng = new google.maps.LatLng(p.coords.latitude, p.coords.longitude);
                            var mapOptions = {
                                center: latLng,
                                zoom: 13,
                                mapTypeId: google.maps.MapTypeId.ROADMAP
                            };
                            var map = new google.maps.Map(document.getElementById("dvMap"), mapOptions);
                            var marker = new google.maps.Marker({
                                position: latLng,
                                map: map,
                                draggable: true,
                                title: "<div style = 'height:60px;width:200px'><b>Your location:</b><br />Latitude: " + p.coords.latitude + "<br />Longitude: " + p.coords.longitude
                            });
                            google.maps.event.addListener(marker, "click", function (e) {
                                var infoWindow = new google.maps.InfoWindow();
                                infoWindow.setContent(marker.title);
                                infoWindow.open(map, marker);
                            });
                        });
                    } else {
                        alert('Geo Location feature is not supported in this browser.');
                    }
                }
            }

它成功地在rdlc报告中显示了地图,但是当导出为pdf或word或打印时,地图没有出现。

打印按钮代码(C#):-

{
    try
    {

        Warning[] warnings;
        string[] streamids;
        string mimeType;
        string encoding;
        string extension;
        DirectoryInfo directoryInfo = new DirectoryInfo(Request.PhysicalApplicationPath + @"Pages\temp\ReportViewerPrint\");
        if (!directoryInfo.Exists)
        {
            Directory.CreateDirectory(Request.PhysicalApplicationPath + @"Pages\temp\ReportViewerPrint\");
        }
        string strFName = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString();
        string strFileName = "temp/ReportViewerPrint/OutPut-" + strFName + ".pdf";
        string strPrintFileName = "temp/ReportViewerPrint/Print-" + strFName + ".pdf";
        byte[] bytes = rvData.LocalReport.Render("PDF", null, out mimeType, out encoding, out extension, out streamids, out warnings);
        int i = 0;
        FileInfo[] FileList = directoryInfo.GetFiles();
        foreach (FileInfo file in FileList)
        {
            if (file.Exists)
            {
                if (!file.IsReadOnly)
                {
                    file.Delete();
                }
            }
        }
        FileStream fs = new FileStream(HttpContext.Current.Server.MapPath(strFileName), FileMode.Create);
        fs.Write(bytes, 0, bytes.Length);
        fs.Close();
        Document document = new Document(PageSize.A4);
        PdfReader reader = new PdfReader(HttpContext.Current.Server.MapPath(strFileName));
        PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(
           HttpContext.Current.Server.MapPath(strPrintFileName), FileMode.Create));
        document.Open();
        PdfContentByte cb = writer.DirectContent;
        int n = reader.NumberOfPages;
        iTextSharp.text.Rectangle psize = reader.GetPageSize(1);
        float width = psize.Width;
        float height = psize.Height;
        while (i < n)
        {
            document.NewPage();
            i++;
            PdfImportedPage page1 = writer.GetImportedPage(reader, i);
            cb.AddTemplate(page1, 0, 0);
        }
        PdfAction jAction = PdfAction.JavaScript("this.print(true);\r", writer, true);
        writer.AddJavaScript(jAction);
        document.Close();
        Random objRandom = new Random();
        frmPrint.Visible = true;
        frmPrint.Attributes["src"] = strPrintFileName + "?" + (objRandom.Next(100) * objRandom.Next(100));
        fs = null;
        document = null;
        reader = null;
        writer = null;
    }
    catch (Exception ex)
    {
        XBS_PL_MasterPages_XBS_Master master = (XBS_PL_MasterPages_XBS_Master)this.Page.Master;
        master.ucHandleException(ex, this.Page);
        master = null;
    }
}

0 个答案:

没有答案