Skip to content

PDF Viewer

PDF Viewer is a PDF reader for viewing and managing PDF documents. Protocol Launcher allows you to generate PDF Viewer URL scheme links.

PDF Viewer's official URL scheme action form is pdfviewer://x-callback-url/[action]?[action parameters]&[x-callback parameters]. The official FAQ documents open-file and add-file action parameters.

Usage

There are two ways to use this library:

  • On-Demand import from subpaths enables tree-shaking and keeps bundles small.
  • Full Import from the root package is convenient but includes all app modules.

Pick On-Demand for production builds; Full Import is fine for quick scripts or demos.

Select Installation Method

On-Demand
Recommended. Optimized for production.
Full Import
Convenient. Good for quick scripts.

Open File

Open a local file from the documented path parameter.

On-Demand
ts
import { openFile } from 'protocol-launcher/pdf-viewer'

const url = openFile({
  path: '/Quick Start.pdf',
})

Add File

Store a file, or download from url, locally as filename.

On-Demand
ts
import { addFile } from 'protocol-launcher/pdf-viewer'

const url = addFile({
  open: true,
  url: 'https://pspdfkit.com/downloads/case-study-box.pdf',
})

Both data and filename are required to add a file from base64 data. The generated URL encodes the data parameter.

On-Demand
ts
import { addFile } from 'protocol-launcher/pdf-viewer'

const url = addFile({
  open: false,
  filename: 'Document.pdf',
  data: 'JVBERi0xLjMKJcTl8uXrp/Og0MTGCg==',
})

References