diff --git a/LehrerApp.TemplateDesigner.Tests/ProjectLifecycleTests.cs b/LehrerApp.TemplateDesigner.Tests/ProjectLifecycleTests.cs index 593a794..4ca43cf 100644 --- a/LehrerApp.TemplateDesigner.Tests/ProjectLifecycleTests.cs +++ b/LehrerApp.TemplateDesigner.Tests/ProjectLifecycleTests.cs @@ -91,6 +91,15 @@ public sealed class ProjectLifecycleTests Assert.Contains("mehrfach", exception.Message); } + [Fact] + public void AktuelleAnsicht_KannAlsPdfGerendertWerden() + { + var pdf = new DesignerViewModel().RenderCurrentPdf(); + + Assert.True(pdf.Length > 100); + Assert.Equal("%PDF-", System.Text.Encoding.ASCII.GetString(pdf, 0, 5)); + } + private static readonly byte[] OnePixelPng = Convert.FromBase64String( "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII="); } diff --git a/LehrerApp.TemplateDesigner/DesignerViewModel.cs b/LehrerApp.TemplateDesigner/DesignerViewModel.cs index 157577c..4827384 100644 --- a/LehrerApp.TemplateDesigner/DesignerViewModel.cs +++ b/LehrerApp.TemplateDesigner/DesignerViewModel.cs @@ -141,6 +141,9 @@ public partial class DesignerViewModel : ObservableObject public ITemplateDataProvider BuildDataProvider() => new DesignerDataProvider(Placeholders.ToDictionary( x => x.Name.Trim(), x => x.ToValue(), StringComparer.Ordinal)); + public byte[] RenderCurrentPdf() => + new QuestTemplateRenderer().RenderToPdf(BuildLoaded(), BuildDataProvider()); + public void ApplyPdfImport(PdfImportResult import) { TemplateId = import.Manifest.Id; TemplateName = import.Manifest.Name; Description = import.Manifest.Description; diff --git a/LehrerApp.TemplateDesigner/MainWindow.axaml b/LehrerApp.TemplateDesigner/MainWindow.axaml index 633580b..df3b324 100644 --- a/LehrerApp.TemplateDesigner/MainWindow.axaml +++ b/LehrerApp.TemplateDesigner/MainWindow.axaml @@ -10,6 +10,7 @@ + @@ -204,8 +205,9 @@ - -