title: Resizing Awesomium WebView does not resize surface
body: <p>I'm using awesomium to take a snapshot of an HTML page.</p>
  
  <pre><code>public Bitmap renderHtml(string htmlContent)
      {
          using (WebSession session = WebCore.CreateWebSession(WebPreferences.Default))
          {
              int docHeight = 0, docWidth = 0;
              using (WebView view = WebCore.CreateWebView(1, 1, WebViewType.Offscreen))
              {
  
                  bool finishedLoading = false;
                  var uri = new Uri("data:text/html," + htmlContent, UriKind.Absolute);
                  //uri = new Uri("http://www.google.com");
                  view.Source = uri;
                  view.LoadingFrameComplete += (s, e) =&gt;
                      {
                          if (e.IsMainFrame)
                          {
                              finishedLoading = true;
                              docHeight = (int)view.ExecuteJavascriptWithResult("(function() { var bodyElmnt = document.body; var html = document.documentElement; var height = Math.max( bodyElmnt.scrollHeight, bodyElmnt.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight ); return height; })();");
                              docWidth = (int)view.ExecuteJavascriptWithResult("(function() { var bodyElmnt = document.body; var html = document.documentElement; var width = Math.max( bodyElmnt.scrollWidth, bodyElmnt.offsetWidth, html.clientWidth, html.scrollWidth, html.offsetWidth); return width; })();");
                          }
                      };
                  while (!finishedLoading)
                  {
                      Thread.Sleep(100);
                      WebCore.Update();
                  }
                  //view.Surface.Initialize(view, docWidth, docHeight);
                  view.Resize(docWidth, docHeight);
  
                  //cannot do this here because view.Surface size is (1,1)
                  /*
                  bmp = new Bitmap(docWidth, docHeight);
                  BitmapData bmpData = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.WriteOnly, bmp.PixelFormat);
                  BitmapSurface bmpSurface = (BitmapSurface)view.Surface;
                  bmpSurface.CopyTo(bmpData.Scan0, bmpSurface.RowSpan, 4, false, false);
                  bmp.UnlockBits(bmpData);
                  */ 
              }
              using (WebView view2 = WebCore.CreateWebView(docWidth, docHeight, WebViewType.Offscreen))
              {
                  bool finishedLoading = false;
                  var uri = new Uri("data:text/html," + htmlContent, UriKind.Absolute);
  
                  view2.Source = uri;
                  view2.LoadingFrameComplete += (s, e) =&gt;
                  {
                      if (e.IsMainFrame)
                      {
                          finishedLoading = true;
                      }
                  };
                  while (!finishedLoading)
                  {
                      Thread.Sleep(100);
                      WebCore.Update();
                  }
                  bmp = new Bitmap(docWidth, docHeight);
                  BitmapData bmpData = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.WriteOnly, bmp.PixelFormat);
                  BitmapSurface bmpSurface = (BitmapSurface)view2.Surface;
                  bmpSurface.CopyTo(bmpData.Scan0, bmpSurface.RowSpan, 4, false, false);
                  bmp.UnlockBits(bmpData);
  
              }
          }
  
          return bmp;
      }
  </code></pre>
  
  <p>This works, but I need to create a second view using the page size that I got from the first view because when I call view.Resize() it does not resize the view's Surface so i'm getting an error trying to save the image because the sizes differ. If I call Surface.Initialize first with the new width and height then the original surface is gone and all I get is an empty white image. </p>
  
  <p>How can I resize the view's surface and make this work without creating a 2nd view ?</p>