Foxit pdf SDK for Android

Creating, viewing and editing PDF files on Android devices has never been easier than with our modern, easy-to-use PDF SDK for Android. Alongside Foxit’s powerful Core API, our built-in UI Extension component helps to ship products quickly, even if your team of developers has limited knowledge of PDF. Powered by Fx Core™ technology, PDF SDK for Android has never been as fast or precise as it is now.

Developing with PDF SDK for Android

Using Android Studio developers can use our PDF SDK in a variety of languages such as Java, Kotlin or C++. With JavaScript you can use our Cordova or React Native binding libraries for more native development. Foxit provides all the essentials for an Android developer to use our technology with ease. Simply put, our core API makes our product easily accessible for developers of all levels and experience.

PDF SDK for Android

FEATURES

PDF Page View Android
Ink Signatures Android
Form filling Android

PDF Viewing

Our core API provides for high-fidelity rendering of PDF documents with optimized performance for Android and other mobile platforms.

PDF Signatures

Use ink signatures to let customers sign documents in their android device. No need to print a file to sign again!

PDF Forms

Give users the ability to fill out digital forms on the go with their android device. Mobile apps have never been more productive!

PDF Password Android
Strikeout annotation
Full Text Search

Rights Management

Our PDF SDK for Android can generate secure PDFs with native encryption/decryption or integrate with customized DRM or IRM security systems. Our technology integrates with Microsoft RMS.

PDF Annotations

Our Android SDK provides full support for annotating and marking up content with an extensive range of functions for creating, editing or importing/exporting annotations.

Full Text Search

Fast full-text search for any PDF document, language, or encoding type. The SQLite-based full-text search delivers near-instant results, even for repositories on any Android device.

Full support for Android 8.1 Oreo

We keep our libraries up to date with the latest versions of Android, so you don’t have to worry about it.

Foxit Mobilepdf android

Our Android PDF Reader is built with our PDF SDK for Android and free to download from the Google Play Store. 

Benefits

Native UI

Our Android PDF SDK is built with developers in mind. We provide a built in PDF viewer which will half your development while allowing you to customize your viewer accordingly.

GOOGLE PLAY READY

PDF SDK for Android is fully compliant with Google’s policies for app developers using third-party components, meaning your apps will be approved on Play Store faster.

Device agnostic

Anything from smart watches, to phones, to Chromebooks, to even cars – Foxit PDF SDK renders documents inside your application just like you expected them.

Powered by Foxit's Core Technology

The core technology of Foxit PDF SDK has been around for years and is trusted by a large number of well-known companies. Foxit’s powerful engine makes document viewing fast and consistent across all platforms.

SYSTEM REQUIREMENTS

  • Android 4.x or newer
  • 32/64-bit ARM (armeabi-v7a/arm64-v8a) or 32-bit Intel x86 CPU

Sample Code in Android Studio

public class Outline {
    private String mFilePath = "";
    private Context mContext = null;
    private static int index = 0;

    public Outline(Context context, String pdfFilePath) {
        mFilePath = pdfFilePath;
        mContext = context;
    }

    public void modifyOutline() {
        int indexPdf = mFilePath.lastIndexOf(".");
        int indexSep = mFilePath.lastIndexOf("/");

        String filenameWithoutPdf = mFilePath.substring(indexSep + 1, indexPdf);
        String outputFilePath = Common.GetOutputFilesFolder(Common.outlineModuleName) + filenameWithoutPdf + "_edit.pdf";

        PDFDoc doc = null;
        doc = Common.loadPDFDoc(mContext, mFilePath, null);
        if (doc == null) {
            return;
        }
        try {
            Bookmark bookmarkRoot = doc.getRootBookmark();
            if (bookmarkRoot == null) {
                return;
            }

            Bookmark firstChild = bookmarkRoot.getFirstChild();
            modifyOutline(firstChild);

            if (false == doc.saveAs(outputFilePath, PDFDoc.e_SaveFlagNormal)) {
                Toast.makeText(mContext, "Save document error!", Toast.LENGTH_LONG).show();
                return;
            }
        } catch (PDFException e) {
            Toast.makeText(mContext, "Outline demo run error. " + e.getMessage(), Toast.LENGTH_LONG).show();
            return;
        } finally {
            Common.releaseDoc(mContext, doc);
        }
        Toast.makeText(mContext, Common.runSuccesssInfo + outputFilePath, Toast.LENGTH_LONG).show();
    }

    private void modifyOutline(Bookmark bookmark) {
        try {
            if (bookmark.isEmpty())
                return;

            if (index % 2 == 0) {
                bookmark.setColor(0xFFFF0000);
                bookmark.setStyle(Bookmark.e_StyleBold);
            } else {
                bookmark.setColor(0xFF00FF00);
                bookmark.setStyle(Bookmark.e_StyleItalic);
            }

            bookmark.setTitle("foxitbookmark" + index);
            index++;

            //Traverse the brother nodes and modify their appearance and titles.
            Bookmark nextSibling = bookmark.getNextSibling();
            modifyOutline(nextSibling);

            //Traverse the children nodes and modify their appearance and titles.
            Bookmark child = bookmark.getFirstChild();
            modifyOutline(child);

        } catch (PDFException e) {
            Toast.makeText(mContext, "Outline demo run error. " + e.getMessage(), Toast.LENGTH_LONG).show();
        }
    }
} 
public class Render {
    private Context mContext = null;
    private String mPath = null;

    public Render(Context context, String path) {
        mContext = context;
        mPath = path;
    }

    public void renderPage(int index) {
        PDFDoc doc = Common.loadPDFDoc(mContext, mPath, null);
        if (doc == null) return;

        try {
            int pageCount = doc.getPageCount();
            if (index > pageCount || index < 0) {
                Toast.makeText(mContext, String.format("The page index is out of range!"), Toast.LENGTH_LONG).show();
                return;
            }

            String name = mPath.substring(mPath.lastIndexOf("/") + 1, mPath.lastIndexOf("."));
            String outputFilePath = String.format("%s_index_%d.jpg", Common.GetOutputFilesFolder(Common.renderModuleName).concat(name), index);
            PDFPage pdfPage = Common.loadPage(mContext, doc, index, PDFPage.e_ParsePageNormal);
            if (pdfPage == null) {
                return;
            }

            //Create the bitmap and erase its background.
            Bitmap bitmap = Bitmap.createBitmap((int) pdfPage.getWidth(), (int) pdfPage.getHeight(), Bitmap.Config.ARGB_8888);

            //If the page has transparency, the bitmap should be erased "Color.TRANSPARENT".
            if (pdfPage.hasTransparency()){
                bitmap.eraseColor(Color.TRANSPARENT);
            }
            else {
                bitmap.eraseColor(Color.WHITE);
            }

            Matrix2D matrix = pdfPage.getDisplayMatrix(0, 0, (int)pdfPage.getWidth(), (int)pdfPage.getHeight(), Constants.e_Rotation0);

            Renderer renderer = new Renderer(bitmap,true);

            //Render the page to bitmap.
            Progressive progressive = renderer.startRender(pdfPage, matrix, null);
            int state = Progressive.e_ToBeContinued;
            while (state == Progressive.e_ToBeContinued) {
                state = progressive.resume();
            }
            progressive.delete();
            if (state == Progressive.e_Error) {
                Toast.makeText(mContext, String.format("Failed to render the page No.%d failed!", index), Toast.LENGTH_LONG).show();
                return;
            }

            //Save the render result to the jpeg image.
            if (false == Common.SaveImageFile(bitmap, Bitmap.CompressFormat.JPEG, outputFilePath)) {
                Toast.makeText(mContext, String.format("Failed to Save Image File!"), Toast.LENGTH_LONG).show();
                return;
            }

            renderer.delete();
            pdfPage.delete();
            Toast.makeText(mContext, Common.runSuccesssInfo + outputFilePath, Toast.LENGTH_LONG).show();
        } catch (PDFException e) {
            Toast.makeText(mContext, String.format("Failed to render the page No.%d! %s", index, e.getMessage()), Toast.LENGTH_LONG).show();
        } finally {
            Common.releaseDoc(mContext, doc);
        }
    }
}