Skip to content
ComPDF

PDF Generation Template Editor

Open-source visual PDF generation engine with customizable templates and developer-friendly APIs.

View on GitHub

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: ''
});