Blog Post

PSPDFKit 4.8 for Android

Today we’re excited to announce PSPDFKit 4.8 for Android, which features support for document tabs, a pop-up toolbar, custom free text fonts, a new Document Editor API, and much more. This blog post only scratches the surface of what is in this release. As always, you can find the full list of features in our changelog for PSPDFKit 4.8 for Android.

Tabs

With tabs we’re bringing another high-demand feature to PSPDFKit for Android. It is now possible to open multiple documents inside a single activity. Doing so results in the appearance of a material design tab strip for switching between as many documents as you would like. The tab strip shows each document’s name, and it allows the dismissing of documents, as well as reordering.

Management of documents inside a PdfActivity is done via the new PdfDocumentCoordinator that can be retrieved by calling getDocumentCoordinator():

fun addDocumentFromUri(uri: Uri) {
  // The descriptor serves as a handle to the document inside the activity.
  // The descriptor also encodes the UI state of a specific document.
  val descriptor = DocumentDescriptor.fromDocumentSource(DocumentSource(uri))

  // Add the document to the end of the tab strip.
  documentCoordinator.addDocument(descriptor)

  // Make the newly added document the actively visible one.
  documentCoordinator.setVisibleDocument(descriptor)
}
void addDocumentFromUri(Uri uri) {
  // The descriptor serves as a handle to the document inside the activity.
  // The descriptor also encodes the UI state of a specific document.
  final DocumentDescriptor descriptor =
    DocumentDescriptor.fromDocumentSource(new DocumentSource(uri));

  // Add the document to the end of the tab strip.
  getDocumentCoordinator().addDocument(descriptor);

  // Make the newly added document the actively visible one.
  getDocumentCoordinator().setVisibleDocument(descriptor);
}

To help you get started quickly with tabs, we added a new DocumentTabsExample to our Catalog app.

Pop-Up Toolbar

With PSPDFKit 4.8 for Android, we’re introducing a new generic PopupToolbar widget that can be used to display a pop-up menu on top of a PDF document. By default, when performing text selection, the new pop-up toolbar replaces the previously used contextual toolbar. If you want to keep the original toolbar behavior, you can set PdfActivityConfiguration.Builder#textSelectionPopupToolbarEnabled() to false.

Custom Free Text Fonts

With 4.8, we’re rolling out custom fonts for free text annotations, which are usable via both the APIs and the user interface. We added a new setter, FreeTextAnnotation#setFontName(), which you can use to set the font of an annotation to use any of the available system fonts. To make font handling even simpler, we added the FontManager class, which will help with fetching the list of available Fonts on the current device:

val fontManager = PSPDFKit.getSystemFontManager()
val fonts = fontManager.availableFonts

// Set the name of a font to use it for the annotation.
freetextAnnotation.fontName = fonts.first().name
final FontManager fontManager = PSPDFKit.getSystemFontManager();
final List<Font> fonts = fontManager.getAvailableFonts();

// Set the name of a font to use it for the annotation.
freetextAnnotation.setFontName(fonts.get(0).name);

In the user interface, we added a new FontPickerInspectorView for the annotation inspector, which is used for selecting from the existing system fonts.

Free fext fonts

And Much More

We hope you like the changes that come along with PSPDFKit 4.8 for Android — rest assured there is more great stuff lined up for upcoming releases. To see a comprehensive list of changes in this release, check out the PSPDFKit 4.8 for Android changelog.

Explore related topics

Free trial Ready to get started?
Free trial