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 Task 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) await Init(); using var page = await Browser?.NewPageAsync(); await page.GoToAsync("file://" + path_html); await page.WaitForFunctionAsync("() => window.finished"); await page.PdfAsync(path_pdf); } public static void Display(string path) { Process.Start(new ProcessStartInfo() { FileName = path, UseShellExecute = true, }); } } }