Apple. Samsung. Android. Windows Phone. Nokia. Blackberry. The mobile marketplace is filled with choices. And today’s end-users expect to have their mobile apps work the same, whatever their device.
Now many OEMs and Enterprises want apps able to view and edit documents across every platform. But building a cross-platform solution means engaging different developers, different code bases and different document technologies -- a fragmentation that leads to higher costs, longer time to market, increased maintenance and staffing issues.
Whether starting with a small team or seeking efficiencies inside a larger one, you need ways to make development more manageable.
As a customer support technician, I have had the privilege of helping many people do just that, using PDFTron technologies, Xamarin, Java and .NET Core to streamline development. With PDFTron, for instance, it’s possible to use the same C# API for iOS, Android, UWP, Linux, macOS and Windows. Here are quick tips on how you can add new cross-platform PDF features to your solution.
PDFTron has offered Xamarin compatibility on iOS, Android and UWP for many years now, allowing companies to quickly add document viewing, annotating and processing to their mobile apps.
If you have an Android device available, the easiest way to preview our Xamarin SDK is to download and run the following pre-built APK files.
The CompleteReader Android sample shows how to make a universal viewer support PDF files and other document extensions such as .docx, .doc, .pptx, .xlsx, .md and .cbz, plus various image formats.
The sample project Xamarin Forms which runs on Android, iOS and UWP, shows a simple PDFViewCtrl with annotation functionality.
Along with how to annotate PDF files, the sample includes code snippets on how to add a custom view on a PDF page, how to find text, how to hide tools from QuickMenu and AnnotationToolbar, how to show reflow mode and night mode, and so on.
linkAnnotating and form filling
Annotating is a common requirement, along with the ability to fully customize your annotations to maximize integration with your business logic. For most common customizations, you can use the same code XamarinAPI for Android and iOS.
Fortunately, this solution also gives you all the UI/UX logic in source code form, so anything not already exposed can still be modified, for complete control over the entire UX. Due to each platform’s particular requirements, you’ll use each platform’s specific API and work in its native language, such as Java.
As mentioned earlier, Xamarin.Forms can be used to provide the most code coverage across Android, iOS and UWP.
Our two most popular Xamarin platforms, iOS and Android, share a common Tools API.
This covers the bulk of user interactions, including...
- panning and zooming
- text highlighting
In addition, we provide an easy-to-use API, and the source code, allowing for further customization to make use of features or qualities specific to each platform.
linkPlatform specific components
Anything not covered by the Xamarin Tools API above can still be customized or controlled using either platform-specific API calls, or by modifying the platform-specific Tool project directly.
Often, it’s better to have some server-side document processing. Examples include when you are optimizing documents for viewing or when you’re extracting text for search indexing.
Just as PDFTron SDK is available for Xamarin, it is also available server side for both .NET framework and .NET Core, and in Java.
Below are common examples of actions that might be done server-side when a file first enters your system.
- Converting various file types, such as Word, or markdown files, to PDF
- Converting PDF files to a linearized format (also known as Fast Web View) for fast network viewing
- Extracting text so that it can be indexed for super-fast searching
- Generating thumbnails for previewing
- Auto-populating form fields
- Redacting text and images
Sample code for many of the above functions can be found in the Sample section of each platform, found in the documentation.
A benefit of using the Java or .NET Core bindings is that you can run PDFNet in a serverless compute environment, such as AWS Lambda. This is a very popular option, for the following reasons:
- You do not have to worry about server management
- You pay for only the processing time used rather than for running a server 24/7
If you use .NET Core bindings for this, then your developers are using the same C# API on both mobile and server side. This means moving PDF related functionality from one to the other could be as simple as copy+pasting code!
Even if you go Java server side, as mentioned earlier, the API for PDFTron SDK server side and client side are essentially identical.
Looking for further guidance? Please get in touch. Our developers, who helped build our SDK from the ground up, would be happy to walk you through your options.