Skip to content

Instantly share code, notes, and snippets.

@jfversluis
Created December 24, 2017 14:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jfversluis/c8fb23ffe03ac58c82a33ace6c067700 to your computer and use it in GitHub Desktop.
Save jfversluis/c8fb23ffe03ac58c82a33ace6c067700 to your computer and use it in GitHub Desktop.
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