From ea375a9ce65bf676cc621db569b582cc484eb8a6 Mon Sep 17 00:00:00 2001 From: CJKmkp <2564608840@qq.com> Date: Sun, 5 Apr 2026 18:36:47 +0800 Subject: [PATCH] =?UTF-8?q?add:pdf=E6=8F=92=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Ink Canvas/Controls/PdfEmbeddedView.cs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Ink Canvas/Controls/PdfEmbeddedView.cs b/Ink Canvas/Controls/PdfEmbeddedView.cs index c6bbb9f2..6c4d21f7 100644 --- a/Ink Canvas/Controls/PdfEmbeddedView.cs +++ b/Ink Canvas/Controls/PdfEmbeddedView.cs @@ -20,6 +20,7 @@ namespace Ink_Canvas.Controls private uint _currentIndex; private bool _compressLargePictures; private bool _isPagingBusy; + private bool _layoutSizeCommitted; /// 页码或可翻页状态变化(用于更新侧栏)。 public event EventHandler PageNavigationStateChanged; @@ -107,9 +108,17 @@ namespace Ink_Canvas.Controls BitmapSource display = ApplyCompressionIfNeeded(raw); _pageImage.Source = display; - // 每页尺寸可能不同,与图片一致按当前页位图更新布局,避免翻页后内容被裁切或“消失” - Width = display.PixelWidth; - Height = display.PixelHeight; + if (!_layoutSizeCommitted) + { + bool callerSized = !double.IsNaN(Width) && Width > 0 && !double.IsNaN(Height) && Height > 0; + if (!callerSized) + { + Width = display.PixelWidth; + Height = display.PixelHeight; + } + + _layoutSizeCommitted = true; + } } finally {