Files
elwig/Elwig/Helpers/Printing/Pdf.cs
T
lorenz.stechauner ca5b719630
Test / Run tests (push) Successful in 2m48s
Elwig: Add BackupService
2026-08-26 10:39:50 +02:00

41 lines
1.2 KiB
C#

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);
}
}
}
}