5

Using IE 11, Windows 8.1.

I'm plugging in the following into a windows form application:

 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);

Now I want to print this as seen, but it doesn't show the directions lines when I got to printpreview

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

I have tried different browser emulations and still no way to print the direction lines in google maps. IE6 - 11 with no luck.

 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;
    }

Can anyone help me find out why this doesn't print the directions lines? Keep in mind, directly plugging in this html into a .html file and opening with IE, will show the directions lines. But they do not print.

Update

Using IE, you can plug in the following into a document with extension 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>

This will print everything correctly in firefox. I have tested this out on multiple printers.

This does not print correctly in IE. I have tried the following:

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

Any ideas on how to get the lines to show up?

Watson
  • 1,385
  • 1
  • 15
  • 36
  • I run your code in my app, but it's OK, I use framework3.5, a winform App. – Scott Yang Dec 11 '13 at 18:37
  • So, when you went to printpreview you saw the lines show up? – Watson Dec 11 '13 at 19:15
  • it can be just browser emulation issue, try to set FEATURE_BROWSER_EMULATION http://stackoverflow.com/questions/15874565/how-to-set-ie9-by-default-for-web-browser/15883250#15883250 – volody Dec 11 '13 at 20:47
  • I am using this to set the default browser emulation to IE10. The webbrowesercontrol shows correctly, but it does not print correctly. – Watson Dec 12 '13 at 19:35
  • I'm taking a look into your problem. It's not giving me any trouble. The purple direction line prints fine. But I've also been playing with IE registry values because I'm still on XP IE8 :). But as a side note, IE will never not be installed on a windows machine. The easiest way to get the IE version is `webBrowser1.Version.Major` I'll post an answer if I can figure it out. I'm trying to see if I can make it stop from working and see what did it. – drankin2112 Dec 21 '13 at 02:44
  • Have you tried sending a screen shot to the printer? – Techie Joe Dec 24 '13 at 17:48
  • Will a screen cast help? – Watson Dec 26 '13 at 15:32

1 Answers1

0

I don't know if your solution is in here anywhere. I can't get mine (IE8 on XP) to not show the print preview correctly. Which, by the way, is the first time something has ever worked for me on XP but not someone else on a newer OS. But, here are the registry keys that I usually end up messing with:

HKLM:

SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_MODE (10) // your version

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

HKCU:

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

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

Also, make sure these (or equivelant) options are set in IE Internet Security Zone.

  • Allow scripting of Microsoft web browser control
  • Script ActiveX controls marked safe for scripting

Gook luck!

drankin2112
  • 4,715
  • 1
  • 15
  • 20
  • Tried different combinations but no dice. This all used to work correctly for me, windows update or a browser update killed it. If I try emulating the browser below IE 10, then this error occurs: http://stackoverflow.com/questions/20506925/wpf-webbrowser-control-and-google-maps-overlays-gray-image – Watson Dec 22 '13 at 18:16
  • Do you think its possible if the webbrowsercontrol suppresses a scripting error but when printing it doesn't get suppressed? – Watson Dec 22 '13 at 18:25
  • Maybe. Give it a try. Turn of Suppression and see if you get an error right when it tries to render the preview. – drankin2112 Dec 22 '13 at 18:28
  • Try going to Print -> Page Setup and disable "Enable Shrink-to-Fit". I think people are having issues with that in IE10. – drankin2112 Dec 22 '13 at 19:03
  • I turned off suppression but no errors. I'm at my wits end. I have turned on and off shrink to fit, it doesn't have any effect. – Watson Dec 24 '13 at 16:51
  • I should add, that this html I posted does not print the lines even if I put the html into a .html file, open IE and hit print. The lines show up, but they do not print. – Watson Dec 24 '13 at 17:09
  • No. Going directly to google maps, it shows the lines when viewing but when you hit print preview the lines disappear. Printing from here does not print the lines, testing on multiple printers and models. – Watson Dec 26 '13 at 18:34
  • see if applying these instructions helps http://technet.microsoft.com/en-us/library/dn338133.aspx – drankin2112 Dec 26 '13 at 18:42
  • Also, read this. Seems like it might be very helpful. http://news.cnet.com/8301-10805_3-57609270-75/microsoft-rolls-out-reliability-patch-for-internet-explorer-11/ – drankin2112 Dec 26 '13 at 18:45