Created
December 24, 2017 14:57
-
-
Save jfversluis/c8fb23ffe03ac58c82a33ace6c067700 to your computer and use it in GitHub Desktop.
The iOS custom renderer to enable zooming of the PDF file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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