Some test text!

menu
search
Default styleskeyboard_arrow_down

Customizing default annotation styles

An annotation's default style is often governed by a tool associated with it. For example, a tool will set stroke color, stroke thickness, fill color, text color, font size and opacity of the annotation, which becomes their 'default' style. To change these properties, you can use the setStyles function on the tool objects.

WebViewer({ ... }, viewerElement)
  .then(function(instance) {
    var docViewer = instance.docViewer;
    var Annotations = instance.Annotations;

    docViewer.getTool('AnnotationCreateTextHighlight').setStyles(function(currentStyle) {
      return {
        StrokeColor: new Annotations.Color(0, 221, 255)
      };
    });

    docViewer.getTool('AnnotationCreateFreeText').setStyles(function(currentStyle) {
      return {
        StrokeThickness: 5,
        StrokeColor: new Annotations.Color(0, 0, 255),
        TextColor: new Annotations.Color(0, 0, 0),
        FontSize: '20pt'
      };
    });
  });

Get the answers you need: Support

close

Free Trial

Get unlimited trial usage of PDFTron SDK to bring accurate, reliable, and fast document processing capabilities to any application or workflow.

Select a platform to get started with your free trial.

Unlimited usage. No email address required.

PDFTron Receives USD$71 Million Growth Investment Led By Silversmith Capital Partners

Learn More
close