Skip to content

Commit

Permalink
Make demo more modern (#2384)
Browse files Browse the repository at this point in the history
  • Loading branch information
kblok authored Dec 22, 2023
1 parent 20c3bef commit aca4eea
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 16 deletions.
26 changes: 11 additions & 15 deletions demos/PuppeteerSharpPdfDemo/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,27 @@ class MainClass
{
public static async Task Main(string[] args)
{
var options = new LaunchOptions
{
Headless = true
};
var options = new LaunchOptions { Headless = true };

Console.WriteLine("Downloading chromium");

using var browserFetcher = new BrowserFetcher();
await browserFetcher.DownloadAsync();

Console.WriteLine("Navigating google");
using (var browser = await Puppeteer.LaunchAsync(options))
using (var page = await browser.NewPageAsync())
{
await page.GoToAsync("http://www.google.com");
await using var browser = await Puppeteer.LaunchAsync(options);
await using var page = await browser.NewPageAsync();

Console.WriteLine("Generating PDF");
await page.PdfAsync(Path.Combine(Directory.GetCurrentDirectory(), "google.pdf"));
await page.GoToAsync("https://www.google.com");

Console.WriteLine("Export completed");
Console.WriteLine("Generating PDF");
await page.PdfAsync(Path.Combine(Directory.GetCurrentDirectory(), "google.pdf"));

if (!args.Any(arg => arg == "auto-exit"))
{
Console.ReadLine();
}
Console.WriteLine("Export completed");

if (!args.Any(arg => arg == "auto-exit"))
{
Console.ReadLine();
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion demos/PuppeteerSharpPdfDemo/PuppeteerSharpPdfDemo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<LangVersion>default</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="PuppeteerSharp" Version="3.0.0" />
<PackageReference Include="PuppeteerSharp" Version="13.0.2" />
</ItemGroup>
</Project>

0 comments on commit aca4eea

Please sign in to comment.