gpt4 book ai didi

c# - 在网络浏览器控件中打印谷歌地图 - 不会显示方向线

转载 作者:太空狗 更新时间:2023-10-29 23:51:22 28 4
gpt4 key购买 nike

使用 IE 11、Windows 8.1。

我将以下内容插入到 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();
}

我尝试了不同的浏览器模拟,但仍然无法在谷歌地图中打印方向线。 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

关于如何显示线条有什么想法吗?

最佳答案

我不知道这里是否有您的解决方案。我无法让我的(XP 上的 IE8)无法正确显示打印预览。顺便说一句,这是我第一次在 XP 上对我有用,但在较新的操作系统上却对其他人不起作用。但是,这里是我通常会弄乱的注册表项:

HKLM:

SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_MODE (10)//你的版本

SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BEHAVIORS(0 或 1)

香港中文大学:

SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_USE_LEGACY_JSCRIPT(0 或 1)

SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION (n000)

此外,请确保在 IE Internet 安全区域中设置了这些(或等效的)选项。

  • 允许 Microsoft 网络浏览器控件的脚本
  • 编写标记为可安全编写脚本的 ActiveX 控件脚本

祝你好运!

关于c# - 在网络浏览器控件中打印谷歌地图 - 不会显示方向线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20526680/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com