Skip to content

Commit 17574d5

Browse files
authored
Demo solution (#74)
1 parent 06774b6 commit 17574d5

File tree

4 files changed

+79
-0
lines changed

4 files changed

+79
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,3 +290,6 @@ Thumbs.db
290290

291291
# ignore local cert
292292
/lib/PuppeteerSharp.TestServer/testCert.cer
293+
294+
demos/PuppeteerSharpPdfDemo/google.pdf
295+
demos/PuppeteerSharpPdfDemo/.local-chromium/

demos/PuppeteerSharpDemos.sln

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 15
4+
VisualStudioVersion = 15.0.27130.2036
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PuppeteerSharpPdfDemo", "PuppeteerSharpPdfDemo\PuppeteerSharpPdfDemo.csproj", "{1B8CE751-9762-45DD-8AEC-A6C1D74A7730}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{1B8CE751-9762-45DD-8AEC-A6C1D74A7730}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{1B8CE751-9762-45DD-8AEC-A6C1D74A7730}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{1B8CE751-9762-45DD-8AEC-A6C1D74A7730}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{1B8CE751-9762-45DD-8AEC-A6C1D74A7730}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {7C1E8495-E1E4-426D-B28C-E0C0C5824B9C}
24+
EndGlobalSection
25+
EndGlobal
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.IO;
4+
using System.Threading.Tasks;
5+
using PuppeteerSharp;
6+
7+
namespace PuppeteerSharpPdfDemo
8+
{
9+
class MainClass
10+
{
11+
public static void Main(string[] args)
12+
{
13+
MainAsync().GetAwaiter().GetResult();
14+
}
15+
16+
public static async Task MainAsync()
17+
{
18+
var chromiumRevision = 526987;
19+
20+
Console.WriteLine("Downloading chromium");
21+
await Downloader.CreateDefault().DownloadRevisionAsync(chromiumRevision);
22+
23+
Console.WriteLine("Navigating google");
24+
var browser = await Puppeteer.LaunchAsync(new LaunchOptions
25+
{
26+
Headless = true
27+
}, chromiumRevision);
28+
29+
var page = await browser.NewPageAsync();
30+
await page.GoToAsync("http://www.google.com");
31+
32+
Console.WriteLine("Generating PDF");
33+
await page.PdfAsync(Path.Combine(Directory.GetCurrentDirectory(), "google.pdf"));
34+
35+
Console.WriteLine("Export completed");
36+
Console.ReadLine();
37+
}
38+
}
39+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>netcoreapp2.0</TargetFramework>
6+
</PropertyGroup>
7+
8+
<ItemGroup>
9+
<PackageReference Include="PuppeteerSharp" Version="0.1.1" />
10+
</ItemGroup>
11+
12+
</Project>

0 commit comments

Comments
 (0)