This guide will show you how to integrate WebViewer Document Viewer & Editor into a Svelte application.
You can also download a ready-to-go sample on GitHub.
Prior to starting, you should have already installed Node and npm.
Get your Apryse trial key.
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.
This video teaches you the fundamentals of installing and initializing WebViewer in any web application. If you wish, you may skip this section and proceed to the steps below.
If you already have a Svelte project, skip to step 2.
To get our project set up, we will use SvelteKit. Start by setting up the project with the following command, replacing <project-name>
with your desired project name.
You may be asked if you want to install the sv
package - in this case, enter "y".
When asked which template you want to use, select SvelteKit minimal
. For the rest of the questions, you may select anything you wish - your choices will not impact the rest of this guide.
Once the project has been set up, we can navigate into our project directory.
We can now install WebViewer by running:
In addition to installing WebViewer, we will need to set up a script to copy the static WebViewer dependencies into statically served folder in your project (in Svelte it's the static
folder). The reason for this is because WebViewer contains many assets that cannot be bundled by the build system. Instead, these assets need to be served statically.
In package.json
we will add a command that copies these static assets to our static
folder. You'll also notice that we run this new command before any of the Svelte tools to ensure the files are always in the proper place when running our app.
package.json
Read more about copying WebViewer static assets.
Now we are ready to start using WebViewer.
Create a file called WebViewer.svelte
and add the following code. This will be our WebViewer component that we use elsewhere in our app.
src/WebViewer.svelte
In this code we are dynamically importing WebViewer to prevent it from being loaded server side. If you are not using server side rendering, you can import WebViewer as you normally would.
Now we can implement this component elsewhere.
routes/+page.svelte
Now we can start our app with npm run dev
- you should see WebViewer loaded with the default document displayed.
Did you find this helpful?
Trial setup questions?
Ask experts on DiscordNeed other help?
Contact SupportPricing or product questions?
Contact Sales