File tree Expand file tree Collapse file tree 2 files changed +14
-13
lines changed
demos/PuppeteerSharpPdfDemo Expand file tree Collapse file tree 2 files changed +14
-13
lines changed Original file line number Diff line number Diff line change @@ -15,25 +15,26 @@ public static void Main(string[] args)
1515
1616 public static async Task MainAsync ( )
1717 {
18- var chromiumRevision = 526987 ;
18+ var options = new LaunchOptions
19+ {
20+ Headless = true
21+ } ;
1922
2023 Console . WriteLine ( "Downloading chromium" ) ;
21- await Downloader . CreateDefault ( ) . DownloadRevisionAsync ( chromiumRevision ) ;
24+ await Downloader . CreateDefault ( ) . DownloadRevisionAsync ( Downloader . DefaultRevision ) ;
2225
2326 Console . WriteLine ( "Navigating google" ) ;
24- var browser = await Puppeteer . LaunchAsync ( new LaunchOptions
27+ using ( var browser = await Puppeteer . LaunchAsync ( options , Downloader . DefaultRevision ) )
28+ using ( var page = await browser . NewPageAsync ( ) )
2529 {
26- Headless = true
27- } , chromiumRevision ) ;
28-
29- var page = await browser . NewPageAsync ( ) ;
30- await page . GoToAsync ( "http://www.google.com" ) ;
30+ await page . GoToAsync ( "http://www.google.com" ) ;
3131
32- Console . WriteLine ( "Generating PDF" ) ;
33- await page . PdfAsync ( Path . Combine ( Directory . GetCurrentDirectory ( ) , "google.pdf" ) ) ;
32+ Console . WriteLine ( "Generating PDF" ) ;
33+ await page . PdfAsync ( Path . Combine ( Directory . GetCurrentDirectory ( ) , "google.pdf" ) ) ;
3434
35- Console . WriteLine ( "Export completed" ) ;
36- Console . ReadLine ( ) ;
35+ Console . WriteLine ( "Export completed" ) ;
36+ Console . ReadLine ( ) ;
37+ }
3738 }
3839 }
3940}
Original file line number Diff line number Diff line change 66 </PropertyGroup >
77
88 <ItemGroup >
9- <PackageReference Include =" PuppeteerSharp" Version =" 0.1.1 " />
9+ <PackageReference Include =" PuppeteerSharp" Version =" 0.3.0 " />
1010 </ItemGroup >
1111
1212</Project >
You can’t perform that action at this time.
0 commit comments