This guide will show you how to integrate WebViewer Document Viewer & Editor into a Vue 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 Vue project set up, skip to step 2.
We will use the create-vue
CLI tool to scaffold our project. Run the tool by running the following command.
You may be asked if you want to install the create-vue
package. In this case, select yes.
Next you will be asked to name your project. You can choose whatever you wish, but for this example we will use webviewer-vue
You will now be asked to select which features to include in your project. For this step, you may choose whatever you wish - your choices will not impact the rest of the steps.
Once you have selected your features and finished running the scaffolding tool, we can install our dependencies by running the following command.
Now that we have a Vue project to work in, we can install WebViewer.
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 (usually public
). The reason for this is because WebViewer contains many assets that cannot be bundled by your 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 public
folder (or whatever your folder may be called).
package.json
You'll notice that we also updated our other scripts to run this command first - this is recommended to make sure your WebViewer assets are always in the right place.
Read more about copying WebViewer static assets.
Now that we have WebViewer installed, we are ready to implement it into our app.
For this example we will create a new component for WebViewer. Create a file called components/WebViewer.vue
and add the following code:
components/WebViewer.vue
Notice that the path
parameter we pass to the WebViewer constructor points to the same place we copied the static assets to in the previous step.
Now that we have our component, we can use it elsewhere in our app like so.
App.vue
If you do not see WebViewer in your app, ensure that your CSS styles are set up correctly. WebViewer will always fill the entire width and height of the DOM element that you mount it to.
That's it! If you run your app, you should see WebViewer mounted with the initial document loaded.
Did you find this helpful?
Trial setup questions?
Ask experts on DiscordNeed other help?
Contact SupportPricing or product questions?
Contact Sales