using Elwig.Services; using Elwig.Windows; using System; namespace Elwig.Helpers.Printing { public static class Pdf { public static void Init(Action? evtHandler = null) { PdfiumNative.FPDF_InitLibrary(); evtHandler?.Invoke(); } public static void Cleanup() { PdfiumNative.FPDF_DestroyLibrary(); } 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 void 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); } } } }