Object PSPDFKit
-
- All Implemented Interfaces:
public class PSPDFKit
Main PSPDFKit entry point. Use .initialize to initialize the library if you are not using the com.pspdfkit.ui.PdfActivity or the com.pspdfkit.ui.PdfFragment (which handle initialization on their own).
-
-
Method Summary
Modifier and Type Method Description final static Unit
initialize(Context context, InitializationOptions options)
Initializes PSPDFKit with a license key. final static Unit
initialize(Context context, String licenseKey)
Helper for the main initialise method. final static Unit
initialize(Context context, String licenseKey, List<String> fontPaths, String hybridTechnology)
Initializes PSPDFKit with a license key. final static Unit
initialize(Context context, String licenseKey, List<String> fontPaths)
Initializes PSPDFKit with a license key. final static Unit
initialize(Context context, String licenseKey, ApplicationPolicy applicationPolicy)
Initializes PSPDFKit with a license key and a specific application policy. final static Unit
initialize(Context context, String licenseKey, ApplicationPolicy applicationPolicy, List<String> fontPaths)
Initializes PSPDFKit with a license key and a specific application policy. final static Unit
clearCaches(Context context, Boolean clearDiskCache)
Clears pageBitmap memory cache to free memory. final static Unit
clearCaches()
Clears pageBitmap memory cache to free memory. final static Unit
release(Context context)
Releases PSPDFKit library and all associated caches from memory. final static Unit
release()
Releases PSPDFKit library and all associated caches from memory.<br></br>BE WARNED: After this call all existing com.pspdfkit.document.PdfDocument instances WILL be invalid and calling methods on them will result in a crash. final Boolean
isLocalFileUri(Context context, Uri uri)
Checks whether or not PSPDFKit can extract a local filesystem path from the uri
.final static Boolean
isOpenableUri(Context context, Uri uri)
PSPDFKit can only open URIs from content providers that also provide size information. final static Boolean
isInitialized()
Returns true
if PSPDFKit is initialized and ready to use.final static Boolean
addAnalyticsClient(AnalyticsClient client)
Add a AnalyticsClient to receive analytics events from PSPDFKit. final Boolean
removeAnalyticsClient(AnalyticsClient client)
Remove a previously added AnalyticsClient from PSPDFKit. final Unit
setNativeCrashDumpPath(String path)
Sets a directory into which native code minidumps will be stored for debugging of native crashes. final Unit
setLocalizationListener(LocalizationListener localizationListener)
Sets a new LocalizationListener to help with localizing SDK framework strings. final static ApplicationPolicy
getApplicationPolicy()
Returns application policy. final static Unit
setApplicationPolicy(ApplicationPolicy applicationPolicy)
Sets application policy for the loaded library. final static Unit
ensureInitialized()
Checks if PSPDFKit is initialized or throws PSPDFKitNotInitializedException if not. final static EnumSet<LicenseFeature>
getLicenseFeatures()
Gets all the LicenseFeature that are enabled with the current license. final static FontManager
getSystemFontManager()
Returns The FontManager giving you access to the system fonts. -
-
Method Detail
-
initialize
@Synchronized() final static Unit initialize(Context context, InitializationOptions options)
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 com.pspdfkit.ui.PdfFragment or com.pspdfkit.ui.PdfActivity.
- Parameters:
context
- Application context.options
- Extra initialization options, for example license key string.
-
initialize
@Synchronized() final static Unit initialize(Context context, String licenseKey)
Helper for the main initialise method. Useful if you only want to initialise with a license key and want to leave other options as default.
- Parameters:
context
- Application context.licenseKey
- A valid PSPDFKit license key.
-
initialize
@Deprecated(message = "v2024.2: Will be removed in 2025.", replaceWith = @ReplaceWith(imports = {}, expression = "initialize(context, options: InitializationOptions?)"))@Synchronized() final static Unit initialize(Context context, String licenseKey, List<String> fontPaths, 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 com.pspdfkit.ui.PdfFragment or com.pspdfkit.ui.PdfActivity.
- Parameters:
context
- Application context.licenseKey
- PSPDFKit license key ornull
for trial.fontPaths
- Additional paths to lookup fonts.hybridTechnology
- Specifies the Hybrid technology where PSPDFKit is supposed to be working on, ornull
if PSPDFKit runs in a native Android project.
-
initialize
@Deprecated(message = "v2024.2: Will be removed in 2025.", replaceWith = @ReplaceWith(imports = {}, expression = "initialize(context, options: InitializationOptions?)"))@Synchronized() final static Unit initialize(Context context, String licenseKey, List<String> fontPaths)
Initializes PSPDFKit with a license key. This must be called before any other call to methods in this class.
- Parameters:
context
- Application context.licenseKey
- PSPDFKit license key ornull
for trial.fontPaths
- Additional paths to lookup fonts.
-
initialize
@Deprecated(message = "v2024.2: Will be removed in 2025.", replaceWith = @ReplaceWith(imports = {}, expression = "initialize(context, options: InitializationOptions?)"))@Synchronized() final static Unit initialize(Context context, String licenseKey, 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.
- Parameters:
context
- Application context.licenseKey
- PSPDFKit license key ornull
for trial.applicationPolicy
- Application policy.
-
initialize
@Deprecated(message = "v2024.2: Will be removed in 2025.", replaceWith = @ReplaceWith(imports = {}, expression = "initialize(context, options: InitializationOptions?)"))@Synchronized() final static Unit initialize(Context context, String licenseKey, ApplicationPolicy applicationPolicy, 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.
- Parameters:
context
- Application context.licenseKey
- PSPDFKit license key ornull
for trial.applicationPolicy
- Application policy.fontPaths
- Additional paths used to lookup fonts.
-
clearCaches
@Deprecated(message = "v2024.2: Will be removed in a future release.", replaceWith = @ReplaceWith(imports = {"com.pspdfkit.PSPDFKit.clearCaches"}, expression = "clearCaches()")) final static Unit clearCaches(Context context, Boolean clearDiskCache)
Clears pageBitmap memory cache to free memory.
- Parameters:
context
- Application context.clearDiskCache
- Clear disk cache as well.
-
clearCaches
final static Unit clearCaches()
Clears pageBitmap memory cache to free memory.
-
release
@Deprecated(message = "v2024.2: Will be removed in a future release.", replaceWith = @ReplaceWith(imports = {}, expression = "release()")) final static Unit release(Context context)
Releases PSPDFKit library and all associated caches from memory.
-
release
@Synchronized() final static Unit release()
Releases PSPDFKit library and all associated caches from memory.<br></br>
BE WARNED: After this call all existing com.pspdfkit.document.PdfDocument instances WILL be invalid and calling methods on them will result in a crash.
-
isLocalFileUri
final Boolean isLocalFileUri(Context context, Uri uri)
Checks whether or not PSPDFKit can extract a local filesystem path from the
uri
. If this method returnstrue
PSPDFKit can directly access the document on the filesystem, and can thus achieve faster loading speeds. If the method returnsfalse
, use .isOpenableUri to check whether PSPDFKit can still use theuri
for document access.- Parameters:
context
- Context for analyzing the uri.uri
- Uri pointing to a PDF document.- Returns:
true
if PSPDFKit can access the file directly, orfalse
if it needs to use a content resolver for access.
-
isOpenableUri
final static Boolean isOpenableUri(Context context, 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.- Returns:
true
if the document can be directly opened.
-
isInitialized
final static Boolean isInitialized()
Returns
true
if PSPDFKit is initialized and ready to use.- Returns:
true
if PSPDFKit was initialized.
-
addAnalyticsClient
final static Boolean addAnalyticsClient(AnalyticsClient client)
Add a AnalyticsClient to receive analytics events from PSPDFKit. This method will return
true
if the client was successfully added, orfalse
if it was not added. Usually this happens if the client has already been added previously.- Parameters:
client
- An AnalyticsClient to add.- Returns:
true
if the client was successfully added, otherwisefalse
.
-
removeAnalyticsClient
final Boolean removeAnalyticsClient(AnalyticsClient client)
Remove a previously added AnalyticsClient from PSPDFKit. This method will return
true
if the client was successfully removed, orfalse
if it was not removed. This usually happens if the client was not registered previously.- Parameters:
client
- An AnalyticsClient to remove.- Returns:
true
if the client was successfully removed, otherwisefalse
.
-
setNativeCrashDumpPath
final Unit setNativeCrashDumpPath(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
final Unit setLocalizationListener(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.
-
getApplicationPolicy
final static ApplicationPolicy getApplicationPolicy()
Returns application policy. If not set, defaults to com.pspdfkit.configuration.policy.DefaultApplicationPolicy.
- Returns:
application policy.
-
setApplicationPolicy
final static Unit setApplicationPolicy(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.
-
ensureInitialized
final static Unit ensureInitialized()
Checks if PSPDFKit is initialized or throws PSPDFKitNotInitializedException if not.
-
getLicenseFeatures
@Synchronized() final static EnumSet<LicenseFeature> getLicenseFeatures()
Gets all the LicenseFeature that are enabled with the current license.
- Returns:
A set of LicenseFeature that are currently enabled or an empty set if PSPDFKit was not initialized yet.
-
getSystemFontManager
final static FontManager getSystemFontManager()
Returns The FontManager giving you access to the system fonts.
-
-
-
-