Frameworks
Integrations
Mendix
SharePoint
Modular UI
Legacy UI
AnnotationManager
Annotation Types
Customize
Version 11
Version 10
v10.12
v10.11
v10.10
v10.9
v10.8
v10.7
v10.6
v10.5
v10.4
v10.3
v10.2
v10.1
v10.0
Version 8
v8.12
v8.11
v8.10
v8.9
v8.8
v8.7
v8.6
v8.5
v8.4
v8.3
v8.2
v8.1
v8.0
Version 7
Version 6
v6.3
v6.2
v6.1
v6.0
Version 5
Version 4
Version 3
Version 2
WebViewer Server
WebViewer BIM
Starting in version 11 WebViewer will be instantiated in a Web Component by default instead of an iframe.
There are some differences between working with WebViewer as an iframe and as a Web Component. Here are some of the key changes:
When using an iframe, it is possible to access DOM elements using instance.UI.iframeWindow.document
.
However, with a Web Component, WebViewer is part of the main document but encapsulated within a Shadow DOM. Shadow DOM provides a contained scope for the Web Component, helping prevent unintended styling or script interference from the rest of the page. To access elements inside this Web Component, you need to first access its shadowRoot
and then query within it.
This shadowRoot
approach gives access to elements within the isolated part of the DOM where WebViewer resides. It respects the Shadow DOM’s encapsulation, which is key to keeping the component’s styles and scripts scoped and self-contained, while still allowing controlled access for customization or interaction when needed.
Since WebViewer is encapsulated within a Shadow DOM, in order to apply CSS styles to elements in WebViewer you need to use the :host
selector when using the css
option in your WebViewer constructor. This selector targets the Web Component itself, allowing you to style its elements from the outside.
The following code would style the WebViewer to use white icons and blue headers.
You can then include the CSS file in the css
property of your WebViewer constructor like so:
Without using the :host
selector, the styles would not be applied to the WebViewer.
Up until now, WebViewer has been instantiated using an iframe. An iframe, or inline frame, is an HTML document embedded inside another HTML document. Iframes have several benefits, such as content isolation and the ability to display content from different sources. However, they also present certain drawbacks. For instance, iframes can slow down site performance as the browser needs to load two separate pages. They can also pose accessibility challenges for assistive technologies like screen readers. Furthermore, running WebViewer in an iframe prevents the parent page from accessing its content directly, limiting opportunities for data gathering and analytics to better understand how users interact with your documents.
Web Components are a suite of web platform APIs that allow developers to create custom, reusable, encapsulated HTML tags for use in web pages and apps. As part of the web browser standard, they're an excellent choice for creating reusable code modules.
Benefits of Web Components:
With the release of version 11, WebViewer is now instantiated as a Web Component by default. This allows you to leverage the advantages of encapsulation and reusability while giving your site direct access to the viewer's content. As a result, you can create a more seamless experience for your users and gather data and analytics on how they interact with your documents.
Previously when using NPM to integrate WebViewer into your project, there needed to be minimal code changes to instantiate WebViewer as a Web Component.
In version 11, there is no longer any need to use WebViewer.WebComponent
as Web Component is now the default for WebViewer. The following code snippet demonstrates how to instantiate WebViewer as a Web Component:
If you prefer to use an iframe, you can still do so by replacing the WebViewer
function with WebViewer.Iframe
and it will work as it did before.
Manual integration is also straightforward. For more info please refer to the manual integration guide.
Large resource and worker files can be hosted on a CDN or some other external server for faster access and caching. WebViewer provides several APIs for dealing with cross-origin resource sharing issues and you can read more about it in this Cross Origin Workers guide.
Did you find this helpful?
Trial setup questions?
Ask experts on DiscordNeed other help?
Contact SupportPricing or product questions?
Contact Sales