From 957c66d0c62d03bdf33c938d6272ec7cd9876948 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wies=C5=82aw=20=C5=A0olt=C3=A9s?= Date: Sun, 20 Jul 2025 10:51:45 +0200 Subject: [PATCH] Add PDF and EPS export --- samples/AvalonDraw/MainWindow.axaml | 2 ++ samples/AvalonDraw/MainWindow.axaml.cs | 38 ++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/samples/AvalonDraw/MainWindow.axaml b/samples/AvalonDraw/MainWindow.axaml index 854ef0d77a..68852f784f 100644 --- a/samples/AvalonDraw/MainWindow.axaml +++ b/samples/AvalonDraw/MainWindow.axaml @@ -43,6 +43,8 @@ + + diff --git a/samples/AvalonDraw/MainWindow.axaml.cs b/samples/AvalonDraw/MainWindow.axaml.cs index 92803cb2f1..ed3e02ede7 100644 --- a/samples/AvalonDraw/MainWindow.axaml.cs +++ b/samples/AvalonDraw/MainWindow.axaml.cs @@ -514,6 +514,44 @@ private async void ExportElementMenuItem_Click(object? sender, RoutedEventArgs e SK.SKColorType.Rgba8888, SK.SKAlphaType.Premul, SvgView.SkSvg.Settings.Srgb); } + private async void ExportPdfMenuItem_Click(object? sender, RoutedEventArgs e) + { + if (_document is null || SvgView.SkSvg?.Picture is null) + return; + var dialog = new SaveFileDialog + { + Filters = new() + { + new FileDialogFilter { Name = "PDF", Extensions = { "pdf" } }, + new FileDialogFilter { Name = "All", Extensions = { "*" } } + }, + DefaultExtension = "pdf", + }; + var path = await dialog.ShowAsync(this); + if (string.IsNullOrEmpty(path)) + return; + SvgView.SkSvg.Picture.ToPdf(path, SK.SKColors.Transparent, 1f, 1f); + } + + private async void ExportEpsMenuItem_Click(object? sender, RoutedEventArgs e) + { + if (_document is null || SvgView.SkSvg?.Picture is null) + return; + var dialog = new SaveFileDialog + { + Filters = new() + { + new FileDialogFilter { Name = "EPS", Extensions = { "eps" } }, + new FileDialogFilter { Name = "All", Extensions = { "*" } } + }, + DefaultExtension = "eps", + }; + var path = await dialog.ShowAsync(this); + if (string.IsNullOrEmpty(path)) + return; + SvgView.SkSvg.Picture.ToXps(path, SK.SKColors.Transparent, 1f, 1f); + } + private async void PlaceImageMenuItem_Click(object? sender, RoutedEventArgs e) { if (_document is null)