问题描述
我正在尝试使用 CefSharp 以 pdf 格式导出页面,但即使在线程睡眠之后我也收到未完全加载的页面,是否有任何正确的方法可以在导出页面之前等待页面加载?
public static int Main(string[] args)
{
///init cefbrowser and pass page for it///
browser.LoadingStateChanged += browserLoadingStateChanged;
///close sefbrowser ///
}
private static async void browserLoadingStateChanged(object sender,LoadingStateChangedEventArgs e)
{
// Check to see if loading is complete - this event is called twice,one when loading starts
// second time when it's finished
// (rather than an iframe within the main frame).
if (!e.IsLoading)
{
// Remove the load event handler,because we only want one snapshot of the initial page.
browser.LoadingStateChanged -= browserLoadingStateChanged;
Console.WriteLine("Wait");
Thread.Sleep(12000);
//Give the browser a little time to render
// Wait for the screenshot to be taken.
Console.WriteLine("print");
await browser.PrintToPdfAsync("D:\\test.pdf");
}
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)