Package com.pspdfkit

Class PSPDFKit

  • All Implemented Interfaces:

    
    public final class PSPDFKit
    
                        

    Main PSPDFKit entry point. Use initialize to initialize the library if you are not using the PdfActivity or the PdfFragment (which handle initialization on their own).

    • Constructor Detail

    • Method Detail

      • initialize

         static void initialize(@NonNull() Context context, @Nullable() String licenseKey, @NonNull() List<String> fontPaths, @Nullable() String hybridTechnology)

        Initializes PSPDFKit with a license key. This must be called before any other call to methods in this class.

        This method can safely be called multiple times and is not needed when using , PdfActivity or PdfActivity.

        Parameters:
        context - Application context.
        licenseKey - PSPDFKit license key or null for trial.
        fontPaths - Additional paths to lookup fonts.
        hybridTechnology - Specifies the Hybrid technology where PSPDFKit is supposed to be working on, or null if PSPDFKit runs in a native Android project.
      • initialize

         static void initialize(@NonNull() Context context, @Nullable() String licenseKey, @NonNull() List<String> fontPaths)

        Initializes PSPDFKit with a license key. This must be called before any other call to methods in this class.

        This method can safely be called multiple times and is not needed when using , PdfActivity or PdfActivity.

        Parameters:
        context - Application context.
        licenseKey - PSPDFKit license key or null for trial.
        fontPaths - Additional paths to lookup fonts.
      • initialize

         static void initialize(@NonNull() Context context, @Nullable() String licenseKey)

        Initializes PSPDFKit with a license key. This must be called before any other call to methods in this class.

        This method can safely be called multiple times and is not needed when using , PdfActivity or PdfActivity.

        Parameters:
        context - Application context.
        licenseKey - PSPDFKit license key or null for trial.
      • initialize

         static void initialize(@NonNull() Context context, @Nullable() String licenseKey, @NonNull() ApplicationPolicy applicationPolicy)

        Initializes PSPDFKit with a license key and a specific application policy. This must be called before any other call to methods in this class.

        This method can safely be called multiple times and is not needed when using , PdfActivity or PdfActivity.

        Parameters:
        context - Application context.
        licenseKey - PSPDFKit license key or nullfor trial.
        applicationPolicy - Application policy.
      • initialize

         static void initialize(@NonNull() Context context, @Nullable() String licenseKey, @NonNull() ApplicationPolicy applicationPolicy, @NonNull() List<String> fontPaths)

        Initializes PSPDFKit with a license key and a specific application policy. This must be called before any other call to methods in this class.

        This method can safely be called multiple times and is not needed when using , PdfActivity or PdfActivity.

        Parameters:
        context - Application context.
        licenseKey - PSPDFKit license key or null for trial.
        applicationPolicy - Application policy.
        fontPaths - Additional paths used to lookup fonts.
      • clearCaches

         static void clearCaches(@NonNull() Context context, boolean clearDiskCache)

        Clears pageBitmap memory cache to free memory.

        Parameters:
        context - Application context.
        clearDiskCache - Clear disk cache as well.
      • release

         static void release(@NonNull() Context context)

        Releases PSPDFKit library and all associated caches from memory.

        BE WARNED: After this call all existing PdfDocument instances WILL be invalid and calling methods on them will result in a crash.

        Parameters:
        context - Application context.
      • isLocalFileUri

         static boolean isLocalFileUri(@NonNull() Context context, @NonNull() Uri uri)

        Checks whether or not PSPDFKit can extract a local filesystem path from the uri. If this method returns true PSPDFKit can directly access the document on the filesystem, and can thus achieve faster loading speeds. If the method returns false, use isOpenableUri to check whether PSPDFKit can still use the uri for document access.

        Parameters:
        context - Context for analyzing the uri.
        uri - Uri pointing to a PDF document.
      • isOpenableUri

         static boolean isOpenableUri(@NonNull() Context context, @NonNull() Uri uri)

        PSPDFKit can only open URIs from content providers that also provide size information. This determines if the document is openable directly from that URI. Note that this will not check if file actually exists.

        Parameters:
        context - Application context.
        uri - Android file URI.
      • isInitialized

         static boolean isInitialized()

        Returns true if PSPDFKit is initialized and ready to use.

      • addAnalyticsClient

         static boolean addAnalyticsClient(@NonNull() AnalyticsClient client)

        Add a AnalyticsClient to receive analytics events from PSPDFKit. This method will return true if the client was successfully added, or false if it was not added. Usually this happens if the client has already been added previously.

        Parameters:
        client - An AnalyticsClient to add.
      • removeAnalyticsClient

         static boolean removeAnalyticsClient(@NonNull() AnalyticsClient client)

        Remove a previously added AnalyticsClient from PSPDFKit. This method will return true if the client was successfully removed, or false if it was not removed. This usually happens if the client was not registered previously.

        Parameters:
        client - An AnalyticsClient to remove.
      • setNativeCrashDumpPath

         static void setNativeCrashDumpPath(@NonNull() String path)

        Sets a directory into which native code minidumps will be stored for debugging of native crashes. T he minidumps are stored in Google Breakpad format.

        Parameters:
        path - Path for native crash dumps, must be writable.
      • setLocalizationListener

         static void setLocalizationListener(@NonNull() LocalizationListener localizationListener)

        Sets a new LocalizationListener to help with localizing SDK framework strings. WARNING: The localization listener is retained globally, so make sure it does not refer to any Activity context or it WILL leak memory.

        Parameters:
        localizationListener - new localization listener.
      • setApplicationPolicy

         static void setApplicationPolicy(@NonNull() ApplicationPolicy applicationPolicy)

        Sets application policy for the loaded library. Make sure the library is initialized before calling this method.

        Parameters:
        applicationPolicy - New policy to be set.