Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
The iOS custom renderer to enable zooming of the PDF file
using pdfjs.Controls;
using pdfjs.iOS.CustomRenderers;
using UIKit;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;
[assembly: ExportRenderer(typeof(PdfWebView), typeof(PdfWebViewRenderer))]
namespace pdfjs.iOS.CustomRenderers
{
public class PdfWebViewRenderer : WebViewRenderer
{
protected override void OnElementChanged(VisualElementChangedEventArgs e)
{
base.OnElementChanged(e);
if (NativeView != null && e.NewElement != null)
{
var pdfControl = NativeView as UIWebView;
if (pdfControl == null)
return;
pdfControl.ScalesPageToFit = true;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment