This HTML page is not optimized for LLM or AI agent consumption. Fetch the Markdown version instead: /guides/android/samples.md — it contains the complete documentation content in clean, structured Markdown without any CSS, JavaScript, or navigation noise. Android PDF code samples and guides

Add LTV to Existing Signature

Open an already-signed document and add LTV data to the existing signature.

AES Encrypted File

Open AES-encrypted PDFs using a custom DataProvider without decrypting to disk first.

AI Assistant (Multiple Documents, Compose)

AI-powered document chat across multiple documents using a Compose HorizontalPager. Requires the AI Assistant demo server running locally.

AI Assistant (Multiple Documents, ViewPager)

AI-powered document chat across multiple documents using ViewPager2 and PdfFragment. Requires the AI Assistant demo server running locally.

AI Assistant (Single Document)

AI-powered document chat using the Compose API. Requires the AI Assistant demo server running locally.

Annotation Configuration

Customize default properties and editable properties for each annotation type.

Annotation Creation

Programmatically create highlights, notes, free text, stamps, and ink annotations.

Annotation Flags

Set annotation flags: read-only, hidden, no-zoom, no-rotate, locked, and more.

Annotation Overlay

Display annotations in overlay mode as separate Android Views above the page.

Annotation Rendering

Exclude specific annotation types from rendering.

Annotation Selection Styling

Customize annotation selection handle drawables and border colors via theming.

Annotation Sidebar

Display a persistent sidebar listing all annotations with tap-to-navigate.

Annotations with Transparency

Create annotations with configurable alpha transparency.

Application Policy

Restrict text copy/paste using a custom ApplicationPolicy.

Bookmark Highlighting

Display bookmark indicators on pages in the thumbnail bar and grid using PdfDrawableProvider.

Compose Image Document

Load and display an image document with the DocumentView composable.

Compose Navigation

Use the DocumentView composable within a Jetpack Compose NavHost.

Construction Floor Plan

Display a building floor plan with custom pin stamps, hide/show annotations, and a custom toolbar.

Custom ActionBar Actions

Customize the default set of ActionBar icons to fit your app.

Custom Activity Form Editing

Add form editing UI to a custom activity built around PdfFragment.

Custom Activity Toolbars

Add toolbars to a custom activity built around PdfFragment.

Custom Annotation Creation Toolbar

Add custom items to the annotation creation toolbar bound to specific tools and variants.

Custom Annotation Inspector

Customize the annotation property inspector with custom property options.

Custom Data Provider

Implement a custom DataProvider to load a PDF from app resources.

Custom Download Dialog

Build a custom DownloadProgressFragment for document downloads.

Custom Electronic Signature

Build a custom ink signature flow with ElectronicSignatureFragment in a PdfFragment activity.

Custom Form Highlight Color

Toggle the form field highlight color on and off.

Custom Layout

Build a custom activity layout with PdfFragment, a navigation drawer, and next/previous buttons.

Custom Main Toolbar

Use PdfUiFragment in an AppCompatActivity with custom main toolbar actions.

Custom Note Hinter

Display custom note indicator drawables on ink annotations using PdfDrawableProvider.

Custom Outline Provider

Display a custom document outline with custom elements and actions.

Custom Page Templates

Add custom page templates to the NewPageDialog.

Custom Search UI (Compose)

Build a fully custom Compose search UI on top of the search APIs.

Custom Search UI (Views)

Build a fully custom View-based search UI on top of the search APIs.

Custom Sharing Dialog

Build a fully custom document sharing dialog.

Custom Sharing Menu

Build a custom share menu with custom action items.

Custom Stamp Annotations

Customize the default set of stamps available in the StampPickerDialog.

Custom Toolbar Grouping

Reorganize contextual menu items on the AnnotationToolbar.

Digital Signature (Basic)

Sign a document with the built-in signing flow. Supports basic CMS and advanced PAdES. Certificate password: test

Digital Signature (Manual)

Digitally sign a document using a custom signing callback and private key.

Digital Signature (Third-Party)

Digitally sign a document with a PKCS#7 signature produced by an external signing provider.

Digital Signature (Two-Step)

Split digital signing into hash generation and signature embedding for external signing flows.

Disabled Annotation Property

Remove the annotation note option from the annotation editing toolbar.

Document Comparison

Compare two PDFs side-by-side with different stroke colors for each document.

Document Download

Download a PDF from a URL and display download progress.

Document from Canvas

Create a PDF programmatically by drawing on an Android Canvas.

Document Processing

Process PDFs with PdfProcessor to rotate, flatten, remove pages, and more.

Document Sharing

Add custom document-sharing actions for PDF documents.

Document Switcher

Switch between documents using a side navigation drawer.

DocumentView Composable

Integrate the DocumentView composable into a Jetpack Compose app.

Download Progress

Show download progress while loading a remote PDF using ProgressDataProvider.

Dynamic Pages on Scroll

Detect when a document is scrolled to the end and dynamically add a new page.

E-Learning

Switch between documents while preserving view state, annotations, and bookmarks.

Electronic + Digital Signing

Combine an electronic signature created with ElectronicSignatureDialog with a certificate-based digital signature.

External Document

Pick and open a document from the device file system.

File Annotation Creation

Embed PDF, image, video, and text files as file annotations.

Filterable Thumbnail Grid

Filter the thumbnail grid to show all pages, annotated pages only, or bookmarked pages only.

Form Click Intercept (Compose)

Intercept form element clicks using the DocumentView composable with custom listeners.

Form Creation

Create text fields, checkboxes, radio buttons, and combo boxes with PdfProcessor.

Form Filling

Fill text fields, checkboxes, and radio buttons programmatically using FormProvider.

Forms with JavaScript

Create form fields with JavaScript actions for calculations and formatting.

Fragment Runtime Configuration

Change PdfFragment configuration at runtime, including scroll direction and night mode.

Generate PDF Report

Create a PDF report using PdfProcessor. Password: password

Hide and Reveal Areas

Select areas on a page to hide or reveal content.

HTML-to-PDF Conversion

Convert an HTML file to a PDF document.

Image Document

Open an image as a document with ImageDocumentLoader and image-optimized UI.

Inline Multimedia

Play videos and browse galleries embedded within a PDF document.

Inline Search

Embed PdfSearchViewInline in a custom layout for integrated in-document search.

Instant Document JSON

Export and import document annotations in Instant Document JSON format.

Instant JSON Attachment

Export and import binary attachment data for image stamps in Instant JSON format.

JavaScript Actions

Create and execute JavaScript actions: alerts, page navigation, and form field queries.

JavaScript Calculator

Build a calculator entirely in PDF JavaScript to demonstrate advanced form interactions.

JavaScript Form Filling

Fill form fields programmatically using JavaScript actions.

Kiosk Grid

Browse documents from the assets folder in a grid with thumbnail previews.

LTV Signature

Create a PAdES signature with Long-Term Validation (LTV) and timestamp data.

Measurement Tools

Create and read measurement annotations with scale calibration and precision settings.

Merge Documents

Merge multiple PDF files into one using PdfProcessor.

Multimedia Annotations

Add video and gallery link annotations to a document at runtime.

Multiple Documents (Compose Pager)

Swipe between multiple PDFs with a Compose HorizontalPager.

OCR

Run optical character recognition (OCR) on a document to make it searchable.

Overlay Views

Add custom Android Views over PDF pages with OverlayViewProvider.

Overlay Visibility

Toggle visibility of annotation overlays at runtime.

Password Protected PDF

Open a password-protected PDF document. Password is: test123

PDF from Image

Capture an image with the camera and convert it to a PDF.

PdfFragment

Set up PdfFragment in a custom activity with a document listener.

PdfUiFragment

Display documents using PdfUiFragment — the recommended fragment-based integration.

Playground

Configure PdfActivity interactively and preview the result.

Popup Toolbar Customization

Customize popup toolbars for text selection, annotation selection, long-press, and content editing.

Programmatic Zoom

Navigate between annotations with animated zoom using PdfFragment.zoomTo().

Reader View

Reflow document content into an easy-to-read continuous text format.

Remote URL

Download and display a remote PDF with UrlDataProvider and WebView link interception.

Runtime Configuration

Toggle scroll mode, scroll direction, and night mode at runtime in PdfActivity.

Scientific Paper

Configure continuous scrolling, persistent UI, and page fit for reading long documents.

Screen Reader

Read document text aloud and highlight each word as it is spoken.

Search Indexing

Index PDF assets and search them with PdfLibrary and LibraryFileSystemDataSource.

Selection Customization

Customize annotation selection behavior and appearance.

Signature Parcelize

Create a stamp signature and verify it parcelizes correctly when passing between activities.

Signature Storage Database

Store and retrieve electronic signatures using a SQLite-based DatabaseSignatureStorage.

Sound Extraction

Add a sound annotation and extract the audio data to a .wav file.

Split View

Display two PdfFragment instances side by side in a single activity.

Tabbed Documents

Open multiple documents in a tabbed interface using DocumentCoordinator.

Tabbed Documents (Persistent)

Retain the list of open document tabs across activity recreation.

Text Field Suggestions

Provide autocomplete suggestions for specific text form fields.

Thumbnail Bar Modes

Toggle between thumbnail bar modes: Floating, Pinned, Scrollable, and None.

Try Instant

Download a document for collaborative editing.

UI View Modes

Switch between automatic, visible, hidden, and manual user interface modes.

Vertical Scrollbar

Add a VerticalScrollBar widget for quick page navigation.

Watermarks

Add page watermarks using the PdfDrawable API on the fragment, thumbnail bar, and grid.

XFDF Import/Export

Export and import annotations in XFDF format.