Custom server sampleskeyboard_arrow_down

Custom server samples

In this document
chevron_rightAnnotations
chevron_rightForms
chevron_rightCustomize UI
chevron_rightText manipulation
chevron_rightOther
chevron_rightSample projects

These samples load pre-converted documents like in a custom server setup. The code for each of the samples is included in the WebViewer download package.

linkBasic viewer

This sample shows how to load a WebViewer instance. It also shows how to customize the page to load different files.

linkCross-origin resource sharing

This sample shows how WebViewer can be hosted on a different server than the actual documents. Here, the document files are fetched from Amazon S3. The server hosting the files must support CORS.

linkWebViewer.js custom controls

This sample shows how to use the WebViewer.js controller (JavaScript API) to create an instance of WebViewer with custom controls.

linkAnnotations

linkAnnotation user permissions

This sample shows how WebViewer handles user permissions for annotations. When an annotation user is set, the client-side end users can only modify annotations that were created by them.

Users can also be given administrative access, which allows modifications to annotations created by any users. Lastly, WebViewer can also be loaded in read-only mode, which allows existing annotations to be displayed but users will not be allowed to create new annotations.

linkRealtime collaboration

This sample shows how the setup HTML5 WebViewer to have realtime syncing of annotations with a server. This example uses Firebase as an example backend. The sample source file main.js and server.js include code that defines how to import/export annotations and add event listeners to annotation add/edit/delete events.

Sources: main.js, server.js

linkHide/Show annotations of specific users

This sample shows how annotations from specific users can be hidden and shown. This could allow you to only display annotations from the current user for example.

Source: config.js

linkStamp annotation from image

This sample shows how a stamp annotation can have an image associated with it.

Source: config.js

linkCustom Annotations

This sample shows how the HTML5 WebViewer can be extended with custom annotations and tools via the Annotation Framework. A custom tool is added to the annotation panel to create a diamond annotation. The sample source file diamond.js includes code that defines the appearance of the annotation, as well as the selection box and control handle behaviors.

Source: diamond.js

linkAnnotation support

This sample shows the HTML5 WebViewer's out-of-the-box support for annotations. WebViewer supports the creation of many annotation types, such as: line, ellipse, text highlight and underline (among others). By default, all WebViewer annotations are compatible with PDF annotations and vice versa (WebViewer annotations can be imported from and exported to the XFDF XML format).

linkForms

linkCustomize forms

This sample shows how to customize the styles of form fields. It changes the colors of text fields and buttons dynamically.

Source: config.js

linkForm actions

This sample demonstrates the different form actions that are supported by WebViewer. Actions should be added to fields in the PDF document.

linkForm support

This sample shows how the HTML5 WebViewer supports PDF form actions. Form submit actions can be directly to a server from the WebViewer. To see it live, fill in some data in the text boxes and click submit at the bottom of the document.

linkCustomize UI

linkCustomize signature

This sample shows how to customize the signature tool. It draws a custom background on the signature menu and then saves and loads the default signature from localStorage.

Source: config.js

linkCustom horizontal display mode

This sample shows how to create a custom display mode by overriding display mode functions. The sample creates a basic horizontal layout.

Source: config.js

linkCustomization: UI controls

This sample shows how the HTML5 WebViewer can be customized in a clean and simple manner. Through an external configuration script that can be loaded at run-time, the WebViewer's theme, branding, or even default behaviors can be changed.

Source: config.js

linkText manipulation

linkGet text position

This sample shows how to get the positions of characters on a page. It then adds highlight annotations over instances of the word WebViewer.

Source: config.js

linkAccessible viewer demo

This sample shows how page text can be loaded to create a basic accessible document viewer. Only the document's text is displayed, with headings for each page.

linkOther

linkOffline library

This sample shows how to use HTML5's application cache with WebViewer's offline mode to download documents and then view them offline.

Source: offline-sample.appcache

linkOffline mode

This sample shows how a document can downloaded for offline viewing. Once the download button is clicked, the xod document will be downloaded and saved within the browser's internal database. Offline viewing mode can be turned on once the xod document has finished downloading.

linkInternationalization support

This sample shows how the HTML5 WebViewer supports internationalization. Additional custom translations can be easily added by copying and modifying the English translation json file.

Source: config.js

linkEncryption support

This sample shows the HTML5 WebViewer loading an encrypted XOD document. This WebViewer loads a custom configuration file that includes a handler for decrypting encrypted XOD files.
The password for this sample is foobar.

Download the XOD document loaded by the viewer, see that the content is encrypted: tiger-encrypted.xod
Source: config.js

linkDeck.js slideshow demo

This sample shows how the HTML5 WebViewer can be integrated with the deck.js project to create a slideshow from a document. Please note that there were some customizations done to the scale extension.

linkFlipbook demo

This sample shows how the HTML5 WebViewer can be modified to display documents in a flipbook style. Place your mouse near a page corner and then click and drag to change pages.

Note that this sample shows how the core document viewing component can be used outside of WebViewer.js and any UI controls would have to be implemented independently.

linkSample projects

Find these projects inside the samples folder of the WebViewer download package.

linkAngular

This sample shows how to integrate WebViewer into an Angular application. It creates a component for WebViewer and shows how you can interact with the WebViewer API from other components.

Sources: webviewer.component.ts, app.component.ts

linkCordova integration

This sample shows how to integrate the HTML5 WebViewer with Cordova to allow you to create native applications. You can find instructions on how to set it up in the README.txt file in the sample folder.

Cordova Resources: Documentation

linkNative WinRT app

This sample shows how to integrate the HTML5 WebViewer in a native WinRT app. WebViewer is packaged directly in the WinRT app, where it can be loaded by the WebView control. Using a custom JavaScript part retriever, WebViewer is able to load XOD documents from the local file system.

WinRT Resources: Getting started

linkNative iOS app

This sample shows how to integrate the HTML5 WebViewer in a native iOS application. The WebViewer is packaged directly in the iOS application, where it can be loaded by the UIWebView control. Using a custom JavaScript part retriever, the WebViewer is able to communicate with Objective-C and load XOD documents from the local file system.

iOS Resources: Getting started

linkNative Android app

This sample shows how to integrate WebViewer.js in a native Android application. The WebViewer is packaged directly as an asset in an Android application, where it can be loaded by the WebView control. Using a custom ContentProvider, the WebViewer is able to load XOD documents from the local file system.

Android Resources: Getting started