Frameworks
Integrations
Mendix
SharePoint
Default UI
Modular 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
The PDF specification provides the definition of a standard set of annotations, but not how they are visually represented on screen as that is left to the document viewers. WebViewer allows changing how annotations are rendered when viewing them using the setCustomDrawHandler API. This can be applied to both standard and custom annotations in WebViewer.
If you are using custom annotations, they already have support for custom rendering. However, implementing one may be too much if you only want to change how annotations look, especially the standard set. This API will allow you to change how the annotations render without having to implement one.
The APIs in this guide are only available in WebViewer 7.1+.
To change how annotations are rendered, you can use the setCustomDrawHandler API.
Alongside the annotation class you are targeting, you must provide a new, custom draw function to the API that will perform the rendering. It takes the regular parameters you would expect from an annotation draw
function with an additional options
parameter. If you are using an arrow function (bound function), then you can find the annotation through the options
parameter.
Note that you get the annotation being drawn as well as the original annotation's draw function as part of the options
parameter. This allows you to reference the annotation and perform the original draw if necessary.
Although this works with annotations in WebViewer, other viewers will render the annotations according to how they render the annotations. By default, setCustomDrawHandler will generate an appearance for the annotation so it will look similar in other viewers. If you want to turn this off, perhaps for changing rendering at certain times or it's unnecessary, you can set the generateAppearance
option in the third parameter of the API.
When customizing annotation rendering, the original draw function is preserved. Calling the setCustomDrawHandler API again will not overwrite the original draw function. This allows the original behavior of the annotation to be restored with restoreDraw API.
Check out how to customize the serialization/deserialization behavior of annotations to save your custom properties.
Did you find this helpful?
Trial setup questions?
Ask experts on DiscordNeed other help?
Contact SupportPricing or product questions?
Contact Sales