diff --git a/WGneu/Print/Pdf.cs b/WGneu/Print/Pdf.cs new file mode 100644 index 0000000..9cad37b --- /dev/null +++ b/WGneu/Print/Pdf.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Reflection.Metadata.Ecma335; +using System.Text; +using System.Threading.Tasks; +using PuppeteerSharp; + + +namespace WGneu.Print { + public static class Pdf { + + private static readonly string CHROMIUM = @"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe"; + private static IBrowser? Browser = null; + + public static async void Init() { + Browser = await Puppeteer.LaunchAsync(new LaunchOptions { + Headless = true, + ExecutablePath = CHROMIUM, + }); + } + + public static async Task Convert(string path_html, string path_pdf) { + if (Browser == null) + Init(); + + using var page = await Browser?.NewPageAsync(); + await page.GoToAsync("file://" + path_html); + await page.WaitForFunctionAsync("() => window.finished"); + await page.PdfAsync(path_pdf); + } + } +} diff --git a/WGneu/Print/Template.cs b/WGneu/Print/Template.cs new file mode 100644 index 0000000..4ce9893 --- /dev/null +++ b/WGneu/Print/Template.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace WGneu.Print { + class Template { + + private static readonly string ROOT = @"C:\Users\Lorenz\Desktop\"; + + public static async void Test() { + await Pdf.Convert(ROOT + "din-5008.html", ROOT + "test.pdf"); + Process.Start(new ProcessStartInfo() { + FileName = ROOT + "test.pdf", + UseShellExecute = true, + }); + } + } +} diff --git a/WGneu/Print/TestTemplate.cs b/WGneu/Print/TestTemplate.cs new file mode 100644 index 0000000..142ddc4 --- /dev/null +++ b/WGneu/Print/TestTemplate.cs @@ -0,0 +1,10 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace WGneu.Print { + internal class TestTemplate { + } +} diff --git a/WGneu/Print/TestTemplate.cshtml b/WGneu/Print/TestTemplate.cshtml new file mode 100644 index 0000000..c233872 --- /dev/null +++ b/WGneu/Print/TestTemplate.cshtml @@ -0,0 +1,9 @@ + + + + Test Document + + +

Test Document

+ + \ No newline at end of file diff --git a/WGneu/WGneu.csproj b/WGneu/WGneu.csproj index d227e38..1c297db 100644 --- a/WGneu/WGneu.csproj +++ b/WGneu/WGneu.csproj @@ -8,9 +8,13 @@ + + + + diff --git a/WGneu/Windows/MainWindow.xaml b/WGneu/Windows/MainWindow.xaml index 1b0375c..3ca7167 100644 --- a/WGneu/Windows/MainWindow.xaml +++ b/WGneu/Windows/MainWindow.xaml @@ -18,5 +18,6 @@