Samples

Add Image to PDF

Editing
Full-API
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.

Annotation - Add and Edit in PDFs

Annotations
Full-API
JavaScript

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

Bookmark

Full-API
Generation
JavaScript
Viewing

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

Color separation

Extraction
JavaScript

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

Compare documents by image, pixels

JavaScript
Viewing

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

Complex Document Editing

Editing
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.

Content Editing (text and images)

Editing
JavaScript

Edit the content of a PDF document directly.

Convert - WebViewerConvert

Conversion
Full-API
JavaScript

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

Create and manipulate layers (OCG) - PDFLayers

Extraction
Full-API
Generation
JavaScript
Viewing

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.

Custom annotations

Annotations
JavaScript

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

Customize a PDF before Saving - ViewerCustomSave

Full-API
JavaScript
Optimization

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

Customizing UI - WebViewer

JavaScript
UI

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

Customizing form fields

Forms
JavaScript

Shows how to change color and opacity of form fields.

Digital Signature and Certification

Full-API
JavaScript
Signing

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

Element Builder - embed fonts, images

Generation
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.

Element Edit

Editing
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.

Element Reader

Editing
Full-API
JavaScript

Illustrates how to traverse page display list using ElementReader.

Encrypt and Decrypt Files

Full-API
JavaScript
Security

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

Extract SDF document

Editing
Full-API
JavaScript

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

Flipbook

JavaScript
Viewing

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

Form Builder - add fields

Editing
Forms
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.

Implement WebViewer Cross-Origin Resource Sharing - CORS

Loading WebViewer's lib from a different domain using CORS.

Implement WebViewer Offline Using Service Worker and localforage

Sample to implement WebViewer offline using service worker and localforage.

Implement WebViewer in Salesforce as a Lightning Web Component

Integrating Apryse WebViewer in Salesforce as a Lightning Web Component. Note that Salesforce static resources have file size limitation to 5MB, to safely upload to the Salesforce platform.

Implement WebViewer in a TypeScript Project

This sample adds a type definitions file to use the WebViewer API in TypeScript.

Implement WebViewer that Automates Face Redaction in PDFs

This sample automatically detects faces in a PDF document and redacts them using WebViewer.

Implement WebViewer using Vanilla JavaScript

Sample project to implement WebViewer in a Vanilla JavaScript.

Implement WebViewer with SQLite3 and XFDF to Enable Saving and Loading Annotations

Save and load annotations to a server-side database using SQLite3 and XFDF.

Implement WebViewer with a Video Addon to Load and Annotate HTML Videos

Loads and annotates HTML5 videos (.mp4, ogg, webm)

Implement WebViewer with an Audio Addon to Load, Annotate and Redact Audio Tracks

This React sample uses the audio addon for WebViewer to load, annotate and redact audio tracks.

Implement WebViewers in a React App to Merge and Re-Arrange Multiple Documents Using a Drop Zone

Merge and rearrange pages from multiple documents using a drop zone. Note that this is only enabled for client-side PDF and Office documents.

Implement a WebViewer that Generates DOCX

This JavaScript sample creates DOCX documents and displays them in WebViewer.

Integrate WebViewer in React to Create Vector-Quality Custom Annotations

Sample to integrate Apryse WebViewer in React and create vector-quality custom annotations.

Integrate WebViewer into Blazor

This sample integrates WebViewer into a Blazor Project.

Integrate WebViewer into Blazor WASM

This sample integrates WebViewer into a Blazor WebAssembly Project.

Integrate WebViewer into Electron Project

This sample integrates WebViewer into an Electron project.

Integrate WebViewer into Mendix

Sample of WebViewer integration into a Mendix low-code app.

Integrate WebViewer into Microsoft Teams

WebViewer implementation on a Microsoft Teams project.

Integrate WebViewer into Node.js and Enable Saving and Loading PDF Annotations

Save and load annotations using files and Node.js backend.

Integrate WebViewer into Node.js to Enable Saving and Loading XFDF Annotations

Save and load XFDF annotations using files and Node.js backend.

Integrate WebViewer into Nuxt 2

Sample project integrating WebViewer with Nuxt 2.

Integrate WebViewer into React

Sample project to implement WebViewer into a React project.

Integrate WebViewer into React and Enable Barcode Scanning and Writing

Sample project to implement a WebViewer into React for generating barcodes, stamping them onto a PDF and then reading them after they have been flattened.

Integrate WebViewer into Salesforce to View, Edit, Annotate, and Redact Attachments

How to View, Edit, Annotate and Redact Salesforce Record Attachment Files in a Lightning Web Component.

Integrate WebViewer into Tomcat JavaServer Pages (JSP)

This sample adds WebViewer as a Web Application that is hosted on a Tomcat Servlet.

Integrate WebViewer into a Flutter App to Enable Cross-Platform Document Viewing

Integrating Apryse WebViewer into a Flutter web project.

Integrate WebViewer into a Mendix Web Module

This sample provides a server side Mendix Web Module for WebViewer.

Integrate WebViewer into a Next.js 14 Project

This sample adds WebViewer into a TSX component for use in a Next.js 14 Project.

Integrate WebViewer into a Node.js App for Enhanced Server-Side Search Functionality

Sample project to integrate WebViewer with Node.js enabling server-side searches.

Integrate WebViewer into a Power Apps Component

This sample shows how to integrate WebViewer into a Power Apps component project.

Integrate WebViewer into a React App with Custom UI Enhancements

Sample that demonstrates several features to customize WebViewer into a React app that renders without <iFrame>, <button> elements for expanded functions, and on leveraging search APIs.

Integrate WebViewer into a Svelte Project

This sample adds WebViewer into a Svelte component for use in a Svelte project.

Integrate WebViewer into a Vue.js Project

This sample adds WebViewer into a Vue component for use in a Vue.js project

Integrate WebViewer into a WinForms Project

This sample integrates WebViewer into a WinForms project using Microsoft Edge's WebView2 control.

Integrate WebViewer into a jQuery Content Delivery Network (CDN)

This sample shows how a WebViewer VanillaJS app can be retrieved and delivered by jQuery CDN.

Integrate WebViewer with ASP.NET to Enable Saving and Loading Annotations

Save and load annotations to disk using XFDF and HTTP messaging

Integrate WebViewer with Angular

This sample shows how to integrate WebViewer into an Angular project.

Integrate WebViewer with Annotations in PHP backend

Sample project that implements WebViewer into a PHP backend development environment.

Integrate WebViewer with Node.js to Enable Bookmark Saving and Loading

Sample WebViewer project with a Node.js backend that enables save/load user bookmarks.

Integrate WebViewer with SQLite3 to Enable Collaboration

This sample shows how to construct a collaboration server for WebViewer through WebSocket, SQLite3, and Node.js.

Interactive Forms

Forms
JavaScript

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

Layer separation

Extraction
JavaScript

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

Logical structure reader

Accessibility
Full-API
JavaScript

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

Measurement annotations

Annotations
JavaScript

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

Media box manipulation - PDFRect

Editing
Full-API
JavaScript

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

Merge, copy, delete, rearrange PDF pages

Editing
Full-API
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.

Office template filling

Generation
JavaScript

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

Office to PDF

Conversion
JavaScript
Office

This sample illustrates how to convert office files to PDF.

Optimizer to Compress PDF Files

Full-API
JavaScript
Optimization

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'.

PDF Comparison by image - ViewerPDFDiff

Full-API
JavaScript
Viewing

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

PDFA - Validate and Convert

Conversion
Full-API
JavaScript

This sample demonstrates PDFA verification and conversion.

Page operations

Editing
JavaScript

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

Preloading WebViewer and Documents

JavaScript
Optimization

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

Preprocess document before viewing - ViewerPreprocess

Editing
Full-API
JavaScript

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

Reader Mode - ReaderMode

Accessibility
Full-API
JavaScript
Viewing

This sample demonstrates Reader Mode in WebViewer.

Realtime collaboration - Firebase

Annotations
Firebase
JavaScript

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

Redact Documents

JavaScript
Redaction

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

Redact document

JavaScript
Redaction

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

Redact people faces from PDF

JavaScript
Redaction

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

Render PDF image - PDFDraw

Full-API
Generation
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.

Replace Text, Image, String - ContentReplacer

Editing
Full-API
JavaScript

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

Select elements, PDF path points - ViewerDisplayPoints

Extraction
Full-API
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.

Snap to nearest point - ViewerSnapToNearest

Annotations
Full-API
JavaScript

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

Stamper - Stamp Text & Image Annotations

Editing
Full-API
JavaScript

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

Switch Toolbar Language - Internationalization

JavaScript
UI

Shows how to switch language.

Text Extraction

Extraction
Full-API
JavaScript

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

Full-API
JavaScript
Search

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

Text position

Extraction
JavaScript

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

Text to Speech - Accessibility

Accessibility
JavaScript

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

Thumbnail controls

Editing
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
Security

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

Validate digital signature - ViewerDigitalSignatureValidation

Full-API
JavaScript
Signing

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

Viewer optimized PDFs

JavaScript
Optimization
Viewing

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

Viewing Documents with WebViewer

JavaScript
Viewing

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
Viewing

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

Viewing with WebViewer Server

JavaScript
Viewing
WebViewer Server

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.

XFDF Import

Annotations
Full-API
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.