Tasks using PuppeteerSharp namespace PuppeteerSharpPdfGenerator We will add the following code to the Program. If you want to see the final code of the application, download it from this GitHub repository.įirst of all, we'll create a new Console App.Īfter we named our application and generated the boilerplate code, we will add the "PuppeteerSharp" NuGet package to our solution. The application will receive a URL from the user it will generate a PDF with the content of the website and will save the generated file in a defined directory. ![]() Let's see how to generate PDF files with a C# console app using the Puppeteer Sharp NuGet package. Let's play with Puppeteer Sharp and leverage it to generate content in PDF. So, we can automate interactions with those web browsers. One cool thing is that Puppeteer Sharp supports Chromium-based browsers (Google Chrome, Microsoft Edge), but also Mozilla Firefox. As the library was developed with a C# focus, we can use it with features like dependency injection, Async suffixes, etc. We can interact with a headless browser through a command line.Įven though Puppeteer runs mainly as a headless Chromium instance, we have the possibility to set it as "non-headless" and display all the interactions on the screen. It renders HTML documents and executes JavaScript code, but without displaying it on the screen. What Is Puppeteer?Īccording to the official definition, Puppeteer is "A Node library which provides a high-level API to control headless Chrome or Chromium over the DevTools Protocol".Ī headless browser is basically a web browser without a graphic user interface. ![]() One of the first to be released was Puppeteer. There are various browser automation tools in the market, implemented for several programming languages and with different features or purposes.
0 Comments
Leave a Reply. |