Skip to content
ComPDF
New Release

Open-Source PDF SDK & AI Document Processing

Get the full self-hosted SDK and AI document processing on GitHub. One-click deploy to quickly build your document workflows.

Set Default Properties of Annotations

You can set the default properties of annotations in the Web PDF Viewer. The following code shows you how to set the default properties of annotations:

javascript
// You can get all tools
const tools = docViewer.getToolMap();

// You can also get the styles of a specific tool, for example, the freetext tool.
const textToolStyles = docViewer.getToolStyles('freetext');

// Set the default properties of text annotations.
docViewer.setToolStyles('freetext', {
  fontName: 'Helvetica',
  fontStyle: 'normal',
  fontWeight: 'normal',
  fontSize: 14,
  textAlignment: 'left',
  color: 'rgb(0, 0, 0)',
  borderWidth: 0,
  borderColor: 'rgb(0, 0, 0)',
  borderStyle: 'solid',
  fillColor: '',
  opacity: 1,
  contents: ''
});