Skip to content

The MinZoom Property appears to have no effect on iOS #14

Description

@mattkeene

Setting the MinZoom property appeared to have no effect on iOS. When setting MinZoom="1.0" and FitPolicy="Width", documents were properly full-width on Android and could not be zoomed out any further than full-width, as intended. On iOS however, while the document loads correctly as full-width, I am able to zoom out infinitely. I solved the issue via the platform-specific workaround below using OnRendered(), but did I miss an easier cross-platform setting? Should the iOS handler in MauiNativePdfView wire MinZoom through to PDFKit's native PDFView.MinScaleFactor once it computes and sets the FitPolicy? As a side note, this package is amazing and we have completely eliminated our reliance on PDF.js in a WebView for open-source cross-platform PDF rendering in MAUI; bravo.

XAML

<pdf:PdfView x:Name="pdfView"
             EnableZoom="True"
             MinZoom="1.0"
             EnableSwipe="True"
             EnableLinkNavigation="True"
             EnableAnnotationRendering="True"
             DisplayMode="SinglePageContinuous"
             ScrollOrientation="Vertical"
             FitPolicy="Width"
             PageSpacing="10"
             DocumentLoaded="OnDocumentLoaded"
             Rendered="OnRendered"
             PageChanged="OnPageChanged"
             Error="OnError" />

Code-behind workaround

private void OnRendered(object sender, EventArgs e)
{
#if IOS
    // Rendered fires after FitPolicy.Width has been applied and layout is
    // complete, so ScaleFactor here reliably reflects the fit-to-width scale.
    if (pdfView.Handler?.PlatformView is PdfKit.PdfView nativePdfView)
    {
        nativePdfView.MinScaleFactor = nativePdfView.ScaleFactor;
    }
#endif
}

Metadata

Metadata

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions