3

Minimalexample.Offscreen の例をダウンロードしました。これはスクリーンショットに使用しているコードですが、ページ全体が表示されません。画像がトリミングされます (表示されているページのスクリーンショットのみが撮影されます)。

//   c# code
 var scriptTask = browser.EvaluateScriptAsync("document.getElementById('lst-ib').value = 'CefSharp Was Here!'");
        scriptTask.ContinueWith(t =>
                {
                    Thread.Sleep(500);
                    var task = browser.ScreenshotAsync();
                    task.ContinueWith(x =>
                    {
                        var screenshotPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "CefSharp screenshot.png");

                        Console.WriteLine();
                        Console.WriteLine("Screenshot ready. Saving to {0}", screenshotPath);
                        task.Result.Save(screenshotPath);
                        task.Result.Dispose();
                        Console.WriteLine("Screenshot saved.  Launching your default image viewer...");                       
                        Process.Start(screenshotPath);
                        Console.WriteLine("Image viewer launched.  Press any key to exit.");            
                    }, TaskScheduler.Default);
                  }).Wait();

CefSharp オフスクリーンまたは Cefsharp winforms を使用して、長いページ全体のスクリーンショットを取得するにはどうすればよいですか?

4

2 に答える 2

2

ページが読み込まれるのを 0.5 秒しか待っていないことが原因である可能性があります。Google Chrome で読み込みにかかる時間を確認し、その秒数を指定します。これを 3 秒間追加します。

Thread.Sleep(3000);
于 2016-10-02T02:41:05.377 に答える