# puppeteer-sharp **Repository Path**: flxgit/puppeteer-sharp ## Basic Information - **Project Name**: puppeteer-sharp - **Description**: Headless Chrome .NET API - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-01-28 - **Last Updated**: 2021-01-28 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Puppeteer Sharp [][NugetUrl] [][BuildUrl] [][BuildDemoUrl] [][CodeFactorUrl] [][Backers] [NugetUrl]: https://www.nuget.org/packages/PuppeteerSharp/ [BuildUrl]: https://ci.appveyor.com/project/kblok/puppeteer-sharp/branch/master [BuildDemoUrl]: https://ci.appveyor.com/project/kblok/puppeteer-sharp-0c8w9/branch/master [CodeFactorUrl]: https://www.codefactor.io/repository/github/hardkoded/puppeteer-sharp [Backers]: https://opencollective.com/hardkoded-projects Puppeteer Sharp is a .NET port of the official [Node.JS Puppeteer API](https://github.com/GoogleChrome/puppeteer). # Useful links * [API Documentation](http://www.puppeteersharp.com/api/index.html) * Slack channel [#puppeteer-sharp](https://puppeteer.slack.com/join/shared_invite/enQtMzU4MjIyMDA5NTM4LWI0YTE0MjM0NWQzYmE2MTRmNjM1ZTBkN2MxNmJmNTIwNTJjMmFhOWFjMGExMDViYjk2YjU2ZmYzMmE1NmExYzc) * [StackOverflow](https://stackoverflow.com/search?q=puppeteer-sharp) * [Issues](https://github.com/hardkoded/puppeteer-sharp/issues?utf8=%E2%9C%93&q=is%3Aissue) # Prerequisites * As Puppeteer-Sharp is a NetStandard 2.0 library, the minimum platform versions are .NET Framework 4.6.1 and .NET Core 2.0. [Read more](https://docs.microsoft.com/en-us/dotnet/standard/net-standard). * The minimum **Windows** versions supporting the WebSocket library are Windows 8 and Windows Server 2012. [Read more](https://docs.microsoft.com/en-us/dotnet/api/system.net.websockets?redirectedfrom=MSDN&view=netframework-4.7.2). If you need to run Puppeteer-Sharp on Windows 7 you can use [System.Net.WebSockets.Client.Managed](https://www.nuget.org/packages/System.Net.WebSockets.Client.Managed/) through the [LaunchOptions.WebSocketFactory](https://www.puppeteersharp.com/api/PuppeteerSharp.LaunchOptions.html#PuppeteerSharp_LaunchOptions_WebSocketFactory) property. * If you have issues running Chrome on Linux, the Puppeteer repo has a [great troubleshooting guide](https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md). * X-server is required on Linux. # How to Contribute and Provide Feedback Some of the best ways to contribute are to try things out file bugs and fix issues. If you have an issue or a question: * Ask a question on [Stack Overflow](https://stackoverflow.com/search?q=puppeteer-sharp). * File a [new issue](https://github.com/hardkoded/puppeteer-sharp/issues/new). ## Contributing Guide See [this document](https://github.com/hardkoded/puppeteer-sharp/blob/master/CONTRIBUTING.md) for information on how to contribute. # Usage ## Take screenshots ```cs await new BrowserFetcher().DownloadAsync(BrowserFetcher.DefaultRevision); var browser = await Puppeteer.LaunchAsync(new LaunchOptions { Headless = true }); var page = await browser.NewPageAsync(); await page.GoToAsync("http://www.google.com"); await page.ScreenshotAsync(outputFile); ``` You can also change the view port before generating the screenshot ```cs await page.SetViewportAsync(new ViewPortOptions { Width = 500, Height = 500 }); ``` ## Generate PDF files ```cs await new BrowserFetcher().DownloadAsync(BrowserFetcher.DefaultRevision); var browser = await Puppeteer.LaunchAsync(new LaunchOptions { Headless = true }); var page = await browser.NewPageAsync(); await page.GoToAsync("http://www.google.com"); await page.PdfAsync(outputFile); ``` ## Inject HTML ```cs using(var page = await browser.NewPageAsync()) { await page.SetContentAsync("