Skip to main content
Version: Version 5

Type Alias: ViewerConfig

ViewerConfig = object

Represents the configuration options for initializing the PDF viewer.

Properties

accessibilityLayerEnabled?

optional accessibilityLayerEnabled?: boolean

Whether to enable the accessibility layer. This improves accessibility for users with disabilities.


customThemes?

optional customThemes?: Record<string, DeepPartial<SemanticTheme>>

Custom themes to register at initialization. Keys are theme names, values are partial semantic theme definitions.

Example

customThemes: {
corporate: {
interactive: { primary: '#003366' }
},
'corporate-dark': {
background: { primary: '#1a1a2e' },
interactive: { primary: '#6699FF' }
}
}

customTranslations?

optional customTranslations?: Record<string, PartialTranslationMap>

Custom translations to add or override existing translations. Keys are locale codes (e.g., ‘en’, ‘de’, ‘fr’), values are translation maps.

Use this to:

  • Add a completely new language
  • Override specific translations in existing languages

Examples

// Add Spanish
customTranslations: {
es: {
'toolbar.button.open': 'Abrir',
'toolbar.button.save': 'Guardar',
// ... all other keys
}
}
// Override specific English translations
customTranslations: {
en: {
'toolbar.button.open': 'Open File',
'toolbar.button.save': 'Save Document'
}
}

devicePixelRatio?

optional devicePixelRatio?: number

The device pixel ratio (DPR) setting for rendering the PDF. Higher values result in better quality but may impact performance.


disableMultipleImageInsert?

optional disableMultipleImageInsert?: boolean

Whether to disable inserting multiple images in succession. When set to true, the image annotation plugin will deactivate after each insertion, returning the user to text selection mode. Defaults to false.


hidePasswordDialogCancelButton?

optional hidePasswordDialogCancelButton?: boolean

Whether to hide the cancel button in the password dialog. If set to true, the cancel button will not be shown, forcing users to enter a password to proceed. Defaults to false.


inputDocument?

optional inputDocument?: InputFile | InputUri

An optional input document to open in the viewer upon initialization. This can be either a file or a URI. If provided, the viewer will automatically load and display this document when it is initialized.


licenseKey?

optional licenseKey?: LicenseKey

License key for the PDF viewer. This is required for the viewer to function properly. You can obtain a license key from the PDF Tools website. If you are using a trial version of the viewer, you can use the staging license key provided in the documentation, but keep in mind that it will add a watermark to the documents.


licenseUrl?

optional licenseUrl?: string

URL to fetch the license key from. This is required if you are using a license key that needs to be fetched from a server. The viewer will request this URL to retrieve the license key during initialization.


locale?

optional locale?: LocaleCode | string & Record<never, never>

The locale (language) to use in the Viewer.

  • Specific locale: 'en' (English), 'de' (German), 'fr' (French)
  • Auto-detect: 'auto' - detects from browser language
  • Custom locale: any string for custom-added locales
  • Default: 'auto'

Example

locale: 'de'; // German
locale: 'auto'; // Auto-detect from browser

path?

optional path?: string

Path to the worker script. This is required for the viewer to function properly, as it uses a web worker for rendering and processing PDF documents.


producerSuffix?

optional producerSuffix?: string

Suffix to append to the producer string in the PDF metadata.


promptOnUnsavedChange?

optional promptOnUnsavedChange?: boolean

Whether to prompt the user when attempting to close or navigate away with unsaved changes. Defaults to true.


theme?

optional theme?: ThemeName | string & Record<never, never>

The theme to use in the Viewer.

  • Built-in themes: 'light' and 'dark'.
  • Auto mode, 'auto', follows the system preference.
  • Custom theme name can be any string for themes registered via customThemes option.

Default Value

'auto'

Examples

// Use dark theme
theme: 'dark';
// Follow the system preference
theme: 'auto';
// Use custom theme (must be registered in customThemes)
theme: 'corporate',
customThemes: {
corporate: { interactive: { primary: '#003366' } }
}

useInitialDestination?

optional useInitialDestination?: boolean

Controls whether to automatically navigate to the PDF’s initial destination when the document view is initialized. If the PDF does not have an initial destination, this option has no effect.

Default Value

false


user?

optional user?: string

An optional user identifier to associate with the viewer session. If not specified, the viewer will use a default user identifier.


zoomLevels?

optional zoomLevels?: number[]

Custom zoom levels for the viewer. This allows you to specify the zoom levels that will be available in the viewer’s zoom dropdown. The values should be numbers representing the zoom percentage (e.g., 1 for 100% zoom, 1.5 for 150% zoom, 0.25 for 25% zoom). If not specified, the viewer will use default zoom levels.