MAUI SfPdfViewer scale mode works incorrectly for FitPage in .NET 8 native iOS application.
Hello, I'm migrating my xamarin native iOS application to .NET 8 iOS application (not maui). Before we used Syncfusion.Xamarin.SfPdfViewer.IOS with PageViewMode.PageByPage and all controls disabled. It works well.
Now, since .NET 8 try using Syncfusion.Maui.PdfViewer using guide from https://support.syncfusion.com/kb/article/14332/integrating-net-maui-chart-with-ios-native-embedding-application. However, when use PageLayoutMode.Single and ZoomMode.FitToPage document always try to take all view's width and scrolls to end automatically. With other options document still wants to take all view's width. Using scaleMode FitPage from UI toolbar still not working. If try scalling view programmatically it tries to take full width and can take not all height.
Tried to create sample app, but same issue. But, works ok in maui project. TargetFramework = net8.0-ios;Microsoft.Maui.Controls=8.0.82; Syncfusion.Maui.PdfViewer=27.1.57. FinishLauching method below:
Window = new UIWindow(UIScreen.MainScreen.Bounds); MauiAppBuilder builder = MauiApp.CreateBuilder(); builder.UseMauiEmbedding<Microsoft.Maui.Controls.Application>(); builder.ConfigureSyncfusionCore(); builder.Services.Add(new Microsoft.Extensions.DependencyInjection.ServiceDescriptor(typeof(UIWindow), Window)); MauiApp mauiApp = builder.Build(); _mauiContext = new MauiContext(mauiApp.Services); _viewer = new SfPdfViewer(); _viewer.PageLayoutMode = PageLayoutMode.Single; _viewer.ZoomMode = ZoomMode.FitToPage; var pdfView = _viewer.ToPlatform(_mauiContext); pdfView.Frame = Window.Frame; // create a UIViewController with a single UILabel var vc = new UIViewController(); vc.View.AddSubview(pdfView); Window.RootViewController = vc; // make the window visible Window.MakeKeyAndVisible(); var stream = typeof(AppDelegate).GetTypeInfo().Assembly.GetManifestResourceStream("iOSApp1.Assets.pdf_succinctly.pdf"); _viewer.LoadDocument(stream);
Hi Anvar,
We are unable to reproduce the issue, “When setting fit to page in page by page mode, it is not displayed properly on the iOS platform." Please find the attached sample and recorded video, which have steps we tried to reproduce the issue on our end. Could you please check the video and let us know whether we have missed out on anything while replicating the issue?
Please share the following details also to analyze this issue further and assist you with a better solution:
- PDF that is causing the issue, as it may be specific to that document.
- Device details
- Exact steps to reproduce the issue.
- .NET MAUI Package version (Microsoft.Maui.Compatability and Microsoft.Maui.Control).
- Any other specific information that could help us to replicate this issue.
Regards,
Bharathi S
Attachment: NativeAppIOS_2fbcafbf.zip
Thank you for your answer, have checked attached project. Seems LoadDocument method works differently then setting DocumentSource. However, still incorrect. Have attached project and video.
Details:
- iPad 9 generation iOS 17.7.1 in landscape mode.
- Microsoft.Maui.Controls=8.0.82; Syncfusion.Maui.PdfViewer=27.1.57
- same document from vs code syncfusion extension sample.
- to reproduce run attached project on ipad in landscape.
Attachment: Downloads_77b59155.zip
Hi Anvar,
Thank you for sharing the details. Based on the video provided, we understand that the issue you're referring to is: “When setting the zoom mode to 'Fit to Page' and loading the PDF using the LoadDocument method, the PDF page does not adjust to 'Fit to Page' but instead appears in full width.”
Please confirm if our understanding is correct. If not, kindly provide further clarification and the correct replication steps.
Your confirmation will help us assist you more effectively.
Regards,
Bharathi S
Hello,
you understood me correctly. It's on video "loadDocument.MP4. That was the issue I have created this report for.
P.S. It wasn't my initial issue, but after looking at project provided by you in current thread, I noticed that load document from DocumentSource property have similar problem in same conditions. You can see it on video "documentSource.MP4".
Hi Anvar,
Thank you for the confirmation. We will validate the issue where setting the zoom mode to 'Fit to Page' and loading the PDF using the LoadDocument method causes the PDF page to display in full width instead of fitting to the page, and we’ll provide an update by November 14, 2024.
Regarding the DocumentSource.MP4 video, it shows the PDF loaded correctly in 'Fit to Page' mode. Could you please clarify the exact issue you are highlighting in the video? This will help us assist you more effectively.
Regards,
Bharathi S
Hello,
About DocumentSource.MP4 video. As you can see at video start pdf document not fully visible.(Left image)
At 4th second (right image) you can see pdf have white margins that's a part of document. And they should be visible.
Hi Anvar,
|
Query |
Response |
|
|
you understood me correctly. It's on video "loadDocument.MP4. That was the issue I have created this report for. |
We have validated and resolved the issue “When setting the zoom mode to 'Fit to Page' and loading the PDF using the LoadDocument method, the PDF page does not adjust to 'Fit to Page' but instead appears in full width”, and it is available in the attached custom NuGet package. This fix will be publicly available in our upcoming weekly NuGet release. |
|
|
About DocumentSource.MP4 video. As you can see at video start pdf document not fully visible.(Left image) At 4th second (right image) you can see pdf have white margins that's a part of document. And they should be visible.
|
To display the entire page of a PDF in Single Page Layout Mode within the PDF Viewer in landscape when zoom mode is fit to page. Please refer the below code snippet,
Setting the minimum zoom factor to 0.1 will allow longer pages to fit within the viewer since the zoom factor is 1 as default.
We’ve modified the sample to meet your requirements. Could you please review the updated sample and let us know if you have any further concerns? |
Regards,
Bharathi S
Attachment: CustomNuget27.1.58_194988_b10570af.zip
Hi Anvar,
I have attached the sample in this update due to size constraints.
Regards,
Bharathi S
Attachment: testNativeios_1372c11c.zip
Have tried attached sample, can't see any changes(Video attached). Custom nuget almost same. Scale still broken, by docment at least scrolled to show document start.
It scale pdf ok, only if set MinZoomFactor=0.1 before(not in event like in your sample) LoadDocument call(Works with old nuget too). However, it breaks scaling by double tap. Seems double tap works with integer factors(like 1,2,3). And 1 still can be bigger then zoom factor we need to show document entirely, so last double tap can't return document back to fit screen.
From sycnfusion docs: " Fit-to-page ensures that users can see the entire page content to get a quick overview without having to scroll. "
This control should scale image relatively to current device screen. Can't understand why set MinZoomFactor should be done when control have scale mode that must work by itself. In MAUI everything works ok without set anything additional.
Attachment: RPReplay_Final1732093506_c1e4f94e.zip
Hi Anvar,
Thank you for the update and for sharing the video. We have replicated the issue where setting the zoom mode to "fit to page" in single-page layout mode (landscape) does not display the entire page in the PDF Viewer. We will validate this issue and provide you with the further details.
Regards,
Bharathi S
Hi Anwar,
After further analysis of the reported
issue, here is more information regarding the queries mentioned in your last
update:
Double-Tap Zoom Behavior
When a user double-taps the PDF Viewer, the ZoomMode automatically resets to the Default ZoomMode. As a result, subsequent double-taps do not preserve the previously set zoom percentage. To retain a consistent behavior or return to the FitToPage mode, it is necessary to manually reset the ZoomMode back to FitToPage after a double-tap interaction.
Reason for Setting MinZoomFactor to 0.1
By default, the ZoomFactor is
initialized to 1 on mobile platforms. In landscape mode, when the ZoomMode is
set to FitToPage, the calculated ZoomFactor may become less than 1 (e.g.,
0.56). During this process, the control compares the calculated ZoomFactor with
the defined MinZoomFactor. If the calculated value is smaller than the
MinZoomFactor, the control assigns the MinZoomFactor instead. For this reason,
it is essential to set MinZoomFactor = 0.1 to ensure proper scaling and to
allow the document to fit entirely within the screen dimensions, especially in
landscape mode. In updated Syncfusion.Maui.PdfViewer
version (27.2.5), will show you the entire page in FitToPage mode
within the landscape orientation with
MinZoomFactor set to 0.1.
Regards,
Manikandan M
- 11 Replies
- 3 Participants
-
AH Anvar Hakimov
- Nov 1, 2024 08:29 AM UTC
- Dec 4, 2024 02:32 AM UTC