using Elwig.Services; using Elwig.Windows; using System; using System.Threading.Tasks; namespace Elwig.Helpers.Printing { public static class Pdf { public static Task Init(Action? evtHandler = null) { PdfiumNative.FPDF_InitLibrary(); evtHandler?.Invoke(); return Task.CompletedTask; } public static Task Cleanup() { PdfiumNative.FPDF_DestroyLibrary(); return Task.CompletedTask; } public static void Show(TempFile file, string title) { App.MainDispatcher.BeginInvoke(() => { var w = new DocumentViewerWindow(title, file); w.Show(); }); } public static void Show(string path, string title) { App.MainDispatcher.BeginInvoke(() => { var w = new DocumentViewerWindow(title, path); w.Show(); }); } public static Task Print(string path, int copies = 1, bool doublePaged = false) { try { var printer = new PdfPrinter(); printer.Print(path, copies, doublePaged); } catch (Exception exc) { InteractionService.ShowException("Fehler beim Drucken", "Beim Drucken ist ein Fehler aufgetreten", exc); } return Task.CompletedTask; } } }