Getting Started
Copy a setup prompt with the install steps and the full markdown guide for this plugin.
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-pdf-viewer`
Run the required Capacitor sync/update step after installation.
Read this markdown guide for the full setup steps: https://raw.githubusercontent.com/Cap-go/website/refs/heads/main/apps/docs/src/content/docs/docs/plugins/pdf-viewer/getting-started.mdx
Use that guide for platform-specific steps, native file edits, permissions, config changes, imports, and usage setup.
If that guide references other docs pages, read them too.
Install
Section titled “Install”You can use our AI-Assisted Setup to install the plugin. Add the Capgo skills to your AI tool using the following command:
bunx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-pluginsThen use the following prompt:
Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-pdf-viewer` plugin in my project.If you prefer Manual Setup, install the plugin by running the following commands and follow the platform-specific instructions below:
bun add @capgo/capacitor-pdf-viewerbunx cap syncImport
Section titled “Import”import { PdfViewer } from '@capgo/capacitor-pdf-viewer';Quick start
Section titled “Quick start”import { PdfViewer } from '@capgo/capacitor-pdf-viewer';
const result = await PdfViewer.open({ source: 'https://example.com/manual.pdf', headers: { Authorization: 'Bearer token' }, mode: 'fullscreen',});Common pitfalls
Section titled “Common pitfalls”- Listeners: remove handles when screens unmount.
- Native sync: run
bunx cap syncafter plugin upgrades. - Source of truth: trust
src/definitions.tsin the GitHub repo.
Platform setup
Section titled “Platform setup”- iOS setup (PDFKit, no extra plist keys).
- Android setup (Pdfium,
INTERNETfor HTTPS sources).
import { PdfViewer } from '@capgo/capacitor-pdf-viewer';
await PdfViewer.addListener('pageChange', ({ page, pageCount }) => { console.log(`Page ${page} of ${pageCount}`);});
const { pageCount } = await PdfViewer.open({ source: 'https://example.com/manual.pdf', headers: { Authorization: 'Bearer YOUR_TOKEN' }, mode: 'fullscreen', scrollMode: 'continuous', page: 1,});
console.log(`Opened ${pageCount} pages`);// Call PdfViewer.close() when the user dismisses the viewer or you navigate away.