@@ -37,6 +37,9 @@ public partial class PdfReader
3737 private bool _isFitToPage ;
3838 private uint _currentPage ;
3939 private string ? _url ;
40+ private string ? _currentScale ;
41+
42+ private readonly HashSet < string > AllowedScaleValues = [ "page-actual" , "page-width" , "page-height" , "page-fit" , "auto" ] ;
4043
4144 private string CurrentPageString
4245 {
@@ -52,6 +55,33 @@ private void SetCurrentPage(string value)
5255 }
5356 }
5457
58+ private string CurrentScaleString
59+ {
60+ get => $ "{ Options . CurrentScale ?? "100" } %";
61+ set => SetCurrentScale ( value ) ;
62+ }
63+
64+ private void SetCurrentScale ( string value )
65+ {
66+ if ( string . IsNullOrEmpty ( value ) )
67+ {
68+ Options . CurrentScale = "100" ;
69+ }
70+ else if ( float . TryParse ( value . TrimEnd ( "%" ) , out var v ) )
71+ {
72+ if ( v > 500 )
73+ {
74+ v = 500 ;
75+ }
76+ else if ( v < 25 )
77+ {
78+ v = 25 ;
79+ }
80+
81+ Options . CurrentScale = v . ToString ( CultureInfo . InvariantCulture ) ;
82+ }
83+ }
84+
5585 /// <summary>
5686 /// <inheritdoc/>
5787 /// </summary>
@@ -82,6 +112,7 @@ protected override async Task OnAfterRenderAsync(bool firstRender)
82112 _isFitToPage = Options . IsFitToPage ;
83113 _currentPage = Options . CurrentPage ;
84114 _url = Options . Url ;
115+ _currentScale = Options . CurrentScale ;
85116 }
86117
87118 if ( _url != Options . Url )
@@ -100,6 +131,11 @@ protected override async Task OnAfterRenderAsync(bool firstRender)
100131 _currentPage = Options . CurrentPage ;
101132 await NavigateToPageAsync ( _currentPage ) ;
102133 }
134+ if ( _currentScale != Options . CurrentScale )
135+ {
136+ _currentScale = Options . CurrentScale ;
137+ await InvokeVoidAsync ( "scale" , Id , _currentScale ) ;
138+ }
103139 }
104140
105141 /// <summary>
0 commit comments