2013-12-11 35 views
5

使用IE 11,Windows 8.1。在網頁瀏覽器控件中打印google地圖 - 不會顯示路線

我堵在下面爲Windows窗體應用程序:

var html = "<iframe width=\"425\" height=\"350\" frameborder=\"0\" scrolling=\"no\" marginheight=\"0\" marginwidth=\"0\" " + 
       "src=\"https://maps.google.com/maps?f=d&amp;source=s_d&amp;saddr=Oklahoma+City,+OK&amp;daddr=texas&amp;hl=en&amp;" + 
       "geocode=FSgxHQIddAQw-imB0vh-VIqthzGdOk_RdBKiMw%3BFVfN5wEdi54L-ilJMoILNnBAhjE83ggYjxzrFg&amp;aq=t&amp;sll=39.632471," + 
       "-56.554076&amp;sspn=61.466508,135.263672&amp;mra=ls&amp;ie=UTF8&amp;t=m&amp;z=7&amp;output=embed\">" + 
       "</iframe>" + 
       "<br /><small><a href=\"https://maps.google.com/maps?f=d&amp;source=embed&amp;saddr=Oklahoma+City,+OK&amp;daddr=texas" + 
       "&amp;hl=en&amp;geocode=FSgxHQIddAQw-imB0vh-VIqthzGdOk_RdBKiMw%3BFVfN5wEdi54L-ilJMoILNnBAhjE83ggYjxzrFg&amp;aq=t&amp;" + 
       "sll=39.632471,-56.554076&amp;sspn=61.466508,135.263672&amp;mra=ls&amp;ie=UTF8&amp;t=m&amp;z=7\" style=\"color:#0000FF;" + 
       "text-align:left\">View Larger Map</a></small>"; 

     webBrowser1.DocumentText = (html); 

現在我需要打印所看到的,但它並不顯示方向線,當我到打印預覽

private void button1_Click(object sender, EventArgs e) 
    { 
     this.webBrowser1.ShowPrintPreviewDialog();   
    } 

我已經嘗試了不同的瀏覽器模擬,但仍無法在Google地圖中打印方向線。 IE6 - 11沒有運氣。

SetBrowserFeatureControlKey("FEATURE_BROWSER_EMULATION", fileName, GetBrowserEmulationMode()); 

    public static UInt32 GetBrowserEmulationMode() 
    { 
     int browserVersion = 7; 
     using (var ieKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Internet Explorer", 
      RegistryKeyPermissionCheck.ReadSubTree, 
      System.Security.AccessControl.RegistryRights.QueryValues)) 
     { 
      var version = ieKey.GetValue("svcVersion"); 
      if (null == version) 
      { 
       version = ieKey.GetValue("Version"); 
       if (null == version) 
        throw new ApplicationException("Microsoft Internet Explorer is required!"); 
      } 
      int.TryParse(version.ToString().Split('.')[0], out browserVersion); 
     } 

     // Internet Explorer 10. Webpages containing standards-based !DOCTYPE directives are displayed in IE10 Standards mode. Default value for Internet Explorer 10. 
     UInt32 mode = 11000; 

     switch (browserVersion) 
     { 
      case 7: 
       // Webpages containing standards-based !DOCTYPE directives are displayed in IE7 Standards mode. Default value for applications hosting the WebBrowser Control. 
       mode = 7000; 
       break; 
      case 8: 
       // Webpages containing standards-based !DOCTYPE directives are displayed in IE8 mode. Default value for Internet Explorer 8 
       mode = 8000; 
       break; 
      case 9: 
       // Internet Explorer 9. Webpages containing standards-based !DOCTYPE directives are displayed in IE9 mode. Default value for Internet Explorer 9. 
       mode = 9000; 
       break; 


      case 10: 
       // Internet Explorer 9. Webpages containing standards-based !DOCTYPE directives are displayed in IE9 mode. Default value for Internet Explorer 9. 
       mode = 10000; 
       break; 

      default: 
       // use IE10 mode by default 
       break; 
     } 

     return mode; 
    } 

任何人都可以幫我找出爲什麼這不會打印指示線嗎?請記住,直接將這個html插入.html文件並用IE打開,將顯示路線。但他們不打印。

更新

使用IE瀏覽器,你可以在下面與擴展HTML文檔插件。

<iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0"  marginwidth="0" src="https://maps.google.com/maps?f=d&amp;source=s_d&amp;saddr=Mesa,+AZ+85201&amp;daddr=85258&amp;hl=en&amp;geocode=FXkl_gEduWFV-Sm5aealKggrhzGuOvW7FLWhww%3BFQ8xAAIdIJBU-SmHMd6RyworhzFB0o03Vh1_HQ&amp;aq=t&amp;sll=34.168218,-111.930907&amp;sspn=16.819377,33.815918&amp;mra=ls&amp;ie=UTF8&amp;t=m&amp;ll=33.511629,-111.898842&amp;spn=0.100189,0.145912&amp;z=12&amp;output=embed"></iframe><br /><small><a href="https://maps.google.com/maps?f=d&amp;source=embed&amp;saddr=Mesa,+AZ+85201&amp;daddr=85258&amp;hl=en&amp;geocode=FXkl_gEduWFV-Sm5aealKggrhzGuOvW7FLWhww%3BFQ8xAAIdIJBU-SmHMd6RyworhzFB0o03Vh1_HQ&amp;aq=t&amp;sll=34.168218,-111.930907&amp;sspn=16.819377,33.815918&amp;mra=ls&amp;ie=UTF8&amp;t=m&amp;ll=33.511629,-111.898842&amp;spn=0.100189,0.145912&amp;z=12" style="color:#0000FF;text-align:left">View Larger Map</a></small> 

這將在firefox中正確打印所有內容。我已經在多臺打印機上進行了測試。

這在IE中不能正確打印。我曾嘗試以下:

https://support.google.com/maps/answer/21849?hl=en

如何得到的線條展現了任何想法?

+0

我在我的應用程序中運行你的代碼,但沒關係,我使用了framework3.5,一個winform應用程序。 –

+0

那麼,當你去打印預覽時,你看到了線條顯示? – Watson

+0

它可能只是瀏覽器模擬問題,請嘗試設置FEATURE_BROWSER_EMULATION http://stackoverflow.com/questions/15874565/how-to-set-ie9-by-default-for-web-browser/15883250#15883250 – volody

回答

0

我不知道你的解決方案是否在這裏任何地方。我無法得到我的(XP上的IE8)不能正確顯示打印預覽。順便說一下,這是我第一次在XP上爲我工作,但在新的操作系統上沒有其他人。但是,這裏有我通常最終會搞亂註冊表項:

HKLM:

SOFTWARE \微軟\的Internet Explorer \ MAIN \ FeatureControl \ FEATURE_BROWSER_MODE(10)//你的版本

SOFTWARE \微軟\的Internet Explorer \ MAIN \ FeatureControl \ FEATURE_BEHAVIORS(0或1)

HKCU:

SOFTWAR Ë\微軟\的Internet Explorer \ MAIN \ FeatureControl \ FEATURE_USE_LEGACY_JSCRIPT(0或1)

SOFTWARE \微軟\的Internet Explorer \ MAIN \ FeatureControl \ FEATURE_BROWSER_EMULATION(n000)

此外,還要確保這些(或equivelant)選項在IE Internet Security Zone中設置。

  • 允許Microsoft Web瀏覽器控件的腳本
  • 腳本的ActiveX控件標記爲腳本

對韓國人的運氣安全!

+0

嘗試過不同的組合,但沒有骰子。這一切都用於正確地爲我工作,Windows更新或瀏覽器更新殺死它。如果我嘗試在IE 10下面模擬瀏覽器,那麼會發生此錯誤:http://stackoverflow.com/questions/20506925/wpf-webbrowser-control-and-google-maps-overlays-gray-image – Watson

+0

你認爲它可能嗎如果webbrowsercontrol抑制腳本錯誤,但打印時不會被抑制? – Watson

+0

也許吧。試一試。關閉Suppression並查看在嘗試呈現預覽時是否出現錯誤。 – drankin2112

相關問題