Viewer Options
JavaScript
const config = {documentId: 'your-document-number',darkMode: true,themeColor: '#FF0000',defaultScale: 'AUTOMATIC',appBarColored: true,disableElements: ['darkmode']};CloudPDF(config, document.getElementById('viewer')).then((instance) => {});
documentIdAfter uploading your document to CloudPDF, you will receive a documentId. Learn how to upload a document?darkMode(default: false): Toggle between light and dark mode by setting this variable totrueorfalse.themeColorCustomize the theme color using a hex code (e.g.,"#FF0000").defaultScaleSets the default scale of the viewer to 'AUTOMATIC', 'FIT_PAGE', 'FIT_WIDTH', or a number representing the percentage to scale the document. For example, settingdefaultScaleto 1 scales the document to 100%.appBarColored(default: false): If set to true, the PDF viewer's toolbar will adopt the theme color.disableElementsUse an array to disable specific UI elements: darkmode, fullscreen, download, search, zoom-in, zoom-out, scale-dropdown, sidebar.disableToolbarSet to true to hide the toolbar.token(optional): For public documents, a security token is not required. By default, documents are private and you will need to generate a token.
Adjusting Viewer Settings After Initialization
Even after initializing the CloudPDF viewer, you can easily modify its settings to customize your experience. Here are some examples of how you can make adjustments to the viewer after the initial setup:
Loading a different document
You can load another document into the viewer by calling the loadDocument method on the instance:
JavaScript
instance.loadDocument({documentId: 'a9658aef-c513-4130-afbf-77f3fc19e0e7'});
Changing the dark mode setting
You can toggle the dark mode setting on and off by calling the setDarkMode method on the instance:
JavaScript
instance.setDarkMode(false);
Changing the theme color
You can modify the theme color by calling the setThemeColor method on the instance:
JavaScript
instance.setThemeColor('#ff0000');