Working with PDFView and Pinch Zoom in Xamarin Forms

.
August 18, 2023
Programming Tips

Xamarin.Forms code runs on multiple platforms like Android, iOS, UWP, and each of them has its own file system. Using native APIs, we can do reading or writing files easily. Embedded resources are a simple solution for distributing data files with the application. In Xamarin.Forms there is no support or any feature for generating or viewing PDF files. We can achieve requirements such as view or generate PDF using native Support with the help of renderer for both Android and iOS platforms.

However, you can also check how to generate PDF file from HTML string to empower your knowledge base on this topic.

Now talking about PDFView, it is a big problem in Android web view. To solve this problem, we can use google driver viewer and google doc viewer. We can also view PDF files using the pdfjs library through native support. We have to download the pdfjs file and put the folder in android and iOS platform projects. In the android platform put a folder inside Android Asset and in iOS put it inside the Resources folder. But the problem is that pdfjs does not support pinch zoom.

Let's create an application that is working with PDFView and pinch zoom. Create a new Project with Android and iOS platforms, choose mobile app project from mobile. Give appropriate names to the application and then select the blank app and platform - Android, iOS, UWP. If you are having a hard time doing this, then you can always hire a developer.

Now create a new class file in the shared project for custom WebView. In this class inherit WebView for custom rendering and then add bindable properties. We are going to create two bindable properties uriProperty and isPDFProperty.

PdfViewRenderercs.cs file (For custom Webview)

using Xamarin.Forms;




namespace PdfView

{

   public class PdfViewRenderercs:WebView

   {

       public static readonly BindableProperty uriProperty = BindableProperty.Create(

         propertyName: "URI",

        returnType: typeof(string ),

        declaringType: typeof(PdfViewRenderercs),

        defaultValue: default(string)

);




       public string URI

       {

           get { return (string)GetValue(uriProperty); }

           set { SetValue(uriProperty, value); }

       }

       public static readonly BindableProperty isPDFProperty = BindableProperty.Create(

           propertyName: "IsPdf ",

           returnType: typeof(bool ),

           declaringType: typeof(PdfViewRenderercs ),

           defaultValue: default(bool)

           );

       public bool IsPdf

       {

           get { return (bool)GetValu(isPDFProperty);

}

           set { SetValue ( isPDFProperty, value ) ;

}

       }

   }

}

Now, we will implement a custom renderer in the Android platform. In Android, webview is not supported so we are going to use Google Driver Viewer to view the PDF. Note that the URL must be public and with extension .PDF

Use https://drive.google.com/viewerng/viewer?embedded=true&url=" + " url”;

or

https://docs.google.com/gview?embedded=true&url=" + " url" ;

Here, we have inherited the WebViewRenderer from renderer and created OnElementChange method and set url.

using Android.Content;

using PdfView;

using PdfView.Droid;

using Xamarin.Forms;

using Xamarin.Forms.Platform.Android;

[assembly: ExportRenderer(typeof( PdfViewRenderercs ), typeof( WebViewRendererAndroid ) ) ]

namespace PdfView.Droid

{

   public class WebViewRendererAndroid : WebViewRenderer

   {

       public WebViewRendererAndroid( Context context) : base( context)

       {

       }

       protected override void OnElementChanged( ElementChangedEventArgs<WebView> e )

       {

           base.OnElementChanged( e ) ;




           if (e.NewElement != null)

           {

               var pdfview = Element as PdfViewRenderercs ;

               Control.Settings.AllowUniversalAccessFromFileURLs = true ;

               If ( pdfview.IsPdf )

               {

                   var Url = "https://drive.google.com/viewerng/viewer?embedded=true&url=" + pdfview.URI;

                   Control.LoadUrl(Url) ;

               }

               else

               {

                   Control.LoadUrl( pdfview.URI) ;

               }

           }

       }

   }

}


MainPage Xamal file

<ContentPage xmlns= "http://xamarin.com/schemas/2014/forms"

            xmlns:x= "http://schemas.microsoft.com/winfx/2009/xaml"

            x:Class= "PdfView.MainPage">




   <StackLayout>

       <Button Text="Pdf" Clicked="pdf_button" />

   </StackLayout>




</ContentPage>





This is an implementation of the iOS platform, we have done the same things as we have implemented in the android platform:

using System;

using PdfView;

using PdfView.iOS;

using UIKit;

using Xamarin.Forms;

using Xamarin.Forms.Platform.iOS;




#pragma warning disable CS0612 // Type or member is obsolete

[assembly: ExportRenderer(typeof( PdfViewRenderercs ), typeof(PDFViewRendererios ))]

#pragma warning restore CS0612 // Type or member is obsolete

namespace PdfView.iOS

{

   [Obsolete]

   public class PDFViewRendererios: WebViewRenderer

   {

       protected override void OnElementChanged(VisualElementChangedEventArgs e )

       {

           base.OnElementChanged (e);




           if (NativeView != null && e.NewElement != null )

           {

               var pdfControl1 = NativeView as UIWebView ;




               if (pdfControl1 == null)

                   return;




               pdfControl1.ScalesPageToFit = true ;

           }

       }

}

}

MainPage code-behind file

using Xamarin.Forms;

namespace PdfView

{

   public partial class MainPage : ContentPage

   {

       public MainPage()

       {

           InitializeComponent();

       }




       private async void pdf_button(object sender, EventArgs e)

       {

           await Navigation.PushModalAsync(new Page1() ) ;

       }

   }

}


Now, Implementing custom web view in XAML. First of all we have to add a namespace like this xmlns:Renderes="clr-namespace:PdfView" and then add custom web view. <Renderes:PdfViewRenderercs> </Renderes:PdfViewRenderercs>

Page1.Xaml

<ContentPage xmlns ="http://xamarin.com/schemas/2014/forms"

            xmlns:x ="http://schemas.microsoft.com/winfx/2009/xaml"

            xmlns:Renderes  ="clr-namespace:PdfView"

            x:Class ="PdfView.Page1">

   <ContentPage.Content>

       <Renderes:PdfViewRenderercs

           x:Name= " pdfviewpg1 "

           IsPdf=" True "

           VerticalOptions="FillAndExpand"

           HorizontalOptions="FillAndExpand">

       </Renderes:PdfViewRenderercs>

</ContentPage.Content>

</ContentPage>

Page1.Xaml.cs file

using Xamarin.Forms;

using Xamarin.Forms.PlatformConfiguration;

using Xamarin.Forms.PlatformConfiguration.AndroidSpecific;

using Xamarin.Forms.Xaml;




namespace PdfView

{

   [XamlCompilation(XamlCompilationOptions.Compile )]

   public partial class Page1 : ContentPage

   {

       string url1 = "http://media.wuerth.com/stmedia/shop/catalogpages/LANG_it/1637048.pdf" ;

       public Page1 ()

       {

           InitializeComponent ();

           if (Device.RuntimePlatform = = Device.Android )

           {

               pdfviewpg1.URI = url1 ;

               pdfviewpg1.On<Android>().EnableZoomControls(true) ;

               pdfviewpg1.On<Android>().DisplayZoomControls(false) ;

           }

           else

           {

               pdfviewpg1.Source = url1 ;

           }

       }

}

}


To test pinch-zoom in the emulator use Control + Shift + Left Click and move the mouse. Here, we have created one Xamarin.Forms application working with PDFView and pinch zoom. We have created a custom WebView using renderer and create bindable properties in custom Webview. After that, we have implemented a custom renderer in the Android project, and in that file, we have inherited WebviewRenderer. At last, we have implemented a custom renderer in our XAML file, in XAML file we have added a namespace and a custom webview.

Conclusion

In Xamarin.Forms there is no support for PDFView. We have to achieve this by using native support through custom renderers. We can view pdf files using the pdfjs library but the problem is that it does not support pinch-zoom functionality. PDFView is a big problem in android webview, to solve this problem we can use Google driver Viewer or Google doc viewer, and custom renderers. In this blog, we have created a simple app working with PDFView and pinch-zoom in which we have displayed one PDF file using google driver viewer with the help of a custom webview renderer. We have created a renderer file in the shared project and inherit webview and created bindable properties. And, in the Android project, we have created a class file for custom renderer and inherited webview renderer after that use a custom webview renderer in our XAML file by adding namespace and custom webview. We have also seen how to use pinch-zoom in the emulator.

Author
Chief Technology Officer
Work with world leading tech companies from the Philippines
Submit CV

One of our recruitment officers will get in touch with you today!

If you’re interested to know more about our employee benefits and perks, you can download the booklet.

Download now

Head of Marketing

Cloud Employee is building a ‘Future of Work’ AI driven talent tech platform in the remote software engineer staffing space. 

In this strategic and hands-on creative role, you'll have the opportunity to shape the narrative of remote work and impact the tech industry at a global scale. 

With team members across the US, LATAM, Europe and Asia - we’re on a mission to bridge the talent gap with our matching platform and employee experience programs.

We need your storytelling strategy skills to ‘share the journey’ and the human stories behind our business

POST DATE
May 1, 2024
WORK LOCATION
Remotely
JOB TYPE
Full Time
Apply

Strategy & Operations Manager

Cloud Employee, is a UK-owned Philippines business established 8 years ago. We connect high-performing software engineer talent in the Philippines with some of the world’s leading and most innovative tech companies. Developers join to work from the Philippines as part of international engineer teams and grow their CV and skill-set.

We pride ourselves on being supportive and cutting-edge work that continuously invests in staff development, engagement and well-being. We provide security, and career paths, along with individual training programs and mentoring.

POST DATE
WORK LOCATION
Remotely
JOB TYPE
Full Time
Apply

Software QA Test Engineer

Cloud Employee, is a UK owned Philippines business established 8 years ago. We connect high-performing software engineer talent in the Philippines with some of the world’s leading and most innovative tech companies. Developers join to work from the Philippines as part of international engineer teams and grow their CV and skill-set.

We pride ourselves on being a supportive and cutting edge workplace continuously investing in staff development, engagement and well-being. We provide security, career paths, along with individual training programs and mentoring.

POST DATE
WORK LOCATION
Remotely
JOB TYPE
Full Time
Apply

Senior/Team Lead Full-Stack PHP Developer

Cloud Employee is a fast-growing UK-managed offshore recruitment and staffing company in the Philippines. We tackle the growing global IT skills shortage by connecting tech companies based in Europe, the US, and Australia to our pool of expert software developers in the country.

We are now seeking a passionate Senior/Team Lead Full-Stack PHP Developer to join our team of skilled talents. This is an excellent opportunity to join a fun and dynamic work environment and to significantly advance your career.

POST DATE
WORK LOCATION
Remotely
JOB TYPE
Full Time
Apply

Senior/Lead Backend Developer - Brazil

Cloud Employee is a UK-owned business established 8 years ago. We connect high-performing software engineer talent worldwide with some of the world’s leading and most innovative tech companies. Developers join to work from the Philippines and Brazil as part of international engineer teams and grow their CV and skill-set.

We pride ourselves on being a supportive and cutting edge workplace continuously investing in staff development, engagement and well-being. We provide security, career paths, along with individual training programs and mentoring.

POST DATE
WORK LOCATION
Remotely
JOB TYPE
Full Time
Apply

Senior/Lead Backend Developer

Cloud Employee, is a UK-owned Philippines business established 8 years ago. We connect high-performing software engineer talent in the Philippines with some of the world’s leading and most innovative tech companies. Developers join to work from the Philippines as part of international engineer teams and grow their CV and skill-set.

We pride ourselves on being supportive and cutting-edge work that continuously invests in staff development, engagement and well-being. We provide security, and career paths, along with individual training programs and mentoring.

POST DATE
WORK LOCATION
Remotely
JOB TYPE
Full Time
Apply

Senior UI Developer with Umbraco

Cloud Employee, is a UK-owned Philippines business established 8 years ago. We connect high-performing software engineer talent in the Philippines with some of the world’s leading and most innovative tech companies. Developers join to work from the Philippines as part of international engineer teams and grow their CV and skill-set.

We pride ourselves on being supportive and cutting-edge work that continuously invests in staff development, engagement and well-being. We provide security, and career paths, along with individual training programs and mentoring.

POST DATE
WORK LOCATION
Remotely
JOB TYPE
Full Time
Apply

Senior Software Engineer (VB6)

Cloud Employee is a UK-owned Philippines business established 8 years ago. We connect high-performing software engineer talent in the Philippines with some of the world’s leading and most innovative tech companies. Developers join to work from the Philippines as part of international engineering teams and grow their CV and skill-set.

We pride ourselves on being supportive and cutting-edge work that continuously invests in staff development, engagement, and well-being. We provide security, career paths, individual training programs, and mentoring.

POST DATE
WORK LOCATION
Remotely
JOB TYPE
Full Time
Apply

Senior Python Developer

Cloud Employee, is a UK owned Philippines business established 8 years ago. We connect high-performing software engineer talent in the Philippines with some of the world’s leading and most innovative tech companies. Developers join to work from the Philippines as part of international engineer teams and grow their CV and skill-set.

We pride ourselves on being a supportive and cutting edge workplace continuously investing in staff development, engagement and well-being. We provide security, career paths, along with individual training programs and mentoring.

POST DATE
WORK LOCATION
Remotely
JOB TYPE
Full Time
Apply

Senior /Lead Fullstack Developer - Brazil

Cloud Employee is a UK-owned business established 8 years ago. We connect high-performing software engineer talent worldwide with some of the world’s leading and most innovative tech companies. Developers join to work from the Philippines and Brazil as part of international engineer teams and grow their CV and skill-set.

We pride ourselves on being a supportive and cutting edge workplace continuously investing in staff development, engagement and well-being. We provide security, career paths, along with individual training programs and mentoring.

POST DATE
WORK LOCATION
Remotely
JOB TYPE
Full Time
Apply

Senior Integrations Developer

Cloud Employee, is a UK-owned Philippines business established 8 years ago. We connect high-performing software engineer talent in the Philippines with some of the world’s leading and most innovative tech companies. Developers join to work from the Philippines as part of international engineer teams and grow their CV and skill-set.

We pride ourselves on being supportive and cutting-edge work that continuously invests in staff development, engagement and well-being. We provide security, and career paths, along with individual training programs and mentoring.

POST DATE
WORK LOCATION
Remotely
JOB TYPE
Full Time
Apply

Senior Integration Backend Developer

Cloud Employee, is a UK-owned Philippines business established 8 years ago. We connect high-performing software engineer talent in the Philippines with some of the world’s leading and most innovative tech companies. Developers join to work from the Philippines as part of international engineer teams and grow their CV and skill-set.

We pride ourselves on being supportive and cutting-edge work that continuously invests in staff development, engagement and well-being. We provide security, and career paths, along with individual training programs and mentoring.

POST DATE
WORK LOCATION
Remotely
JOB TYPE
Full Time
Apply

Senior Fullstack Python Developer with React

Cloud Employee, is a UK-owned Philippines business established 8 years ago. We connect high-performing software engineer talent in the Philippines with some of the world’s leading and most innovative tech companies. Developers join to work from the Philippines as part of international engineer teams and grow their CV and skill-set.

We pride ourselves on being supportive and cutting-edge work that continuously invests in staff development, engagement and well-being. We provide security, and career paths, along with individual training programs and mentoring.

POST DATE
WORK LOCATION
Remotely
JOB TYPE
Full Time
Apply

Senior Fullstack PHP Laravel Developer

Cloud Employee, is a UK-owned Philippines business established 8 years ago. We connect high-performing software engineer talent in the Philippines with some of the world’s leading and most innovative tech companies. Developers join to work from the Philippines as part of international engineer teams and grow their CV and skill-set.

We pride ourselves on being supportive and cutting-edge work that continuously invests in staff development, engagement and well-being. We provide security, and career paths, along with individual training programs and mentoring.

POST DATE
WORK LOCATION
Remotely
JOB TYPE
Full Time
Apply

Senior Fullstack Engineer

Cloud Employee, is a UK-owned Philippines business established 8 years ago. We connect high-performing software engineer talent in the Philippines with some of the world’s leading and most innovative tech companies. Developers join to work from the Philippines as part of international engineer teams and grow their CV and skill-set.

We pride ourselves on being supportive and cutting-edge work that continuously invests in staff development, engagement and well-being. We provide security, and career paths, along with individual training programs and mentoring.

POST DATE
WORK LOCATION
Remotely
JOB TYPE
Full Time
Apply

Senior Frontend Developer (React)

Cloud Employee, is a UK-owned Philippines business established 8 years ago. We connect high-performing software engineer talent in the Philippines with some of the world’s leading and most innovative tech companies. Developers join to work from the Philippines as part of international engineer teams and grow their CV and skill-set.

We pride ourselves on being supportive and cutting-edge work that continuously invests in staff development, engagement and well-being. We provide security, and career paths, along with individual training programs and mentoring.

POST DATE
WORK LOCATION
Remotely
JOB TYPE
Full Time
Apply

Senior NET Developer

Cloud Employee, is a UK-owned Philippines business established 8 years ago. We connect high-performing software engineer talent in the Philippines with some of the world’s leading and most innovative tech companies. Developers join to work from the Philippines as part of international engineer teams and grow their CV and skill-set.

We pride ourselves on being supportive and cutting-edge work that continuously invests in staff development, engagement and well-being. We provide security, and career paths, along with individual training programs and mentoring.

POST DATE
WORK LOCATION
Remotely
JOB TYPE
Full Time
Apply

Senior DevOps Engineer

Cloud Employee, is a UK owned Philippines business established 8 years ago. We connect high-performing software engineer talent in the Philippines with some of the world’s leading and most innovative tech companies. Developers join to work from the Philippines as part of international engineer teams and grow their CV and skill-set.

We pride ourselves on being a supportive and cutting edge workplace continuously investing in staff development, engagement and well-being. We provide security, career paths, along with individual training programs and mentoring.

Our Client

A leading UK-company that specializes in providing foreign currencies solutions

POST DATE
WORK LOCATION
Remotely
JOB TYPE
Full Time
Apply

Robotics Software Engineer

Cloud Employee, is a UK-owned Philippines business established 8 years ago. We connect high-performing software engineer talent in the Philippines with some of the world’s leading and most innovative tech companies. Developers join to work from the Philippines as part of international engineer teams and grow their CV and skill-set.

We pride ourselves on being supportive and cutting-edge work that continuously invests in staff development, engagement and well-being. We provide security, and career paths, along with individual training programs and mentoring.

A completely integrated innovation studio within the corporate framework, with a primary emphasis on making the future of the food industry accessible to all. Their core objective is to discover, create, and expand tailored automation remedies, utilizing a team of proficient individuals covering domains like engineering, robotics, and artificial intelligence. Our central mission revolves around constructing automation technology solutions that empower individuals to achieve greater feats.

Position Summary

In your role as a Robotics Software Engineer, your expertise in Robotic Software Engineering will be the key to your success. Collaborating with our skilled team, you'll play a pivotal role in advancing our cutting-edge product development accelerator. Your responsibilities will involve crafting, programming, and evaluating top-notch software essential for ensuring the dependable and secure operations of commercial robots.

POST DATE
WORK LOCATION
Remotely
JOB TYPE
Full Time
Apply

Senior Python Developer

Cloud Employee, is a UK-owned Philippines business established 8 years ago. We connect high-performing software engineer talent in the Philippines with some of the world’s leading and most innovative tech companies. Developers join to work from the Philippines as part of international engineer teams and grow their CV and skill-set.

We pride ourselves on being supportive and cutting-edge work that continuously invests in staff development, engagement and well-being. We provide security, and career paths, along with individual training programs and mentoring.

POST DATE
WORK LOCATION
Remotely
JOB TYPE
Full Time
Apply

Python Developer (Senior Level)

Cloud Employee, is a UK-owned Philippines business established 8 years ago. We connect high-performing software engineer talent in the Philippines with some of the world’s leading and most innovative tech companies. Developers join to work from the Philippines as part of international engineer teams and grow their CV and skill-set.

We pride ourselves on being supportive and cutting-edge work that continuously invests in staff development, engagement and well-being. We provide security, and career paths, along with individual training programs and mentoring.

POST DATE
WORK LOCATION
JOB TYPE
Apply

Python Developer

Cloud Employee, is a UK-owned Philippines business established 8 years ago. We connect high-performing software engineer talent in the Philippines with some of the world’s leading and most innovative tech companies. Developers join to work from the Philippines as part of international engineer teams and grow their CV and skill-set.

We pride ourselves on being supportive and cutting-edge work that continuously invests in staff development, engagement and well-being. We provide security, and career paths, along with individual training programs and mentoring.

POST DATE
WORK LOCATION
Remotely
JOB TYPE
Full Time
Apply

Perl Developer

Cloud Employee, is a UK-owned Philippines business established 8 years ago. We connect high-performing software engineer talent in the Philippines with some of the world’s leading and most innovative tech companies. Developers join to work from the Philippines as part of international engineer teams and grow their CV and skill-set.

We pride ourselves on being supportive and cutting-edge work that continuously invests in staff development, engagement and well-being. We provide security, and career paths, along with individual training programs and mentoring.

POST DATE
WORK LOCATION
Remotely
JOB TYPE
Full Time
Apply

Mid-Senior Mechanical Engineer

Cloud Employee, is a UK-owned Philippines business established 8 years ago. We connect high-performing software engineer talent in the Philippines with some of the world’s leading and most innovative tech companies. Developers join to work from the Philippines as part of international engineer teams and grow their CV and skill-set.

We pride ourselves on being supportive and cutting-edge work that continuously invests in staff development, engagement and well-being. We provide security, and career paths, along with individual training programs and mentoring.

A completely integrated innovation studio within the corporate framework, with a primary emphasis on making the future of the food industry accessible to all. Their core objective is to discover, create, and expand tailored automation remedies, utilizing a team of proficient individuals covering domains like engineering, robotics, and artificial intelligence. Our central mission revolves around constructing automation technology solutions that empower individuals to achieve greater feats.

Position Summary

The position of Mechanical Engineer corresponds to a mid-level role. An ideal candidate for this position possesses robust practical expertise in various technical systems. The responsibilities encompass a combination of individual input within projects and actively leading teams towards achieving a remarkable standard of technical proficiency.

POST DATE
WORK LOCATION
Remotely
JOB TYPE
Full Time
Apply

Mid-Senior Industrial Design Engineer

Cloud Employee, is a UK-owned Philippines business established 8 years ago. We connect high-performing software engineer talent in the Philippines with some of the world’s leading and most innovative tech companies. Developers join to work from the Philippines as part of international engineer teams and grow their CV and skill-set.

We pride ourselves on being supportive and cutting-edge work that continuously invests in staff development, engagement and well-being. We provide security, and career paths, along with individual training programs and mentoring.

A completely integrated innovation studio within the corporate framework, with a primary emphasis on making the future of the food industry accessible to all. Their core objective is to discover, create, and expand tailored automation remedies, utilizing a team of proficient individuals covering domains like engineering, robotics, and artificial intelligence. Our central mission revolves around constructing automation technology solutions that empower individuals to achieve greater feats.

Position Summary

In the role of an Industrial Design Engineer with a focus on cobotics, you will assume a crucial position in envisioning, crafting, and honing both the tangible and operational facets of our collaborative robotic solutions. Your collaboration will extend to cross-functional groups, including mechanical engineers, software developers, and UX designers, in the pursuit of devising cobotic systems centered around users. These systems will redefine effectiveness and safety within industrial settings.

POST DATE
WORK LOCATION
JOB TYPE
Apply

Backend Python Developer

Cloud Employee, is a UK owned Philippines business established 8 years ago. We connect high-performing software engineer talent in the Philippines with some of the world’s leading and most innovative tech companies. Developers join to work from the Philippines as part of international engineer teams and grow their CV and skill-set.

We pride ourselves on being a supportive and cutting edge workplace continuously investing in staff development, engagement and well-being. We provide security, career paths, along with individual training programs and mentoring.

A top rated and state of the art cloud based video interviewing solutions company based in the UK catering to over 5000 prominent companies around the world such as Samsung, Uber, Boohoo, Coinbase, 7-Eleven and many more.

POST DATE
WORK LOCATION
Remotely
JOB TYPE
Full Time
Apply

CNC Machinist

Cloud Employee, is a UK-owned Philippines business established 8 years ago. We connect high-performing software engineer talent in the Philippines with some of the world’s leading and most innovative tech companies. Developers join to work from the Philippines as part of international engineer teams and grow their CV and skill-set.

We pride ourselves on being supportive and cutting-edge work that continuously invests in staff development, engagement and well-being. We provide security, and career paths, along with individual training programs and mentoring.

POST DATE
WORK LOCATION
Remotely
JOB TYPE
Full Time
Apply

CRM Data Specialist (MS Dynamics 365)

Cloud Employee, is a UK-owned Philippines business established 8 years ago. We connect high-performing software engineer talent in the Philippines with some of the world’s leading and most innovative tech companies. Developers join to work from the Philippines as part of international engineer teams and grow their CV and skill-set.

We pride ourselves on being supportive and cutting-edge work that continuously invests in staff development, engagement and well-being. We provide security, and career paths, along with individual training programs and mentoring.

POST DATE
WORK LOCATION
Remotely
JOB TYPE
Full Time
Apply

Electrical Engineer

Cloud Employee, is a UK-owned Philippines business established 8 years ago. We connect high-performing software engineer talent in the Philippines with some of the world’s leading and most innovative tech companies. Developers join to work from the Philippines as part of international engineer teams and grow their CV and skill-set.

We pride ourselves on being supportive and cutting-edge work that continuously invests in staff development, engagement and well-being. We provide security, and career paths, along with individual training programs and mentoring.

A completely integrated innovation studio within the corporate framework, with a primary emphasis on making the future of the food industry accessible to all. Their core objective is to discover, create, and expand tailored automation remedies, utilizing a team of proficient individuals covering domains like engineering, robotics, and artificial intelligence. Our central mission revolves around constructing automation technology solutions that empower individuals to achieve greater feats.

Position Overview

In the role of an Electrical Engineer, your expertise and proficiency in designing electrical-mechanical systems will be a key asset, enabling you to stand out. Collaborating with our skilled team, you will play a vital role in expediting product development processes.

POST DATE
WORK LOCATION
Remotely
JOB TYPE
Full Time
Apply

Front-End Developer

Cloud Employee, is a UK-owned Philippines business established 8 years ago. We connect high-performing software engineer talent in the Philippines with some of the world’s leading and most innovative tech companies. Developers join to work from the Philippines as part of international engineer teams and grow their CV and skill-set.

We pride ourselves on being supportive and cutting-edge work that continuously invests in staff development, engagement and well-being. We provide security, and career paths, along with individual training programs and mentoring.

POST DATE
WORK LOCATION
Remotely
JOB TYPE
Full Time
Apply

Front End React Developer

Cloud Employee is a fast-growing UK-managed offshore recruitment and staffing company in the Philippines. We tackle the growing global IT skills shortage by connecting tech companies based in Europe, the US, and Australia to our pool of expert software developers in the country.

We are now seeking a passionate Front End React Developer to join our team of skilled talents. This is an excellent opportunity to join a fun and dynamic work environment and to significantly advance your career.

POST DATE
WORK LOCATION
Remotely
JOB TYPE
Full Time
Apply

Frontend Developer (NextJS and React)

Cloud Employee, is a UK-owned Philippines business established 8 years ago. We connect high-performing software engineer talent in the Philippines with some of the world’s leading and most innovative tech companies. Developers join to work from the Philippines as part of international engineer teams and grow their CV and skill-set.

We pride ourselves on being supportive and cutting-edge work that continuously invests in staff development, engagement and well-being. We provide security, and career paths, along with individual training programs and mentoring.

POST DATE
WORK LOCATION
Remotely
JOB TYPE
Full Time
Apply

Frontend Developer (Senior)

Cloud Employee, is a UK-owned Philippines business established 8 years ago. We connect high-performing software engineer talent in the Philippines with some of the world’s leading and most innovative tech companies. Developers join to work from the Philippines as part of international engineer teams and grow their CV and skill-set.

We pride ourselves on being supportive and cutting-edge work that continuously invests in staff development, engagement and well-being. We provide security, and career paths, along with individual training programs and mentoring.

POST DATE
WORK LOCATION
Remotely
JOB TYPE
Seasonal
Apply

Frontend React Developer

Cloud Employee, is a UK-owned Philippines business established 8 years ago. We connect high-performing software engineer talent in the Philippines with some of the world’s leading and most innovative tech companies. Developers join to work from the Philippines as part of international engineer teams and grow their CV and skill-set.

We pride ourselves on being supportive and cutting-edge work that continuously invests in staff development, engagement and well-being. We provide security, and career paths, along with individual training programs and mentoring.

POST DATE
WORK LOCATION
JOB TYPE
Apply

Full-Stack Developer

Cloud Employee is a fast-growing UK-managed offshore recruitment and staffing company in the Philippines. We tackle the growing global IT skills shortage by connecting tech companies based in Europe, the US, and Australia to our pool of expert software developers in the country.

We are now seeking a passionate Full-Stack Developer to join our team of skilled talents. This is an excellent opportunity to join a fun and dynamic work environment and to significantly advance your career.

POST DATE
WORK LOCATION
Remotely
JOB TYPE
Full Time
Apply

Full-Stack Laravel/Vue Developer (Jr to Mid)

Cloud Employee, is a UK-owned Philippines business established 8 years ago. We connect high-performing software engineer talent in the Philippines with some of the world’s leading and most innovative tech companies. Developers join to work from the Philippines as part of international engineer teams and grow their CV and skill-set.

We pride ourselves on being supportive and cutting-edge work that continuously invests in staff development, engagement and well-being. We provide security, and career paths, along with individual training programs and mentoring.

POST DATE
WORK LOCATION
Remotely
JOB TYPE
Full Time
Apply

Full Stack .Net Developer

Cloud Employee, is a UK-owned Philippines business established 8 years ago. We connect high-performing software engineer talent in the Philippines with some of the world’s leading and most innovative tech companies. Developers join to work from the Philippines as part of international engineering teams and grow their CV and skill-set.We pride ourselves on being a supportive and cutting-edge workplace that continuously invests in staff development, engagement, and well-being. We provide security, and career paths, along with individual training programs and mentoring.

POST DATE
WORK LOCATION
Remotely
JOB TYPE
Full Time
Apply

Full-Stack Node/VueJS Developer (Mid - Senior)

Cloud Employee, is a UK-owned Philippines business established 8 years ago. We connect high-performing software engineer talent in the Philippines with some of the world’s leading and most innovative tech companies. Developers join to work from the Philippines as part of international engineer teams and grow their CV and skill-set.

We pride ourselves on being supportive and cutting-edge work that continuously invests in staff development, engagement and well-being. We provide security, and career paths, along with individual training programs and mentoring

POST DATE
WORK LOCATION
Remotely
JOB TYPE
Full Time
Apply

Full-Stack PHP Developer (Mid to Senior)

Cloud Employee is a fast-growing UK-managed offshore recruitment and staffing company in the Philippines. We tackle the growing global IT skills shortage by connecting tech companies based in Europe, the US, and Australia to our pool of expert software developers in the country.

We are now seeking passionate mid to senior-level Fullstack PHP Developer to join our team of skilled talents. This is an excellent opportunity to join a fun and dynamic work environment and to significantly advance your career.

POST DATE
WORK LOCATION
Remotely
JOB TYPE
Full Time
Apply

Full-Stack PHP Developer Tech Lead

Cloud Employee is a fast-growing UK-managed offshore recruitment and staffing company in the Philippines. We tackle the growing global IT skills shortage by connecting tech companies based in Europe, the US, and Australia to our pool of expert software developers in the country.

We are now seeking passionate Lead Full-Stack PHP Developer to join our team of skilled talents. This is an excellent opportunity to join a fun and dynamic work environment and to significantly advance your career.

POST DATE
WORK LOCATION
Remotely
JOB TYPE
Full Time
Apply

Full stack RoR/VueJS Developer

Cloud Employee, is a UK-owned Philippines business established 8 years ago. We connect high-performing software engineer talent in the Philippines with some of the world’s leading and most innovative tech companies. Developers join to work from the Philippines as part of international engineer teams and grow their CV and skill-set.

We pride ourselves on being supportive and cutting-edge work that continuously invests in staff development, engagement and well-being. We provide security, and career paths, along with individual training programs and mentoring.

POST DATE
WORK LOCATION
Remotely
JOB TYPE
Full Time
Apply

Fullstack Developer

Cloud Employee, is a UK-owned Philippines business established 8 years ago. We connect high-performing software engineer talent in the Philippines with some of the world’s leading and most innovative tech companies. Developers join to work from the Philippines as part of international engineer teams and grow their CV and skill-set.

We pride ourselves on being supportive and cutting-edge work that continuously invests in staff development, engagement and well-being. We provide security, and career paths, along with individual training programs and mentoring.

POST DATE
WORK LOCATION
Remotely
JOB TYPE
Full Time
Apply

Fullstack .NET Developer

Cloud Employee, is a UK-owned Philippines business established 8 years ago. We connect high-performing software engineer talent in the Philippines with some of the world’s leading and most innovative tech companies. Developers join to work from the Philippines as part of international engineer teams and grow their CV and skill-set.

We pride ourselves on being supportive and cutting-edge work that continuously invests in staff development, engagement and well-being. We provide security, and career paths, along with individual training programs and mentoring.

POST DATE
WORK LOCATION
Remotely
JOB TYPE
Full Time
Apply

Lead/Senior Frontend Developer (UI/UX) - Brazil

Cloud Employee is a UK-owned business established eight years ago. We connect high-performing software engineer talent worldwide with some of the world’s leading and most innovative tech companies. Developers join to work from the Philippines and Brazil as part of international engineering teams and grow their CV and skill-set.

We pride ourselves on being a supportive and cutting edge workplace that continuously invests in staff development, engagement, and well-being. We provide security, career paths, individual training programs, and mentoring.

POST DATE
WORK LOCATION
Remotely
JOB TYPE
Full Time
Apply

Marketing Specialists

Cloud Employee, is a UK-owned Philippines business established 8 years ago. We connect high-performing software engineer talent in the Philippines with some of the world’s leading and most innovative tech companies. Developers join to work from the Philippines as part of international engineer teams and grow their CV and skill-set.

We pride ourselves on being supportive and cutting-edge work that continuously invests in staff development, engagement and well-being. We provide security, and career paths, along with individual training programs and mentoring.

POST DATE
WORK LOCATION
Remotely
JOB TYPE
Full Time
Apply

Backend Developer (Python)

Cloud Employee, is a UK-owned Philippines business established 8 years ago. We connect high-performing software engineer talent in the Philippines with some of the world’s leading and most innovative tech companies. Developers join to work from the Philippines as part of international engineer teams and grow their CV and skill-set.

We pride ourselves on being supportive and cutting-edge work that continuously invests in staff development, engagement and well-being. We provide security, and career paths, along with individual training programs and mentoring.

POST DATE
WORK LOCATION
Remotely
JOB TYPE
Full Time
Apply

Senior Full-Stack PHP Developer

Cloud Employee is a UK-owned Philippines business established 8 years ago. We connect high-performing software engineer talent in the Philippines with some of the world’s leading and most innovative tech companies. Developers join to work from the Philippines as part of international engineering teams and grow their CV and skill-set.

We pride ourselves on being a supportive and cutting-edge workplace that continuously invests in staff development, engagement, and well-being. We provide security, and career paths, along with individual training programs and mentoring.

POST DATE
January 2, 2024
WORK LOCATION
Remotely
JOB TYPE
Full Time
Apply

Working with PDFView and Pinch Zoom in Xamarin Forms

February 16, 2024

Xamarin.Forms code runs on multiple platforms like Android, iOS, UWP, and each of them has its own file system. Using native APIs, we can do reading or writing files easily. Embedded resources are a simple solution for distributing data files with the application. In Xamarin.Forms there is no support or any feature for generating or viewing PDF files. We can achieve requirements such as view or generate PDF using native Support with the help of renderer for both Android and iOS platforms.

However, you can also check how to generate PDF file from HTML string to empower your knowledge base on this topic.

Now talking about PDFView, it is a big problem in Android web view. To solve this problem, we can use google driver viewer and google doc viewer. We can also view PDF files using the pdfjs library through native support. We have to download the pdfjs file and put the folder in android and iOS platform projects. In the android platform put a folder inside Android Asset and in iOS put it inside the Resources folder. But the problem is that pdfjs does not support pinch zoom.

Let's create an application that is working with PDFView and pinch zoom. Create a new Project with Android and iOS platforms, choose mobile app project from mobile. Give appropriate names to the application and then select the blank app and platform - Android, iOS, UWP. If you are having a hard time doing this, then you can always hire a developer.

Now create a new class file in the shared project for custom WebView. In this class inherit WebView for custom rendering and then add bindable properties. We are going to create two bindable properties uriProperty and isPDFProperty.

PdfViewRenderercs.cs file (For custom Webview)

using Xamarin.Forms;




namespace PdfView

{

   public class PdfViewRenderercs:WebView

   {

       public static readonly BindableProperty uriProperty = BindableProperty.Create(

         propertyName: "URI",

        returnType: typeof(string ),

        declaringType: typeof(PdfViewRenderercs),

        defaultValue: default(string)

);




       public string URI

       {

           get { return (string)GetValue(uriProperty); }

           set { SetValue(uriProperty, value); }

       }

       public static readonly BindableProperty isPDFProperty = BindableProperty.Create(

           propertyName: "IsPdf ",

           returnType: typeof(bool ),

           declaringType: typeof(PdfViewRenderercs ),

           defaultValue: default(bool)

           );

       public bool IsPdf

       {

           get { return (bool)GetValu(isPDFProperty);

}

           set { SetValue ( isPDFProperty, value ) ;

}

       }

   }

}

Now, we will implement a custom renderer in the Android platform. In Android, webview is not supported so we are going to use Google Driver Viewer to view the PDF. Note that the URL must be public and with extension .PDF

Use https://drive.google.com/viewerng/viewer?embedded=true&url=" + " url”;

or

https://docs.google.com/gview?embedded=true&url=" + " url" ;

Here, we have inherited the WebViewRenderer from renderer and created OnElementChange method and set url.

using Android.Content;

using PdfView;

using PdfView.Droid;

using Xamarin.Forms;

using Xamarin.Forms.Platform.Android;

[assembly: ExportRenderer(typeof( PdfViewRenderercs ), typeof( WebViewRendererAndroid ) ) ]

namespace PdfView.Droid

{

   public class WebViewRendererAndroid : WebViewRenderer

   {

       public WebViewRendererAndroid( Context context) : base( context)

       {

       }

       protected override void OnElementChanged( ElementChangedEventArgs<WebView> e )

       {

           base.OnElementChanged( e ) ;




           if (e.NewElement != null)

           {

               var pdfview = Element as PdfViewRenderercs ;

               Control.Settings.AllowUniversalAccessFromFileURLs = true ;

               If ( pdfview.IsPdf )

               {

                   var Url = "https://drive.google.com/viewerng/viewer?embedded=true&url=" + pdfview.URI;

                   Control.LoadUrl(Url) ;

               }

               else

               {

                   Control.LoadUrl( pdfview.URI) ;

               }

           }

       }

   }

}


MainPage Xamal file

<ContentPage xmlns= "http://xamarin.com/schemas/2014/forms"

            xmlns:x= "http://schemas.microsoft.com/winfx/2009/xaml"

            x:Class= "PdfView.MainPage">




   <StackLayout>

       <Button Text="Pdf" Clicked="pdf_button" />

   </StackLayout>




</ContentPage>





This is an implementation of the iOS platform, we have done the same things as we have implemented in the android platform:

using System;

using PdfView;

using PdfView.iOS;

using UIKit;

using Xamarin.Forms;

using Xamarin.Forms.Platform.iOS;




#pragma warning disable CS0612 // Type or member is obsolete

[assembly: ExportRenderer(typeof( PdfViewRenderercs ), typeof(PDFViewRendererios ))]

#pragma warning restore CS0612 // Type or member is obsolete

namespace PdfView.iOS

{

   [Obsolete]

   public class PDFViewRendererios: WebViewRenderer

   {

       protected override void OnElementChanged(VisualElementChangedEventArgs e )

       {

           base.OnElementChanged (e);




           if (NativeView != null && e.NewElement != null )

           {

               var pdfControl1 = NativeView as UIWebView ;




               if (pdfControl1 == null)

                   return;




               pdfControl1.ScalesPageToFit = true ;

           }

       }

}

}

MainPage code-behind file

using Xamarin.Forms;

namespace PdfView

{

   public partial class MainPage : ContentPage

   {

       public MainPage()

       {

           InitializeComponent();

       }




       private async void pdf_button(object sender, EventArgs e)

       {

           await Navigation.PushModalAsync(new Page1() ) ;

       }

   }

}


Now, Implementing custom web view in XAML. First of all we have to add a namespace like this xmlns:Renderes="clr-namespace:PdfView" and then add custom web view. <Renderes:PdfViewRenderercs> </Renderes:PdfViewRenderercs>

Page1.Xaml

<ContentPage xmlns ="http://xamarin.com/schemas/2014/forms"

            xmlns:x ="http://schemas.microsoft.com/winfx/2009/xaml"

            xmlns:Renderes  ="clr-namespace:PdfView"

            x:Class ="PdfView.Page1">

   <ContentPage.Content>

       <Renderes:PdfViewRenderercs

           x:Name= " pdfviewpg1 "

           IsPdf=" True "

           VerticalOptions="FillAndExpand"

           HorizontalOptions="FillAndExpand">

       </Renderes:PdfViewRenderercs>

</ContentPage.Content>

</ContentPage>

Page1.Xaml.cs file

using Xamarin.Forms;

using Xamarin.Forms.PlatformConfiguration;

using Xamarin.Forms.PlatformConfiguration.AndroidSpecific;

using Xamarin.Forms.Xaml;




namespace PdfView

{

   [XamlCompilation(XamlCompilationOptions.Compile )]

   public partial class Page1 : ContentPage

   {

       string url1 = "http://media.wuerth.com/stmedia/shop/catalogpages/LANG_it/1637048.pdf" ;

       public Page1 ()

       {

           InitializeComponent ();

           if (Device.RuntimePlatform = = Device.Android )

           {

               pdfviewpg1.URI = url1 ;

               pdfviewpg1.On<Android>().EnableZoomControls(true) ;

               pdfviewpg1.On<Android>().DisplayZoomControls(false) ;

           }

           else

           {

               pdfviewpg1.Source = url1 ;

           }

       }

}

}


To test pinch-zoom in the emulator use Control + Shift + Left Click and move the mouse. Here, we have created one Xamarin.Forms application working with PDFView and pinch zoom. We have created a custom WebView using renderer and create bindable properties in custom Webview. After that, we have implemented a custom renderer in the Android project, and in that file, we have inherited WebviewRenderer. At last, we have implemented a custom renderer in our XAML file, in XAML file we have added a namespace and a custom webview.

Conclusion

In Xamarin.Forms there is no support for PDFView. We have to achieve this by using native support through custom renderers. We can view pdf files using the pdfjs library but the problem is that it does not support pinch-zoom functionality. PDFView is a big problem in android webview, to solve this problem we can use Google driver Viewer or Google doc viewer, and custom renderers. In this blog, we have created a simple app working with PDFView and pinch-zoom in which we have displayed one PDF file using google driver viewer with the help of a custom webview renderer. We have created a renderer file in the shared project and inherit webview and created bindable properties. And, in the Android project, we have created a class file for custom renderer and inherited webview renderer after that use a custom webview renderer in our XAML file by adding namespace and custom webview. We have also seen how to use pinch-zoom in the emulator.

Webflow
Python
MySQL
Node.js
Angular
Android
React
Php
Javascript
What skillsets are you looking to hire?
Previous
Next
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.