WebBrowser的简单使用

加载初始网页

this.webBrowser1.Url = new Uri("http://www.google.com");

加载初始html

webBrowser1.DocumentText =
    "<html><body>Please enter your name:<br/>" +
    "<input type='text' name='userName'/><br/>" +
    "<a href='http://www.microsoft.com'>continue</a>" +
    "<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>" +
    "<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>" +
    "<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>"+                
    "</body></html>";

webBrowser1.Navigate(@"D:\A\test.html");

加载pdf文件

this.webBrowser1.Url = new Uri(@"D:\pdf\a.pdf");

在html中嵌入pdf

webBrowser1.DocumentText = "<html><body><p><center><h1> PDF in HTML </h1></center></p>" +
    "<object classid = 'clsid:CA8A9780-280D-11CF-A24D-444553540000' width = '100%' height = '720'>" +
    @"<param name = 'SRC' value = 'D:\pdf\a.pdf'>" +
    @"<embed width = '100%' height = '400' fullscreen = 'yes' src = 'D:\pdf\a.pdf'>" +
    "<noembed></noembed></embed></object></body></html>";
posted @ 2018-11-21 16:14  Kyle0418  阅读(486)  评论(0编辑  收藏  举报