File tree Expand file tree Collapse file tree 1 file changed +44
-3
lines changed Expand file tree Collapse file tree 1 file changed +44
-3
lines changed Original file line number Diff line number Diff line change 1- # Introduction
1+ # Puppeteer Sharp
22
3- This project is a .NET port of the official [ Node.JS Puppeteer API] ( https://github.com/GoogleChrome/puppeteer ) .
4- The first goal is to get a functional library with an API as close as the official one.
3+ [ ![ NuGet] ( https://img.shields.io/nuget/v/PuppeteerSharp.svg?style=flat-square&label=nuget&colorB=green )] ( https://www.nuget.org/packages/PuppeteerSharp/ )
4+
5+ Puppeteer Sharp is a .NET port of the official [ Node.JS Puppeteer API] ( https://github.com/GoogleChrome/puppeteer ) .
6+
7+ # Usage
8+
9+ ## Take screenshots
10+
11+ ```
12+ await Downloader.CreateDefault().DownloadRevisionAsync(chromiumRevision);
13+ var browser = await Puppeteer.LaunchAsync(new LaunchOptions
14+ {
15+ Headless = true
16+ }, chromiumRevision);
17+ var page = await browser.NewPageAsync();
18+ await page.GoToAsync("http://www.google.com");
19+ await page.ScreenshotAsync(outputFile));
20+ ```
21+
22+ You can also change the view port before generating the screenshot
23+
24+
25+ ```
26+ await page.SetViewport(new ViewPortOptions
27+ {
28+ Width = 500,
29+ Height = 500
30+ });
31+ ```
32+
33+
34+ ## Generate PDF files
35+
36+ ```
37+ await Downloader.CreateDefault().DownloadRevisionAsync(chromiumRevision);
38+ var browser = await Puppeteer.LaunchAsync(new LaunchOptions
39+ {
40+ Headless = true
41+ }, chromiumRevision);
42+ var page = await browser.NewPageAsync();
43+ await page.GoToAsync("http://www.google.com");
44+ await page.PdfAsync(outputFile));
45+ ```
546
647# Monthly reports
748
You can’t perform that action at this time.
0 commit comments