我有Cefsharp winforms v.104
我需要保存整个页面的截图。这段代码改变了浏览器的分辨率。我认为这是错误的方法。
您能指定如何正确保存整个页面吗?
int width = 1024;
int height = 768;
string jsString = "Math.max(document.body.scrollHeight, " +
"document.documentElement.scrollHeight, document.body.offsetHeight, " +
"document.documentElement.offsetHeight, document.body.clientHeight, " +
"document.documentElement.clientHeight);";
JavascriptResponse JSresponse = await chromeBrowser.EvaluateScriptAsync(jsString);
height = Convert.ToInt32(JSresponse.Result);
var client = chromeBrowser.GetDevToolsClient();
await client.Emulation.SetDeviceMetricsOverrideAsync(width, height, 1, true);
await Task.Delay(1000);
await chromeBrowser.CaptureScreenshotAsync().ContinueWith(t => {
using (FileStream fs = new FileStream(@"D:\\" + DateTime.Now.Ticks + ".jpg", FileMode.Create, FileAccess.ReadWrite))
{
byte[] b = t.Result;
fs.Write(b, 0, b.Length);
}
});
1条答案
按热度按时间sxissh061#
谢谢amaitland