Jitendra singh
Jitendra singh

Reputation: 433

how to render string(html/xhtml/xml) in cefsharp.winform chromium webbrowser not from url

hi I am using chromium web browser control to render html/xhtml/xml file to get height and width of this file. I am able to render html file from html page url like(www.google.com).

//browser = new ChromiumWebBrowser("www.google.com")
 //  {
  //    Dock = DockStyle.Fill,
  // };

but I have to render pages after reading the file

StreamReader sr = new StreamReader("C:/Users/deependra.singh/Documents/Desktop/ePub2_Sample05_Biology_SampleChapter_EN/OPS/ch01.xhtml");
 string html = sr.ReadToEnd();

browser = new ChromiumWebBrowser(html )
            {
                Dock = DockStyle.Fill,
            };

I want to get height and width of renders data in cef browser. I need height/width on after complete rendering so please bind the complete method also.

thanks

Upvotes: 2

Views: 2938

Answers (1)

İsmail Kocacan
İsmail Kocacan

Reputation: 1234

try this

const String URL_BLANK = "about:blank";
ChromiumWebBrowser browser = new ChromiumWebBrowser(String.Empty);
String htmlContent = File.ReadAllText("c:\myfile.html");
browser.Load(URL_BLANK);
browser.LoadHtml(HtmlContent, "zart zurt");

Upvotes: 3

Related Questions