So I am trying to create a feature for a mobile app. It needs to be able to display a pdf file in a view and allow a user to place a sizeable picture of his signature on desirable location.
I am working with xamarin.forms and to display a pdf file using this: https://github.com/xamarin/recipes/tree/master/Recipes/xamarin-forms/Controls/display-pdf
Now I need to know what is the best approach for the second part. A user places an image and all I need is to get coordinates of the location and its width.
So far I see two possible ways:
Any suggestions or ideas for a better way to do it?
Thanks
You can add image and signature into webView.ScrollView
, and make some adjustments on its ContentInset
.
Change webView.ScrollView.ContentInset
first.
Add additional view .
Make the webView scroll to the correct location(original anchor).
class MyDelegate: UIWebViewDelegate
{
public override void LoadingFinished(UIWebView webView)
{
webView.ScrollView.ContentInset = new UIEdgeInsets(200, 0, 0, 0);
UIView view = new UIView(frame: new CoreGraphics.CGRect(0, -200, webView.Frame.Width, 200));
UIImageView image = new UIImageView(frame: new CoreGraphics.CGRect(0, 0, webView.Frame.Width, 100));
UILabel label = new UILabel(frame: new CoreGraphics.CGRect(0, 100, webView.Frame.Width, 100));
view.Add(image);
view.Add(label);
webView.ScrollView.AddSubview(view);
webView.ScrollView.ContentOffset = new CoreGraphics.CGPoint(0, -200);
}
}
public class CustomWebViewRenderer : ViewRenderer<CustomWebView, UIWebView>
{
protected override void OnElementChanged (ElementChangedEventArgs<CustomWebView> e)
{
base.OnElementChanged (e);
if (Control == null) {
UIWebView web = new UIWebView();
web.Delegate = new MyDelegate();
SetNativeControl(web);
}
}
//xxxxx
}