Samples

Accessibility

JavaScript

Demonstrates how to use accessibility feature of WebViewer to read PDF text out loud.

AddImage

JavaScript

This sample illustrates how to embed various raster image formats (e.g. TIFF, JPEG, JPEG2000, JBIG2, GIF, PNG, BMP, etc.) in a PDF document.

Angular

Github repo that demonstrates how to integrate WebViewer into an Angular project.

Annotate HTML web pages

In this example, you are able to pass any URL and be able to save a copy of that website to annotate.

Annotation

JavaScript

Shows how to add a text annotation to an existing page and how to create link annotations between several pages.

Bookmark

JavaScript

The sample code illustrates how to read and edit existing outline items and create new bookmarks using the high-level API.

Color separation

JavaScript

Shows how to get each color's information. You can also show/hide specific colors.

Content Editing (text and images)

JavaScript

Edit the content of a PDF document directly.

ContentReplacer

JavaScript

The sample demonstrates replacement of objects such as images, text and strings within a document.

Custom annotations

JavaScript

Shows how to create and add custom annotations by extending the existing annotation classes.

Customizing UI

JavaScript

Shows how to customize the UI using WebViewer APIs. Includes modifying header, enabling/disabling features and hiding/showing individual elements.

Customizing form fields

JavaScript

Shows how to change color and opacity of form fields.

Diff documents

JavaScript

Shows how to render three synchronized panels where the middle panel shows pixel differences between the two documents.

DigitalSignature

JavaScript

Demonstrates how to digitally sign a PDF and also how to certify a PDF doc.

Document assembly from multiple viewers

Shows how to implement a dropzone to be able to drag and drop pages from multiple viewer instances.

Electron

Github repo that demonstrates how to integrate WebViewer into an Electron project.

ElementBuilder

JavaScript

Illustrates how to use PDFNet page writing API, how to embed fonts and images and how to copy graphical elements from one page to another.

ElementEdit

JavaScript

The sample code shows how to edit the page display list and how to modify graphics state attributes on existing Elements. In particular the sample program strips all images from the page and changes text color to blue.

ElementReader

JavaScript

Illustrates how to traverse page display list using ElementReader.

Encryption

JavaScript

Demonstrates how to encrypt and decrypt files by adding or removing passwords.

Flipbook

JavaScript

Demonstrates how to extract canvas of each page. The sample uses turn.js to render them.

Form Builder Demo

JavaScript

This sample demonstrates how to add form fields to a PDF. Fields are first added as annotations and then converted to interactive form fields. Add signatures, text fields, checkboxes.

InteractiveForms

JavaScript

Illustrates how to create and edit interactive forms (check boxes and text boxes).

Internationalization

JavaScript

Shows how to switch language.

Layer separation

JavaScript

Shows how to get each layer's information. You can also show/hide specific layers.

LogicalStructure

JavaScript

This sample illustrates how to traverse the structure and content of a tagged PDF document.

Measurement annotations

JavaScript

Shows how to create annotations that measure distance, perimeter and area.

NuxtJS

Github repo that demonstrates how to integrate WebViewer into NuxtJS project.

Office template filling

JavaScript

Bind templates to content in .docx and .xlsx files.

Office to PDF

JavaScript

This sample illustrates how to convert office files to PDF.

Offline

Demonstrates how to use ServiceWorker to use WebViewer offline.

Optimizer

JavaScript

The sample illustrates how to reduce PDF file size using 'pdftron.PDF.Optimizer'. It also shows how to simplify and optimize PDF documents for viewing on mobile devices and on the Web using 'pdftron.PDF.Flattener'.

PDFA

JavaScript

This sample demonstrates PDFA verification and conversion.

PDFDraw

JavaScript

This sample illustrates how to use the built-in rasterizer in order to render PDF images on the fly and how to save resulting images in PNG and JPEG format.

PDFLayers

JavaScript

This sample demonstrates how to create PDF layers (also known as Optional Content Groups - OCGs). The sample also shows how to extract and render PDF layers.

PDFPage

JavaScript

The sample illustrates how to copy pages from one document to another, how to delete, and re-arrange pages and how to use ImportPages() method for very efficient copy and merge operations.

PDFRect

JavaScript

The sample illustrates how to translate a PDF image by extracting and manipulating the image's media box.

PDFRedaction

JavaScript

The sample illustrates how to create Redaction objects and use PDFNetJS's redact function to remove and overlay PDF document content.

Page operations

JavaScript

Shows how to rotate/crop/add/delete page, change page order, insert blank pages and merge multiple documents.

Preloading

JavaScript

Shows how to preload WebViewer and documents to improve user experience.

React

Github repo that demonstrates how to integrate WebViewer into a React project.

ReaderModeTest

JavaScript

This sample demonstrates Reader Mode in WebViewer.

Realtime collaboration - Firebase

JavaScript

An example setup with Firebase backend. For more details, refer to realtime collaboration guide .

Realtime collaboration - Node.js

An example setup with Node.js backend.

Redact people faces from PDF

JavaScript

Shows how to automatically detect and redact people faces from documents.

Redaction

JavaScript

Shows how to redact and permanently remove text, images or graphics from a document.

SDFTest

JavaScript

The sample illustrates how to extract an SDF document from a PDF document and change some of its values.

Salesforce

Github repo that demonstrates how to integrate WebViewer into Salesforce as a Lightning Web Component.

Sign App

Demonstrates building a signing application where users can request signatures on the documents by placing fields, sign documents, review signed documents.

Stamper

JavaScript

The sample code illustrates how to stamp text and images onto various pages in a PDF document.

Svelte

Github repo that demonstrates how to integrate WebViewer into Svelte project.

Text position

JavaScript

Shows how to extract text positions from a document. The sample highlights the positions with different colors.

TextExtraction

JavaScript

The sample demonstrates how to extract information from text boxes such as their position, font, size, color and of course the text itself.

TextSearch

JavaScript

The sample demonstrates how to search using strings and regular expressions in a PDF document and how to set search mode and parameters.

Thumbnail controls

JavaScript

Shows how to use thumbnail controls for page manipulation of documents. Note that this is only enabled for client side PDF and Office documents.

Users and permissions

JavaScript

Describes types of permissions and switching between users. You can also show/hide annotations of specific users.

Video annotations

Allows the functionality of annotating video frames.

Viewer optimized PDFs

JavaScript

Compares viewing an unoptimized PDF with the same viewer optimized PDF side by side

ViewerCustomSave

JavaScript

This sample demonstrates how to customize document save/download. In the example annotations are flattened before saving.

ViewerDigitalSignatureValidationTest

JavaScript

This sample illustrates how PDFNetJS can be used to validate digital signatures in a document.

ViewerDisplayPoints

JavaScript

This sample demonstrates how to use PDFNetJS to select elements in a PDF document. Click on an element in the PDF and it will show the element's bounding box and an outline if it is a PDF path.

ViewerEdit

JavaScript

This sample illustrates how PDFNetJS can be used to perform complex editing on PDF documents as they are displayed in the WebViewer. Open a PDF of your choice and press the refresh button at the top right to change all text to blue and all images to red.

ViewerPDFDiffTest

JavaScript

This sample illustrates how PDFNetJS can be used to compare two PDF documents and show their difference in WebViewer.

ViewerPreprocess

JavaScript

This sample illustrates how PDFNetJS can be used to preprocess a document before displaying it with WebViewer.

ViewerSnapToNearestTest

JavaScript

This sample illustrates how to use the snap API for calculating the nearest snap point.

Viewing

JavaScript

Shows how to call WebViewer constructor to instantiate and load document. You can load local/remote files of your choice.

Viewing with Custom Server (XOD)

JavaScript

Shows how to load XOD files, which are generated from a custom server.

Viewing with WebViewer Server

JavaScript

Shows how to call WebViewer constructor to instantiate and load document using WebViewer with WebViewer Server. You can upload local files or load files that are publicly accessible.

Vue

Github repo that demonstrates how to integrate WebViewer into Vue project.

WebViewerConvert

JavaScript

The sample is using pdftron.PDF.Convert.ToXod() to convert/stream PDF, XPS, MS Office, RTF, HTML and other document formats to WebViewer.

XFDF Import

JavaScript

PDFNet includes full support for FDF (Forms Data Format) and the capability to merge/extract forms data (FDF) with/from PDF. The sample illustrates basic XFDF merge functionality available in PDFNet.

deck.js

This sample illustrates how PDFNetJS can be used to power deck.js slideshows in the same way WebViewer does using PDFNet rasterizing functions.