diff --git a/MainWindow.axaml.cs b/MainWindow.axaml.cs index 2a777e5..40fc428 100644 --- a/MainWindow.axaml.cs +++ b/MainWindow.axaml.cs @@ -774,32 +774,51 @@ public partial class MainWindow : Window private async void BtnStartGenerateLabels_OnClick(object? sender, RoutedEventArgs e) { - SavePdfExportOptions(); - - var saveDialog = new SaveFileDialog + try { - DefaultExtension = "pdf", - Filters = { new FileDialogFilter { Name = "PDF-Dateien", Extensions = { "pdf" } } } - }; - - // hier nach winpafd prüfen - var filePath = await saveDialog.ShowAsync(this); + SavePdfExportOptions(); - if (!string.IsNullOrWhiteSpace(filePath)) - { - if (filePath.StartsWith("file://")) + var saveDialog = new SaveFileDialog { - filePath = new Uri(filePath).LocalPath; - } - Console.WriteLine(filePath); - - var builder = new PdfBuilder(Settings._instance.pdfExport); + DefaultExtension = "pdf", + Filters = + { + new FileDialogFilter + { + Name = "PDF-Dateien", + Extensions = { "pdf" } + } + } + }; - builder.CreateAddressLabelPdfFromAddressSetWithPlaceholder( - ((KasAddressList)LstCustomerAdressSets.SelectedItem).ID, - "Company Logo/Info", - filePath - ); + var filePath = await saveDialog.ShowAsync(this); + + Console.WriteLine($"RAW: {filePath}"); + + if (!string.IsNullOrWhiteSpace(filePath)) + { + if (filePath.StartsWith("file://")) + { + filePath = new Uri(filePath).LocalPath; + } + + Console.WriteLine($"PATH: {filePath}"); + + var builder = new PdfBuilder(Settings._instance.pdfExport); + + builder.CreateAddressLabelPdfFromAddressSetWithPlaceholder( + ((KasAddressList)LstCustomerAdressSets.SelectedItem).ID, + "Company Logo/Info", + filePath + ); + + Console.WriteLine("PDF OK"); + } + } + catch (Exception ex) + { + Console.WriteLine(ex); + File.WriteAllText("crash.txt", ex.ToString()); } }