Exploring Foxit MobilePDF SDK on Android and iOS

5.00 avg. rating (96% score) - 2 votes

Last week when downloading Foxit PDF Reader, I browsed through the list of PDF products offered by Foxit and came across Foxit MobilePDF SDK, a feature-rich PDF library for Android, iOS and Universal Windows Platform (UWP). In addition to common PDF features such as form filling and annotations, what thrills me the most is the SDK’s support for text-reflow and night mode viewing, which is still lacking in other PDF SDKs. Being so excited at the existence of such a sophisticated PDF SDK , I decided to spend some time playing with the SDK on my mobile devices and this article will share some of my interesting findings.

Downloading the SDK

As is the case for most advanced PDF libraries, Foxit does not provide direct download links to the SDK on its website, only a trial request form which you have to fill in to contact a sales representative for the download links. For each supported platform (Android, iOS or UWP), the SDK files will contain the following:

  • Sample applications (CompletePDFViewer, FunctionDemo, ViewerCtrlDemo)
  • Open source UIExtensions project
  • Main PDF library in the following formats:
    • .so and .jar for Android
    • framework files for iOS
    • Visual Studio Extension (vsix) for UWP
  • Test PDF files
  • Documentation (available in HTML and PDF format)

Among the sample applications, the CompletePDFViewer project provides a fully functional PDF viewer which is more or less the same with Foxit PDF Reader, as far as viewing PDFs is concerned. The FunctionDemo project demonstrates various SDK functionalities, such as adding annotations/signature or exporting a PDF file. The ViewerCtrlDemo project (not available in the UWP download) shows how to use the SDK as a custom control to display PDF files in a simple way without having to deal with the underlying PDF rendering logic. The open-source UIExtensions library provides various components that will be useful to build your own PDF readers such as annotations or text selection toolbars.

The SDK is listed as supporting iOS 9, Android 4 and Windows 10 or newer. Interestingly, in a separate tutorial, Foxit indicated that the SDK can support Android 2.2 or newer. I did not test to see if the SDK can run on Android 2.2, since I do not have such an old Android device.

Setting up the demo app

The objective of my testing of this PDF SDK is simple – that is to see what kinds of PDF features it can support, and whether a mobile app developed using the SDK can provide a PDF-reading experience that is on par with a commercial PDF reader application, e.g. Adobe Acrobat Reader, Moon+ Reader or Foxit PDF Reader. Also as the SDK seems to provide consistent performance between its Android and iOS versions, the screenshots provided in this article will be from the CompletePDFViewer demo app running on Android, unless otherwise specified.

The first step in getting the demo app to work is to update the license keys in the App.java file. Change the sn and key declarations to match the rdk_key.txt and rdk_sn.txt files found in the libs folder of the download.  These keys are passed to the App() constructor which calls Library.init() to initialize the Foxit MobilePDF SDK:

private static String sn = "";
private static String key = "";

private Context mContext;
private int errCode = PDFError.NO_ERROR.getCode();
private static App INSTANCE = new App();
public static App instance() {
 return INSTANCE;
}

private App(){
 try {
 Library.init(sn, key);
 } catch (PDFException e) {
 errCode = e.getLastError();
 }
}

With this change, the demo app starts and shows a list of sample PDF files for testing:

Foxit-MobilePDF-SDK-Demo-App-2

Testing the SDK

Features standard for modern PDF readers such as annotation or signature work quite smoothly as shown in the following screenshot. Ignore the watermark since I am using the demo version of the SDK:

Foxit MobilePDF SDK Demo App (1)

Now it’s time for the advanced tests! The first test is a PDF with a table of contents which is internally stored as a list of bookmarks. The desktop version of Foxit Reader displays this file together with the table of contents just fine:

Capture 3

On the SDK demo app, the table of contents can be found by selecting the List menu and choose the Outline tab:

foxit_pdf_mobile_file_outline1

Tap on the arrow on the right and and you can now see the individual chapters:

foxit_pdf_mobile_file_outline2

It would be better if Foxit can make the table of contents more accessible, for example by automatically popping it up once the document is opened. Moon+ Reader, my favorite Android PDF reader, does this nicely:

Foxit MobilePDF SDK Demo App (17)

My next test is to see whether basic arithmetic calculations can be supported. This feature is quite popular in PDF with formulas created using Adobe Acrobat. Internally, the calculations are implemented using JavaScript and will be quite a challenge to calculate and render in a PDF viewer, due to poor file format documentation.

Surprisingly, our Foxit SDK not only renders the formula without issues but also updates the results smoothly once the text field values are changed:

Foxit MobilePDF SDK Demo App (16)

The only inconvenience is that the search feature does not search within field values. However, to be fair, none of the major PDF readers I try can do this either. The following screenshot demonstrates this limitation when running the SDK on iOS – “230” is not found, despite being the value of field A:

Foxit MobilePDF SDK Demo App (3)

In the above screenshot, “totally found” sounds weird and should be changed to something like “total results”. This is however not a problem as far as SDK functionality is concerned :)

For PDF with embedded multimedia, the SDK only renders the video thumbnails. It does not play the multimedia files when clicked:

Foxit MobilePDF SDK Demo App (12)

This is however understandable as playing multimedia presents various technical challenges such as checking for supported video and audio codecs and launching a third party application that can play the file. The desktop version of Foxit Reader has no issues with this and plays embedded audio and video just fine.

Links inside PDF files (http:// or https://) are also not clickable. I guess there are optional event handlers which I can use to know when links are clicked and act accordingly. Adobe Acrobat Reader and various other PDF readers will also not open links by default, perhaps due to security reasons.

Next, I tried viewing a PDF file created by scanning an old document. The file has been OCR’ed so the text should be searchable. This is the screenshot of the viewer after several attempts to underline and select text:

select text

As can be seen, the highlighted rectangle for selected text and the line below the underline text are simply drawn horizontally, even though the original scanned line might be at an angle. Although the same issue is found with Foxit Reader desktop version, Adobe Acrobat Reader handles this much better and highlights the selected text nicely:

adobe acrobat

As for night mode (the moon icon on right of the bottom toolbar that inverts the color of the PDF text), it is not usable on this SDK since the text is gray (not white), displayed on a dark purple background, and looks a bit blurry:

Foxit MobilePDF SDK Demo App (10)

The same behavior can be found in Foxit Reader Android version. Acrobat Reader for Android, however, renders the PDF file in night mode in a much nicer way. White text on black background is much better to read and text selected at an angle is also rendered properly:

Foxit MobilePDF SDK Demo App (7)

Text reflow seems to work with the Foxit SDK, however the text is drawn with no left or top margins and hard to read:

text reflow

In text reflow mode, the rendering process is much slower and you can sometimes see the screen being displayed part by part. Using it on a PDF file with OCR’ed text and the phone will slow down considerably. And surprisingly, most of the PDF will be unreadable when both text reflow and night mode are used, only some texts can be seen:

Foxit MobilePDF SDK Demo App (9)

This does indeed seem to be an issue with the SDK as Moon+ Reader has no problems with the same file, rendering nice-to-read white text on dark gray background:

text reflow night mode moon reader

Password-protected PDFs with various encryption settings can be handled with no issues. PDFs with embedded custom fonts are also displayed properly with the correct fonts being used. This is a screenshot showing a PDF with embedded Verdana, Tahoma and Georgia fonts nicely rendered:

pdf with custom font

The custom fonts, if not present on the device, are not substituted with default fonts, but instead rendered using their embedded versions. Had font substitutions occurred, we would see the same typeface for the three paragraphs in the above screenshots. Font substitutions would also cause the reader to simply show garbage text when displaying a PDF file that uses custom CID fonts – refer to my previous post for details.

During one of my tests, I encountered an interesting scenario when an Android toast message, “it’s out of memory and on recovering”, was displayed repeatedly on the screen. The application stopped responding and all I could do was to force close it. The problem did not happen again despite my several attempts to replicate it. The error was probably triggered by low memory conditions when I attempted to zoom in on a PDF page with a big image and poor error handling on the Foxit PDF library.

On a side note, the trial license key expires in 10 days, which is rather a short period for a sophisticated PDF SDK. It would have been much nicer if Foxit could increase the expiry period to a month or more as the demo watermark shown in all PDFs rendered using the trial versions would make any application developed using the demo SDKs only useful for testing.

Conclusion

With the custom font test, I concluded my testing of the Foxit MobilePDF SDK and I can say I am happy with the SDK performance on both my Android and iOS devices. Although there is certainly a lot of room for improvements, especially with regards to text reflow and night mode support, the Foxit MobilePDF SDK is still an excellent PDF SDK to be considered if you are planning to develop mobile applications with sophisticated support for PDF.

The PDF files used for testing in this article can be downloaded here for those who might be interested.

See also

Comparison of popular PDF libraries on iOS and Android
Restoring text from PDF files encoded using custom CID fonts

5.00 avg. rating (96% score) - 2 votes
ToughDev

ToughDev

A tough developer who likes to work on just about anything, from software development to electronics, and share his knowledge with the rest of the world.

One thought on “Exploring Foxit MobilePDF SDK on Android and iOS

  • January 24, 2018 at 5:51 pm
    Permalink

    Very valuable information for”Exploring Foxit MobilePDF SDK on Android and iOS”

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>