Libraries and Frameworks
Integrations
The Apryse WebViewer SDK delivers high-quality rendering, conversion, and document manipulation capabilities through a single, customizable component. Supporting PDF, Office, CAD, and images, it's fully featured out of the box, delivering great usability and functionality.
Adding WebViewer to your application allows users to view and edit PDFs without going outside of your application. This reduces reliance on third-party systems, multiple vendors, and file downloads for everyday tasks without compromising control, compliance, or security.
Interact with our showcase demo to test out all of the Apryse WebViewer SDK functionality.
WebViewer provides a UI to view and annotate documents, but it also provides access to Apryse's SDK which allows you to perform document operations without the UI. This is useful for areas of your app that need additional document processing without viewing a document.
Common use cases for performing document operations without the WebViewer UI include using it to:
This guide walks you through how to integrate the WebViewer SDK into your project without using the WebViewer UI. By the end, you'll be able to:
Get started with the Apryse WebViewer SDK functionality without using the WebViewer UI. This video includes instructions for successfully integrating the WebViewer SDK into your application and building functionality without using the UI. You can also skip the video and, instead, follow the steps below to get started.
Use WebViewer functionality without using the UI
Before you start:
Apryse collects some data regarding your usage of the SDK for product improvement.
If you wish to continue without data collection, contact us and we will email you a no-tracking trial key for you to get started.
Download the WebViewer package (contains library and samples).
Extract the WebViewer package (WebViewer.zip
) into your project folder. For this guide, we'll call our project folder without-viewer
.
1. In your text editor, create a new index.html
file in your without-viewer
folder.
2. Paste the HTML below into the index.html
file. A few essential things to take note of in the HTML page are that:
webviewer-core.min.js
file.PDFNet.js
file. This file and the file mentioned in the bullet above were included in the zip file you extracted in Section 2 above.If you're not going to use any of the advanced PDFNet functionality, you can use the PDFNetLean.js
script instead. It's smaller and loads and runs more quickly. For this tutorial, we'll use the full PDFNet
even though it's not required.
WebViewer Core is the core for WebViewer. The usual script required with the UI is webviewer.min.js
. In a viewless scenario though, you only need to import the core script, webviewer-core.min.js
, and PDFNet.js
. Alternatively, you can import PDFNetLean.js
to include functions that come from PDFNet.js
, but do not require fullAPI
.
Next, copy the block of code below, which includes HTML and JavaScript, into the index.html
file you made. Add the code after the <h1>Working without a viewer</h1> heading and before the close body tag.
A few essential things to take note of about the code above include:
scroll-view
and one named viewer
. Core.setWorkPath
, specify the worker path which allows PDFNet
to know where the functionality is that it will need to use within this program. main
function that takes parameters from the URL and decides what to do with those URL parameters. countpages
, it takes the URL and creates a PDF document from it. Then, it calculates the page count from the document and displays the count in an alert. show
, then it takes the URL and creates a custom document viewer. In this case, it uses the viewer actually built into WebViewer. You can use an alternative viewer if you prefer. Next, the divs for scroll-view
and viewer
are included, and loadDocument
loads the document into the viewer.convert
, then it takes the URL, which is a docx file, and runs it through office2PDF
. This returns a PDFDoc
object. It then downloads the PDF object. main
, and your license key. When the page loads, it will hit Core.PDFNET.runWithCleanup
, call the main
function, and complete what we listed above.
After you've saved the file, you'll serve the webpage so you can see:
Let's use http-server to view these actions.
1. Run the following command on the command line from your project directory to run http-server which is a simple web server.
2. Click the localhost
link created in your terminal to view the the results locally.
You'll see the HTML you wrote.
3. Copy the first URL, ?countpages=https://pdftron.s3.amazonaws.com/pl/demo-annotated.pdf
, and paste it after localhost: 8080/
in the browser, then press Enter. An alert displays with the page count of the PDF.
Alert displaying with the total page count of the PDF
4. Copy the second URL and paste it after localhost: 8080/
in the browser, then press Enter. You'll see the PDF display with a minimal viewer.
A minimal viewer displaying the PDF
5. Copy the third URL and paste it after localhost: 8080/
in the browser, then press Enter. You'll see the PDF version download.
The Download icon is highlighted which means it's downloading the converted PDF
Did you find this helpful?
Trial setup questions?
Ask experts on DiscordNeed other help?
Contact SupportPricing or product questions?
Contact Sales