Explore Android PDF development with practical code samples
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 Selection Styling
Customize annotation selection handle drawables and border colors via theming.Annotation Toolbar: Custom Items
Add custom items to the annotation creation toolbar bound to specific tools and variants.Annotation Toolbar: User-Editable Tools
Pick and arrange annotation tools with drag and drop: a bottom sheet lists every tool — tap to show or hide it on the bar, long-press and drag to plac...Bookmark Highlighting
Display bookmark indicators on pages in the thumbnail bar and grid using PdfDrawableProvider.Compose PDF Viewer
A complete Compose viewer app: recent documents with page thumbnails, system file import, light/dark/dynamic-color settings, and a host-rendered main ...Construction Floor Plan
Display a building floor plan with custom pin stamps, hide/show annotations, and a custom toolbar.Custom Annotation Inspector
Customize the annotation property inspector with custom property options.Custom Electronic Signature
Build a custom ink signature flow with ElectronicSignatureFragment in a PdfFragment activity.Custom Layout
Build a custom activity layout with PdfFragment, a navigation drawer, and next/previous buttons.Custom Note Hinter
Display custom note indicator drawables on ink annotations using PdfDrawableProvider.Custom Settings, Info and Outline UI
Replaces the settings, document info and outline screens with your own UI, reading and writing the SDK data through public API only.Digital Signature (Basic)
Sign a document with the built-in signing flow. Supports basic CMS and advanced PAdES. Certificate password: testDigital 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.DocumentView in a Dialog
Preview a document with the DocumentView composable hosted in a Navigation Compose dialog destination.Dynamic Pages on Scroll
Detect when a document is scrolled to the end and dynamically add a new page.Electronic + Digital Signing
Combine an electronic signature created with ElectronicSignatureDialog with a certificate-based digital signature.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.Fragment Runtime Configuration
Change PdfFragment configuration at runtime, including scroll direction and night mode.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.Main Toolbar: Custom Layout & Items
Mount the main toolbar in your own rounded, elevated container with a custom color scheme, and add a custom item that resizes it.Main Toolbar: FAB Menu (M3 Expressive)
Toolbar actions as a Material 3 Expressive FAB menu: the collapsed FAB shows the active item, tapping it expands the labeled action list, and long-pre...Main Toolbar: Floating Pill (M3 Expressive)
Material 3 Expressive floating toolbar: drag the pill to dock it at any window edge, horizontally or vertically — or switch it into the collapsible va...Measurement Tools
Create and read measurement annotations with scale calibration and precision settings.Memory Pressure Recovery
Simulate critical memory pressure on heavy documents and observe render abort, backoff, and automatic recovery.Popup Toolbar: Custom Items
Customize popup toolbars for text selection, annotation selection, long-press, and content editing.Replace and Refresh Documents
Swap the displayed document or reload the current one on a hoisted DocumentState with setCustomPdfSource — without recreating the DocumentView.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.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.Split Screen (Compose)
Show two documents side by side with two DocumentView composables, each with its own configuration.Tabbed Documents (Compose)
Render a floating-pill main toolbar with a rounded, spaced NutrientTabBar below it above a DocumentView, and open more documents into it.| Title | Description |
|---|---|
| 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. |
| Annotation Toolbar: Custom Items | Add custom items to the annotation creation toolbar bound to specific tools and variants. |
| Annotation Toolbar: Item Grouping | Reorganize contextual menu items on the annotation toolbar. |
| Annotation Toolbar: User-Editable Tools | Pick and arrange annotation tools with drag and drop: a bottom sheet lists every tool — tap to show or hide it on the bar, long-press and drag to plac... |
| 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. |
| Compose PDF Viewer | A complete Compose viewer app: recent documents with page thumbnails, system file import, light/dark/dynamic-color settings, and a host-rendered main ... |
| Construction Floor Plan | Display a building floor plan with custom pin stamps, hide/show annotations, and a custom toolbar. |
| Custom Activity Form Editing | Add form editing UI to a custom activity built around PdfFragment. |
| 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 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 Settings, Info and Outline UI | Replaces the settings, document info and outline screens with your own UI, reading and writing the SDK data through public API only. |
| 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. |
| 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. |
| DocumentView in a Dialog | Preview a document with the DocumentView composable hosted in a Navigation Compose dialog destination. |
| 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. |
| 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. |
| Main Toolbar: Custom Layout & Items | Mount the main toolbar in your own rounded, elevated container with a custom color scheme, and add a custom item that resizes it. |
| Main Toolbar: FAB Menu (M3 Expressive) | Toolbar actions as a Material 3 Expressive FAB menu: the collapsed FAB shows the active item, tapping it expands the labeled action list, and long-pre... |
| Main Toolbar: Floating Pill (M3 Expressive) | Material 3 Expressive floating toolbar: drag the pill to dock it at any window edge, horizontally or vertically — or switch it into the collapsible va... |
| Measurement Tools | Create and read measurement annotations with scale calibration and precision settings. |
| Memory Pressure Recovery | Simulate critical memory pressure on heavy documents and observe render abort, backoff, and automatic recovery. |
| 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: Custom Items | 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. |
| Replace and Refresh Documents | Swap the displayed document or reload the current one on a hoisted DocumentState with setCustomPdfSource — without recreating the DocumentView. |
| 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 Screen (Compose) | Show two documents side by side with two DocumentView composables, each with its own configuration. |
| Split View | Display two PdfFragment instances side by side in a single activity. |
| Tabbed Documents (Compose) | Render a floating-pill main toolbar with a rounded, spaced NutrientTabBar below it above a DocumentView, and open more documents into it. |
| 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. |