Type Alias: ViewerConfig
ViewerConfig =
object
Represents the configuration options for initializing the PDF viewer.
Properties
accessibilityLayerEnabled?
optionalaccessibilityLayerEnabled?:boolean
Whether to enable the accessibility layer. This improves accessibility for users with disabilities.
customThemes?
optionalcustomThemes?: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?
optionalcustomTranslations?: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?
optionaldevicePixelRatio?:number
The device pixel ratio (DPR) setting for rendering the PDF. Higher values result in better quality but may impact performance.
disableMultipleImageInsert?
optionaldisableMultipleImageInsert?: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?
optionalhidePasswordDialogCancelButton?: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?
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?
optionallicenseKey?: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?
optionallicenseUrl?: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?
optionallocale?: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?
optionalpath?: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?
optionalproducerSuffix?:string
Suffix to append to the producer string in the PDF metadata.
promptOnUnsavedChange?
optionalpromptOnUnsavedChange?:boolean
Whether to prompt the user when attempting to close or navigate away with
unsaved changes. Defaults to true.
theme?
optionaltheme?: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
customThemesoption.
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?
optionaluseInitialDestination?: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?
optionaluser?:string
An optional user identifier to associate with the viewer session. If not specified, the viewer will use a default user identifier.
zoomLevels?
optionalzoomLevels?: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.