Printing: Replace PdfiumViewer with native pdfium.dll binary
All checks were successful
Test / Run tests (push) Successful in 2m52s

This commit is contained in:
2026-02-17 17:21:38 +01:00
parent f1737af2a2
commit 751246537e
5 changed files with 111 additions and 9 deletions

View File

@@ -1,5 +1,4 @@
using Elwig.Windows;
using PdfiumViewer;
using System;
using System.Collections.Generic;
using System.Diagnostics;
@@ -27,6 +26,7 @@ namespace Elwig.Helpers.Printing {
public static bool IsReady => WinziPrintProc != null;
public static async Task Init(Action? evtHandler = null) {
PdfiumNative.FPDF_InitLibrary();
// NOTE: If the WinziPrint daemon is already running this will succeed, but the process will fail.
// Should be no problem, as long as the daemon is not closed
var p = new Process() { StartInfo = new() {
@@ -47,6 +47,7 @@ namespace Elwig.Helpers.Printing {
public static Task Cleanup() {
WinziPrintProc?.Kill(true);
WinziPrintProc?.Close();
PdfiumNative.FPDF_DestroyLibrary();
return Task.CompletedTask;
}
@@ -123,9 +124,9 @@ namespace Elwig.Helpers.Printing {
public static Task Print(string path, PrinterSettings settings) {
try {
using var doc = PdfDocument.Load(path);
using var printDoc = doc.CreatePrintDocument(PdfPrintMode.CutMargin);
printDoc.PrinterSettings = settings;
using var printDoc = new PdfPrintDocument(path) {
PrinterSettings = settings,
};
printDoc.Print();
} catch (Exception e) {
MessageBox.Show("Beim Drucken ist ein Fehler aufgetreten:\n\n" + e.Message, "Fehler beim Drucken", MessageBoxButton.OK, MessageBoxImage.Error);